Camera.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <anki/scene/SceneNode.h>
  7. #include <anki/scene/SpatialComponent.h>
  8. #include <anki/scene/MoveComponent.h>
  9. #include <anki/scene/FrustumComponent.h>
  10. namespace anki
  11. {
  12. /// @addtogroup Scene
  13. /// @{
  14. /// Camera SceneNode interface class
  15. class Camera : public SceneNode
  16. {
  17. friend class CameraMoveFeedbackComponent;
  18. friend class CameraFrustumFeedbackComponent;
  19. public:
  20. /// @note Don't EVER change the order
  21. enum class Type : U8
  22. {
  23. PERSPECTIVE,
  24. ORTHOGRAPHIC,
  25. COUNT
  26. };
  27. Camera(SceneGraph* scene, Type type);
  28. virtual ~Camera();
  29. ANKI_USE_RESULT Error create(const CString& name, Frustum* frustum);
  30. Type getCameraType() const
  31. {
  32. return m_type;
  33. }
  34. void lookAtPoint(const Vec3& point);
  35. private:
  36. Type m_type;
  37. /// Called when moved.
  38. void onMoveComponentUpdate(MoveComponent& move);
  39. /// Called when something changed in the frustum.
  40. void onFrustumComponentUpdate(FrustumComponent& fr);
  41. };
  42. /// Perspective camera
  43. class PerspectiveCamera : public Camera
  44. {
  45. public:
  46. PerspectiveCamera(SceneGraph* scene);
  47. ~PerspectiveCamera();
  48. ANKI_USE_RESULT Error create(const CString& name)
  49. {
  50. return Camera::create(name, &m_frustum);
  51. }
  52. void setAll(F32 fovX, F32 fovY, F32 near, F32 far);
  53. private:
  54. PerspectiveFrustum m_frustum;
  55. };
  56. /// Orthographic camera
  57. class OrthographicCamera : public Camera
  58. {
  59. public:
  60. OrthographicCamera(SceneGraph* scene);
  61. ~OrthographicCamera();
  62. ANKI_USE_RESULT Error create(const CString& name)
  63. {
  64. return Camera::create(name, &m_frustum);
  65. }
  66. private:
  67. OrthographicFrustum m_frustum;
  68. };
  69. /// @}
  70. } // end namespace anki