Open Source Tomb Raider Engine
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Camera.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*!
  2. * \file include/Camera.h
  3. * \brief Camera class
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _CAMERA_H_
  9. #define _CAMERA_H_
  10. #include "math/math.h"
  11. #include "math/Quaternion.h"
  12. /*!
  13. * \brief Commands for interactive camera control
  14. */
  15. enum camera_command {
  16. CAMERA_ROTATE_RIGHT,
  17. CAMERA_ROTATE_LEFT,
  18. CAMERA_ROTATE_UP,
  19. CAMERA_ROTATE_DOWN
  20. };
  21. /*!
  22. * \brief Camera class
  23. */
  24. class Camera {
  25. public:
  26. /*!
  27. * \brief Constructs an object of Camera
  28. */
  29. Camera();
  30. /*!
  31. * \brief Get the target currently looked at
  32. * \param target where the target will be stored
  33. */
  34. void getTarget(vec3_t target);
  35. /*!
  36. * \brief Get angle/yaw of camera
  37. * \returns theta angle/yaw of camera
  38. */
  39. vec_t getRadianYaw();
  40. /*!
  41. * \brief Get angle/pitch of camera
  42. * \returns phi angle/pitch of camera
  43. */
  44. vec_t getRadianPitch();
  45. /*!
  46. * \brief Set current position
  47. * \param pos new position
  48. */
  49. void setPosition(vec3_t pos);
  50. void setSensitivityX(vec_t sens);
  51. void setSensitivityY(vec_t sens);
  52. /*!
  53. * \brief Updates view target
  54. */
  55. void update();
  56. /*!
  57. * \brief Sends interactive command to camera
  58. * \param cmd valid camera command
  59. */
  60. void command(enum camera_command cmd);
  61. private:
  62. void rotate(vec_t angle, vec_t x, vec_t y, vec_t z);
  63. Quaternion mQ; //!< Quaternion for rotation
  64. vec4_t mPos; //!< Location in 3 space (aka eye)
  65. vec4_t mTarget; //!< Postition we're looking at
  66. vec_t mViewDistance; //!< Distance from target
  67. vec_t mTheta; //!< View angle Y
  68. vec_t mTheta2; //!< View angle Z
  69. vec_t mRotationDeltaX; //!< Horizontal mouse sensitivity
  70. vec_t mRotationDeltaY; //!< Vertical mouse sensitivity
  71. };
  72. Camera &getCamera();
  73. #endif