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.0KB

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