FirstPersonCamera.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef FIRSTPERSONCAMERA_H_
  2. #define FIRSTPERSONCAMERA_H_
  3. #include "gameplay.h"
  4. using namespace gameplay;
  5. /**
  6. * FirstPersonCamera controls a camera like a first person shooter game.
  7. */
  8. class FirstPersonCamera
  9. {
  10. public:
  11. /**
  12. * Constructor.
  13. */
  14. FirstPersonCamera();
  15. /**
  16. * Destructor.
  17. */
  18. ~FirstPersonCamera();
  19. /**
  20. * Initializes the first person camera. Should be called after the Game has been initialized.
  21. */
  22. void initialize(float nearPlane = 1.0f, float farPlane = 1000.0f, float fov = 45.0f);
  23. /**
  24. * Gets root node. May be NULL if not initialized.
  25. *
  26. * @return Root node or NULL.
  27. */
  28. Node* getRootNode();
  29. /**
  30. * Gets the camera. May be NULL.
  31. *
  32. * @return Camera or NULL.
  33. */
  34. Camera* getCamera();
  35. /**
  36. * Sets the position of the camera.
  37. *
  38. * @param position The position to move to.
  39. */
  40. void setPosition(const Vector3& position);
  41. /**
  42. * Moves the camera forward in the direction that it is pointing. (Fly mode)
  43. */
  44. void moveForward(float amount);
  45. /**
  46. * Moves the camera in the opposite direction that it is pointing.
  47. */
  48. void moveBackward(float amount);
  49. /**
  50. * Strafes that camera left, which is perpendicular to the direction it is facing.
  51. */
  52. void moveLeft(float amount);
  53. /**
  54. * Strafes that camera right, which is perpendicular to the direction it is facing.
  55. */
  56. void moveRight(float amount);
  57. void moveUp(float amount);
  58. void moveDown(float amount);
  59. /**
  60. * Rotates the camera in place in order to change the direction it is looking.
  61. *
  62. * @param yaw Rotates the camera around the yaw axis in radians. Positive looks right, negative looks left.
  63. * @param pitch Rotates the camera around the ptich axis in radians. Positive looks up, negative looks down.
  64. */
  65. void rotate(float yaw, float pitch);
  66. private:
  67. Node* _pitchNode;
  68. Node* _rootNode;
  69. };
  70. #endif