Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Camera.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/Matrix.h"
  12. #include "math/Quaternion.h"
  13. /*!
  14. * \brief Commands for interactive camera control
  15. */
  16. enum camera_command {
  17. CAMERA_ROTATE_RIGHT,
  18. CAMERA_ROTATE_LEFT,
  19. CAMERA_ROTATE_UP,
  20. CAMERA_ROTATE_DOWN
  21. };
  22. /*!
  23. * \brief Camera class
  24. */
  25. class Camera {
  26. public:
  27. /*!
  28. * \brief Constructs an object of Camera
  29. */
  30. Camera();
  31. /*!
  32. * \brief Returns the current position
  33. * \param pos where the position will be stored
  34. */
  35. void getPosition(vec3_t pos);
  36. /*!
  37. * \brief Get the target currently looked at
  38. * \param target where the target will be stored
  39. */
  40. void getTarget(vec3_t target);
  41. /*!
  42. * \brief Get angle/yaw of camera
  43. * \returns theta angle/yaw of camera
  44. */
  45. vec_t getRadianYaw();
  46. /*!
  47. * \brief Get angle/pitch of camera
  48. * \returns phi angle/pitch of camera
  49. */
  50. vec_t getRadianPitch();
  51. /*!
  52. * \brief Set current position
  53. * \param pos new position
  54. */
  55. void setPosition(vec3_t pos);
  56. void setSensitivityX(vec_t sens);
  57. void setSensitivityY(vec_t sens);
  58. /*!
  59. * \brief Updates view target
  60. */
  61. void update();
  62. /*!
  63. * \brief Rotate the camera
  64. * \param angle angle in radians
  65. * \param x X coordinate of axis
  66. * \param y Y coordinate of axis
  67. * \param z Z coordinate of axis
  68. */
  69. void rotate(vec_t angle, vec_t x, vec_t y, vec_t z);
  70. /*!
  71. * \brief Sends interactive command to camera
  72. * \param cmd valid camera command
  73. */
  74. void command(enum camera_command cmd);
  75. private:
  76. Quaternion mQ; //!< Quaternion for rotation
  77. vec_t mPos[4]; //!< Location in 3 space (aka eye)
  78. vec_t mTarget[4]; //!< Postition we're looking at
  79. vec_t mUp[4]; //!< Up vector
  80. vec_t mSide[4]; //!< Side vector
  81. vec_t mViewDistance; //!< Distance from target
  82. vec_t mTheta; //!< View angle Y
  83. vec_t mTheta2; //!< View angle Z
  84. vec_t mRotationDeltaX;
  85. vec_t mRotationDeltaY;
  86. };
  87. Camera &getCamera();
  88. #endif