camera.h
Upload User: szxjsk
Upload Date: 2022-06-16
Package Size: 35k
Code Size: 1k
Category:

OpenGL program

Development Platform:

C/C++

  1. //***************************************************************************
  2. //
  3. // Advanced CodeColony Camera
  4. // Philipp Crocoll, 2003
  5. //
  6. //***************************************************************************
  7. #include <glglut.h> // Need to include it here because the GL* types are required
  8. #define PI 3.1415926535897932384626433832795
  9. #define PIdiv180 (PI/180.0)
  10. /////////////////////////////////
  11. //Note: All angles in degrees  //
  12. /////////////////////////////////
  13. struct SF3dVector  //Float 3d-vect, normally used
  14. {
  15. GLfloat x,y,z;
  16. };
  17. struct SF2dVector
  18. {
  19. GLfloat x,y;
  20. };
  21. SF3dVector F3dVector ( GLfloat x, GLfloat y, GLfloat z );
  22. class CCamera
  23. {
  24. private:
  25. GLfloat RotatedX, RotatedY, RotatedZ;
  26. public:
  27. CCamera(); //inits the values (Position: (0|0|0) Target: (0|0|-1) )
  28. void Render ( void ); //executes some glRotates and a glTranslate command
  29. //Note: You should call glLoadIdentity before using Render
  30. void Move ( SF3dVector Direction );
  31. void RotateX ( GLfloat Angle );
  32. void RotateY ( GLfloat Angle );
  33. void RotateZ ( GLfloat Angle );
  34. void MoveForward ( GLfloat Distance );
  35. void MoveUpward ( GLfloat Distance );
  36. void StrafeRight ( GLfloat Distance );
  37. SF3dVector ViewDir;
  38. SF3dVector RightVector;
  39. SF3dVector UpVector;
  40. SF3dVector Position;
  41. };