Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Camera.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*!
  2. * \file include/Camera.h
  3. * \brief OpenGL camera class
  4. *
  5. * \author Mongoose
  6. */
  7. #ifndef _CAMERA_H_
  8. #define _CAMERA_H_
  9. #include "math/math.h"
  10. #include "math/Matrix.h"
  11. #include "math/Quaternion.h"
  12. /*!
  13. * \brief Commands for interactive camera control
  14. */
  15. enum camera_command {
  16. CAMERA_MOVE_FORWARD = 1,
  17. CAMERA_MOVE_BACKWARD,
  18. CAMERA_MOVE_UP,
  19. CAMERA_MOVE_DOWN,
  20. CAMERA_ROTATE_RIGHT,
  21. CAMERA_ROTATE_LEFT,
  22. CAMERA_SPEED_UP,
  23. CAMERA_SPEED_DOWN,
  24. CAMERA_ROTATE_UP,
  25. CAMERA_ROTATE_DOWN,
  26. CAMERA_MOVE_LEFT,
  27. CAMERA_MOVE_RIGHT
  28. };
  29. /*!
  30. * \brief Flags a camera can have
  31. */
  32. enum CameraFlags {
  33. Camera_FlyMode = (1 << 0) //!< Camera is flying free?
  34. };
  35. /*!
  36. * \brief OpenGL camera class
  37. *
  38. * 2002.12.16:
  39. * Mongoose - Removed perspective setting and OpenGL dependency
  40. * API changes to reflect new direction of this object:
  41. * Removing outdated algorithms and code
  42. * And refactoring the class in general
  43. *
  44. * 2001.06.06:
  45. * Mongoose - Moving GLU code into here to setup break up
  46. * into Camera base class, DynamicCamera,
  47. * and GLUCamera child classes
  48. *
  49. * 2001.06.04:
  50. * Mongoose - Quaternion based compile option
  51. *
  52. * 2001.05.18:
  53. * Mongoose - Created, based on my old GL camera code
  54. * that has been used in GooseEgg since alpha
  55. * and algorithms from Yuri Zhivago's trview
  56. */
  57. class Camera {
  58. public:
  59. /*!
  60. * \brief Constructs an object of Camera
  61. */
  62. Camera();
  63. /*!
  64. * \brief Returns the current position
  65. * \param pos where the position will be stored
  66. */
  67. void getPosition(vec3_t pos);
  68. /*!
  69. * \brief Returns the up vector
  70. * \param up where the up vector will be stored
  71. */
  72. void getUp(vec3_t up);
  73. /*!
  74. * \brief Get the target currently looked at
  75. * \param target where the target will be stored
  76. */
  77. void getTarget(vec3_t target);
  78. /*!
  79. * \brief Get current yaw in degrees
  80. * \returns yaw in degrees
  81. */
  82. float getYaw();
  83. /*!
  84. * \brief Get angle/yaw of camera
  85. * \returns theta angle/yaw of camera
  86. */
  87. vec_t getRadianYaw();
  88. /*!
  89. * \brief Get current angle/pitch
  90. * \returns current pitch in degrees
  91. */
  92. float getPitch();
  93. /*!
  94. * \brief Get angle/pitch of camera
  95. * \returns phi angle/pitch of camera
  96. */
  97. vec_t getRadianPitch();
  98. /*!
  99. * \brief Rotate the camera
  100. * \param angle angle in radians
  101. * \param x X coordinate of axis
  102. * \param y Y coordinate of axis
  103. * \param z Z coordinate of axis
  104. */
  105. void rotate(float angle, float x, float y, float z);
  106. /*!
  107. * \brief Set Camera position
  108. * \param x new X coordinate
  109. * \param y new Y coordinate
  110. * \param z new Z coordinate
  111. */
  112. void translate(float x, float y, float z);
  113. /*!
  114. * \brief Set the Camera to its initial state
  115. */
  116. void reset();
  117. /*!
  118. * \brief Sends interactive command to camera
  119. * \param cmd valid camera command
  120. */
  121. void command(enum camera_command cmd);
  122. /*!
  123. * \brief Sets speed
  124. * \param s new speed, is 256 or greater in general
  125. */
  126. void setSpeed(float s);
  127. /*!
  128. * \brief Updates view target
  129. */
  130. void update();
  131. /*!
  132. * \brief Set current position
  133. * \param pos new position
  134. */
  135. void setPosition(vec3_t pos);
  136. /*!
  137. * \brief Sets the up vector
  138. * \param up new up vector
  139. */
  140. void setUp(vec3_t up);
  141. /*!
  142. * \brief Sets target (look at pos)
  143. * \param target new target
  144. */
  145. void setTarget(vec3_t target);
  146. private:
  147. Quaternion mQ; //!< Quaternion for rotation
  148. unsigned int mFlags; //!< For testing with flags
  149. vec_t mPos[4]; //!< Location in 3 space (aka eye)
  150. vec_t mTarget[4]; //!< Postition we're looking at
  151. vec_t mUp[4]; //!< Up vector
  152. vec_t mSide[4]; //!< Side vector
  153. vec_t mViewDistance; //!< Distance from target
  154. vec_t mTranslateDelta; //!< Step size to move
  155. vec_t mTheta; //!< View angle Y
  156. vec_t mTheta2; //!< View angle Z
  157. };
  158. #endif