40class VENOM_COMMON_API CameraImpl :
public PluginObjectImpl,
public GraphicsPluginObject
44 virtual ~CameraImpl();
47 const vcm::Mat4 & GetViewMatrix();
48 vcm::Mat4 & GetViewMatrixMut();
51 void SetPerspective(
float fovY,
float aspectRatio,
float nearPlane,
float farPlane);
52 const vcm::Mat4 & GetProjectionMatrix();
54 void SetPosition(
const vcm::Vec3& position);
55 void Move(
const vcm::Vec3& delta);
56 void MoveForward(
const float delta);
57 void MoveRight(
const float delta);
58 void MoveUp(
const float delta);
59 const vcm::Vec3 & GetPosition();
61 void SetYaw(
float angle);
62 void SetPitch(
float angle);
63 void SetRoll(
float angle);
64 void SetRotation(
const vcm::Vec3& rotation);
65 inline void SetRawRotation(
const vcm::Vec3& rotation) { __transform->SetRawRotation(rotation); }
66 void RotateYaw(
float angle);
67 void RotatePitch(
float angle);
68 void RotateRoll(
float angle);
69 void Rotate(
const vcm::Vec3 & rotation);
70 const vcm::Quat & GetRotationQuat()
const;
71 const vcm::Vec3 & GetRotation()
const;
73 vcm::Vec3 GetForwardVector()
const;
74 vcm::Vec3 GetUpVector()
const;
75 vcm::Vec3 GetRightVector()
const;
77 void RotateAround(
const vcm::Vec3& target,
const vcm::Vec3& planeNormal,
float angle);
79 void SetFocusEntity(vc::Entity entity);
80 vc::Entity GetFocusEntity();
81 void RemoveFocusEntity();
84 void SetFieldOfView(
float fovY);
85 float GetFieldOfView()
const;
87 void SetAspectRatio(
float aspectRatio);
88 float GetAspectRatio()
const;
90 void SetNearPlane(
float nearPlane);
91 float GetNearPlane()
const;
93 void SetFarPlane(
float farPlane);
94 float GetFarPlane()
const;
96 void LookAt(
const vcm::Vec3& target);
105 vcm::Mat4 __viewMatrix;
106 vcm::Mat4 __projectionMatrix;
115 bool __projectionMatrixDirty;
116 bool __viewMatrixDirty;
119 void __UpdateViewMatrix();
120 void __UpdateProjectionMatrix();
131class VENOM_COMMON_API Camera :
public Component,
public PluginObjectImplWrapper
136 static void SetMainCamera(
const Camera & camera);
137 static Camera * GetMainCamera();
139 void _GUI(
const Entity entity)
override;
140 void Init(Entity entity)
override;
141 void Update(Entity entity)
override;
142 bool CanRemove(Entity entity)
override;
143 vc::String _GetComponentTitle()
override;
145 inline void SetPosition(
const vcm::Vec3& position) { _impl->As<
CameraImpl>()->SetPosition(position); }
146 inline void Move(
const vcm::Vec3& delta) { _impl->As<
CameraImpl>()->Move(delta); }
147 inline void MoveForward(
const float delta) { _impl->As<
CameraImpl>()->MoveForward(delta); }
148 inline void MoveRight(
const float delta) { _impl->As<
CameraImpl>()->MoveRight(delta); }
149 inline void MoveUp(
const float delta) { _impl->As<
CameraImpl>()->MoveUp(delta); }
150 inline const vcm::Vec3 & GetPosition()
const {
return _impl->As<
CameraImpl>()->GetPosition(); }
152 inline void SetYaw(
float angle) { _impl->As<
CameraImpl>()->SetYaw(angle); }
153 inline void SetPitch(
float angle) { _impl->As<
CameraImpl>()->SetPitch(angle); }
154 inline void SetRoll(
float angle) { _impl->As<
CameraImpl>()->SetRoll(angle); }
155 inline void SetRotation(
const vcm::Vec3& rotation) { _impl->As<
CameraImpl>()->SetRotation(rotation); }
156 inline void SetRawRotation(
const vcm::Vec3& rotation) { _impl->As<
CameraImpl>()->SetRawRotation(rotation); }
157 inline void RotateYaw(
float angle) { _impl->As<
CameraImpl>()->RotateYaw(angle); }
158 inline void RotatePitch(
float angle) { _impl->As<
CameraImpl>()->RotatePitch(angle); }
159 inline void RotateRoll(
float angle) { _impl->As<
CameraImpl>()->RotateRoll(angle); }
160 inline void Rotate(
const vcm::Vec3 & rotation) { _impl->As<
CameraImpl>()->Rotate(rotation); }
161 inline const vcm::Quat & GetRotationQuat()
const {
return _impl->As<
CameraImpl>()->GetRotationQuat(); }
162 inline const vcm::Vec3 & GetRotation()
const {
return _impl->As<
CameraImpl>()->GetRotation(); }
164 inline vcm::Vec3 GetForwardVector()
const {
return _impl->As<
CameraImpl>()->GetForwardVector(); }
165 inline vcm::Vec3 GetUpVector()
const {
return _impl->As<
CameraImpl>()->GetUpVector(); }
166 inline vcm::Vec3 GetRightVector()
const {
return _impl->As<
CameraImpl>()->GetRightVector(); }
168 inline void RotateAround(
const vcm::Vec3& target,
const vcm::Vec3& planeNormal,
float angle) { _impl->As<
CameraImpl>()->RotateAround(target, planeNormal, angle); }
170 inline const vcm::Mat4 & GetViewMatrix()
const {
return _impl->As<
CameraImpl>()->GetViewMatrix(); }
171 inline vcm::Mat4 & GetViewMatrixMut() {
return _impl->As<
CameraImpl>()->GetViewMatrixMut(); }
172 inline void SetPerspective(
float fovY,
float aspectRatio,
float nearPlane,
float farPlane) { _impl->As<
CameraImpl>()->SetPerspective(fovY, aspectRatio, nearPlane, farPlane); }
173 inline const vcm::Mat4 & GetProjectionMatrix()
const {
return _impl->As<
CameraImpl>()->GetProjectionMatrix(); }
175 inline void SetFieldOfView(
float fovY) { _impl->As<
CameraImpl>()->SetFieldOfView(fovY); }
176 inline float GetFieldOfView()
const {
return _impl->As<
CameraImpl>()->GetFieldOfView(); }
178 inline void SetAspectRatio(
float aspectRatio) { _impl->As<
CameraImpl>()->SetAspectRatio(aspectRatio); }
179 inline float GetAspectRatio()
const {
return _impl->As<
CameraImpl>()->GetAspectRatio(); }
181 inline void SetNearPlane(
float nearPlane) { _impl->As<
CameraImpl>()->SetNearPlane(nearPlane); }
182 inline float GetNearPlane()
const {
return _impl->As<
CameraImpl>()->GetNearPlane(); }
184 inline void SetFarPlane(
float farPlane) { _impl->As<
CameraImpl>()->SetFarPlane(farPlane); }
185 inline float GetFarPlane()
const {
return _impl->As<
CameraImpl>()->GetFarPlane(); }
187 inline void LookAt(
const vcm::Vec3& target) { _impl->As<
CameraImpl>()->LookAt(target); }
189 inline void SetFocusEntity(vc::Entity entity) { _impl->As<
CameraImpl>()->SetFocusEntity(entity); }
190 inline vc::Entity GetFocusEntity()
const {
return _impl->As<
CameraImpl>()->GetFocusEntity(); }
191 inline void RemoveFocusEntity() { _impl->As<
CameraImpl>()->RemoveFocusEntity(); }