Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Camera.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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