You.i Engine
YiAbstractCameraSceneNode.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_ABSTRACT_CAMERA_SCENE_NODE_H_
3 #define _YI_ABSTRACT_CAMERA_SCENE_NODE_H_
4 
6 #include "renderer/YiViewport.h"
8 #include "utility/YiRtti.h"
9 #include "utility/YiTime.h"
10 
32 {
33 public:
40  static const float DEFAULT_FRUSTUM_DISTANCE;
41 
43 
44  virtual bool Init() override;
45 
51  void SetUpVector(const glm::vec3 &camUp);
52 
58  const glm::vec3 &GetUpVector() const;
59 
68  void SetNearPlane(float nearZ);
69 
78  float GetNearPlane() const;
79 
88  void SetFarPlane(float farZ);
89 
98  float GetFarPlane() const;
99 
118  void SetTarget(CYISceneNode *pTargetNode);
119 
123  CYISceneNode *GetTarget() const;
124 
134  void RemoveTarget();
135 
144  const glm::mat4 &GetCameraMatrix() const;
145 
157  void SetViewport(const YI_FLOAT_RECT_REL &viewport);
158 
162  const YI_FLOAT_RECT_REL &GetViewport() const;
163 
168  const glm::mat4 &GetViewMatrix() const;
169 
174  const glm::mat4 &GetProjectionMatrix() const;
175 
176 protected:
178 
182  void DirtyProjectionMatrix();
183 
188  virtual glm::mat4 CalculateProjectionMatrix() const = 0;
189 
194  glm::mat4 CalculateViewMatrix() const;
195 
203  glm::mat4 CalculateViewportMatrix() const;
204 
210  const glm::mat4 &GetViewportWorldMatrix() const;
211 
212  virtual bool OnFrameTimeUpdated(std::chrono::microseconds frameTime) override;
213 
214  virtual void UpdateEnd() override;
215 
216  virtual CYIString GetDumpTreeString() const override;
217 
218 private:
219  bool IsTransformDirty(const CYISceneNode *pSceneNode) const;
220  bool IsViewMatrixDirty() const;
221  bool IsViewportMatrixDirty() const;
222 
223  CYISceneNode *m_pTargetNode;
224  glm::mat4 m_cameraMatrix;
225  glm::mat4 m_projectionMatrix;
226  glm::mat4 m_viewMatrix;
227  YI_FLOAT_RECT_REL m_Viewport;
228  glm::mat4 m_viewportTransform;
229  bool m_viewportDirty;
230  bool m_projectionMatrixDirty;
231  bool m_targetChanged;
232  glm::vec3 m_upVector;
233  float m_nearPlane;
234  float m_farPlane;
235 
237 };
238 
243 #ifdef YI_FUNCTION_SPECIALIZATION_FULLY_SUPPORTED
244 template<>
245 inline const CYIAbstractCameraSceneNode *YiDynamicCast<CYIAbstractCameraSceneNode>(const CYISceneNode *pObject)
246 {
247  return pObject ? (pObject->CanCastTo<CYIAbstractCameraSceneNode>() ? static_cast<const CYIAbstractCameraSceneNode *>(pObject) : nullptr) : nullptr;
248 }
249 #endif
250 
251 #endif // _YI_ABSTRACT_CAMERA_SCENE_NODE_H_
const glm::mat4 & GetProjectionMatrix() const
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
CYISceneNode * GetTarget() const
const glm::mat4 & GetViewMatrix() const
Provides a base for the definition of camera objects.
Definition: YiAbstractCameraSceneNode.h:31
Definition: YiTime.h:28
const glm::vec3 & GetUpVector() const
virtual bool Init() override
virtual glm::mat4 CalculateProjectionMatrix() const =0
A scene node is the base type for all nodes which are used by the scene manager; it is an integral pa...
Definition: YiSceneNode.h:99
glm::mat4 CalculateViewportMatrix() const
void SetUpVector(const glm::vec3 &camUp)
virtual void UpdateEnd() override
const YI_FLOAT_RECT_REL & GetViewport() const
virtual bool OnFrameTimeUpdated(std::chrono::microseconds frameTime) override
void SetViewport(const YI_FLOAT_RECT_REL &viewport)
const glm::mat4 & GetViewportWorldMatrix() const
glm::mat4 CalculateViewMatrix() const
const glm::mat4 & GetCameraMatrix() const
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
Definition: YiPredef.h:530
static const float DEFAULT_FRUSTUM_DISTANCE
Definition: YiAbstractCameraSceneNode.h:40
virtual ~CYIAbstractCameraSceneNode()
This file contains the classes and macros used to implement RTTI in You.i Engine. ...
void SetFarPlane(float farZ)
void SetNearPlane(float nearZ)
void SetTarget(CYISceneNode *pTargetNode)
virtual CYIString GetDumpTreeString() const override