Aether3D Game Engine
All Classes Namespaces Functions Variables Enumerations Pages
CameraComponent.hpp
1 #ifndef CAMERA_COMPONENT_H
2 #define CAMERA_COMPONENT_H
3 
4 #include <string>
5 #include "Vec3.hpp"
6 #include "Matrix.hpp"
7 
8 namespace ae3d
9 {
10  class RenderTexture;
11 
14  {
15  public:
17  enum class ProjectionType { Orthographic, Perspective };
18 
20  enum class ClearFlag { DepthAndColor, DontClear };
21 
23  const Matrix44& GetProjection() const { return projectionMatrix; }
24 
26  const Matrix44& GetView() const { return viewMatrix; }
27 
29  ProjectionType GetProjectionType() const { return projectionType; }
30 
32  void SetProjectionType( ProjectionType aProjectionType ) { projectionType = aProjectionType; }
33 
44  void SetProjection( float left, float right, float bottom, float top, float near, float far );
45 
54  void SetProjection( float fovDegrees, float aspect, float near, float far );
55 
57  void SetProjection( const Matrix44& proj );
58 
60  Vec3 GetClearColor() const { return clearColor; }
61 
63  RenderTexture* GetTargetTexture() { return targetTexture; }
64 
66  void SetClearColor( const Vec3& color );
67 
69  void SetTargetTexture( RenderTexture* renderTexture );
70 
72  void SetClearFlag( ClearFlag clearFlag );
73 
75  ClearFlag GetClearFlag() const { return clearFlag; }
76 
78  float GetNear() const { return nearp; }
79 
81  float GetFar() const { return farp; }
82 
84  float GetAspect() const { return aspect; }
85 
87  float GetFovDegrees() const { return fovDegrees; }
88 
90  std::string GetSerialized() const;
91 
93  float GetLeft() const { return orthoParams.left; }
94 
96  float GetRight() const { return orthoParams.right; }
97 
99  float GetBottom() const { return orthoParams.down; }
100 
102  float GetTop() const { return orthoParams.top; }
103 
106  void SetView( const Matrix44& view ) { viewMatrix = view; }
107 
108  private:
109  friend class GameObject;
110  friend class Scene;
111 
113  static int Type() { return 0; }
114 
116  static unsigned New();
117 
119  static CameraComponent* Get( unsigned index );
120 
121  Matrix44 projectionMatrix;
122  Matrix44 viewMatrix;
123  Vec3 clearColor;
124  RenderTexture* targetTexture = nullptr;
125 
126  struct OrthoParams
127  {
128  float left = 0;
129  float right = 100;
130  float top = 0;
131  float down = 100;
132  } orthoParams;
133 
134  float nearp = 0;
135  float farp = 1;
136  float fovDegrees = 45;
137  float aspect = 1;
138  ProjectionType projectionType = ProjectionType::Orthographic;
139  ClearFlag clearFlag = ClearFlag::DepthAndColor;
140  };
141 }
142 #endif
ClearFlag
Clear flag.
Definition: CameraComponent.hpp:20
Definition: AudioClip.hpp:4
float GetTop() const
Definition: CameraComponent.hpp:102
float GetNear() const
Definition: CameraComponent.hpp:78
const Matrix44 & GetView() const
Definition: CameraComponent.hpp:26
void SetClearColor(const Vec3 &color)
float GetLeft() const
Definition: CameraComponent.hpp:93
3-component vector.
Definition: Vec3.hpp:12
Render texture.
Definition: RenderTexture.hpp:10
float GetBottom() const
Definition: CameraComponent.hpp:99
RenderTexture * GetTargetTexture()
Definition: CameraComponent.hpp:63
float GetRight() const
Definition: CameraComponent.hpp:96
ProjectionType
Projection type.
Definition: CameraComponent.hpp:17
const Matrix44 & GetProjection() const
Definition: CameraComponent.hpp:23
void SetClearFlag(ClearFlag clearFlag)
ClearFlag GetClearFlag() const
Definition: CameraComponent.hpp:75
std::string GetSerialized() const
void SetView(const Matrix44 &view)
Definition: CameraComponent.hpp:106
GameObject is composed of components that define its behavior.
Definition: GameObject.hpp:9
float GetFar() const
Definition: CameraComponent.hpp:81
void SetProjectionType(ProjectionType aProjectionType)
Definition: CameraComponent.hpp:32
void SetProjection(float left, float right, float bottom, float top, float near, float far)
Camera views the scene. Game Object containing a camera component must also contain a transform compo...
Definition: CameraComponent.hpp:13
void SetTargetTexture(RenderTexture *renderTexture)
ProjectionType GetProjectionType() const
Definition: CameraComponent.hpp:29
Contains game objects in a transform hierarchy.
Definition: Scene.hpp:16
float GetAspect() const
Definition: CameraComponent.hpp:84
float GetFovDegrees() const
Definition: CameraComponent.hpp:87
Vec3 GetClearColor() const
Definition: CameraComponent.hpp:60