PerspectiveCamera.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef PERSPECTIVE_CAMERA_H
  2. #define PERSPECTIVE_CAMERA_H
  3. #include "Camera.h"
  4. /// @todo
  5. class PerspectiveCamera: public Camera
  6. {
  7. public:
  8. PerspectiveCamera(bool inheritParentTrfFlag, SceneNode* parent);
  9. /// @name Accessors
  10. /// @{
  11. float getFovX() const {return fovX;}
  12. void setFovX(float fovx);
  13. float getFovY() const {return fovY;}
  14. void setFovY(float fovy);
  15. /// @}
  16. void setAll(float fovx, float fovy, float znear, float zfar);
  17. private:
  18. /// @name Data
  19. /// @{
  20. /// fovX is the angle in the y axis (imagine the cam positioned in
  21. /// the default OGL pos) Note that fovX > fovY (most of the time) and
  22. /// aspectRatio = fovX/fovY
  23. float fovX;
  24. float fovY; /// @see fovX
  25. /// @}
  26. /// Implements Camera::calcLSpaceFrustumPlanes
  27. void calcLSpaceFrustumPlanes();
  28. /// Implements Camera::calcProjectionMatrix
  29. void calcProjectionMatrix();
  30. /// Implements Camera::getExtremePoints
  31. void getExtremePoints(Vec3* pointsArr, uint& pointsNum) const;
  32. };
  33. inline PerspectiveCamera::PerspectiveCamera(bool inheritParentTrfFlag,
  34. SceneNode* parent)
  35. : Camera(CT_PERSPECTIVE, inheritParentTrfFlag, parent)
  36. {
  37. name = "PerspectiveCamera:" + name;
  38. }
  39. inline void PerspectiveCamera::setFovX(float fovx_)
  40. {
  41. fovX = fovx_;
  42. calcProjectionMatrix();
  43. calcLSpaceFrustumPlanes();
  44. }
  45. inline void PerspectiveCamera::setFovY(float fovy_)
  46. {
  47. fovY = fovy_;
  48. calcProjectionMatrix();
  49. calcLSpaceFrustumPlanes();
  50. }
  51. #endif