VenomEngine
Cross-Platform Modern Graphics Engine
Loading...
Searching...
No Matches
Camera.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <venom/common/Error.h>
12
14
16
17namespace venom
18{
19namespace common
20{
22{
23public:
24 CameraImpl();
25 virtual ~CameraImpl();
26
27 // View matrix generation
28 const vcm::Mat4 & GetViewMatrix(); // Generate and return the view matrix
29
30 // Projection matrix generation
31 void SetPerspective(float fovY, float aspectRatio, float nearPlane, float farPlane); // Set perspective projection
32 const vcm::Mat4 & GetProjectionMatrix(); // Generate and return the projection matrix
33
34 // Camera configuration
35 void SetFieldOfView(float fovY); // Set field of view (vertical)
36 float GetFieldOfView() const; // Get field of view
37
38 void SetAspectRatio(float aspectRatio); // Set aspect ratio (width / height)
39 float GetAspectRatio() const; // Get aspect ratio
40
41 void SetNearPlane(float nearPlane); // Set near clipping plane distance
42 float GetNearPlane() const; // Get near clipping plane
43
44 void SetFarPlane(float farPlane); // Set far clipping plane distance
45 float GetFarPlane() const; // Get far clipping plane
46
47 void LookAt(const vcm::Vec3& target); // Point camera towards a specific target
48
49private:
50 vcm::Mat4 __viewMatrix;
51 vcm::Mat4 __projectionMatrix;
52
53 // Projection parameters
54 float __fov;
55 float __aspect;
56 float __near;
57 float __far;
58
59 // Internal state
60 bool __projectionMatrixDirty;
61 bool __3DrotationViewDirty;
62
63 void __UpdateViewMatrix();
64 void __UpdateProjectionMatrix();
65};
66
72{
73public:
74 Camera();
75 ~Camera();
76 static void SetMainCamera(const Camera & camera);
77 static Camera * GetMainCamera();
78
79 inline void SetPosition(const vcm::Vec3& position) { _impl->As<CameraImpl>()->SetPosition(position); }
80 inline void Move(const vcm::Vec3& delta) { _impl->As<CameraImpl>()->Move(delta); }
81 inline void MoveForward(const float delta) { _impl->As<CameraImpl>()->MoveForward(delta); }
82 inline void MoveRight(const float delta) { _impl->As<CameraImpl>()->MoveRight(delta); }
83 inline void MoveUp(const float delta) { _impl->As<CameraImpl>()->MoveUp(delta); }
84 inline const vcm::Vec3 & GetPosition() const { return _impl->As<CameraImpl>()->GetPosition(); }
85
86 inline void SetYaw(float angle) { _impl->As<CameraImpl>()->SetYaw(angle); }
87 inline void SetPitch(float angle) { _impl->As<CameraImpl>()->SetPitch(angle); }
88 inline void SetRoll(float angle) { _impl->As<CameraImpl>()->SetRoll(angle); }
89 inline void SetRotation(const vcm::Vec3& rotation) { _impl->As<CameraImpl>()->SetRotation(rotation); }
90 inline void RotateYaw(float angle) { _impl->As<CameraImpl>()->RotateYaw(angle); }
91 inline void RotatePitch(float angle) { _impl->As<CameraImpl>()->RotatePitch(angle); }
92 inline void RotateRoll(float angle) { _impl->As<CameraImpl>()->RotateRoll(angle); }
93 inline void Rotate(const vcm::Vec3 & rotation) { _impl->As<CameraImpl>()->Rotate(rotation); }
94 inline const vcm::Quat & GetRotationQuat() const { return _impl->As<CameraImpl>()->GetRotationQuat(); }
95 inline const vcm::Vec3 & GetRotation() const { return _impl->As<CameraImpl>()->GetRotation(); }
96
97 inline const vcm::Mat4 & GetViewMatrix() { return _impl->As<CameraImpl>()->GetViewMatrix(); }
98 inline void SetPerspective(float fovY, float aspectRatio, float nearPlane, float farPlane) { _impl->As<CameraImpl>()->SetPerspective(fovY, aspectRatio, nearPlane, farPlane); }
99 inline const vcm::Mat4 & GetProjectionMatrix() { return _impl->As<CameraImpl>()->GetProjectionMatrix(); }
100
101 inline void SetFieldOfView(float fovY) { _impl->As<CameraImpl>()->SetFieldOfView(fovY); }
102 inline float GetFieldOfView() const { return _impl->As<CameraImpl>()->GetFieldOfView(); }
103
104 inline void SetAspectRatio(float aspectRatio) { _impl->As<CameraImpl>()->SetAspectRatio(aspectRatio); }
105 inline float GetAspectRatio() const { return _impl->As<CameraImpl>()->GetAspectRatio(); }
106
107 inline void SetNearPlane(float nearPlane) { _impl->As<CameraImpl>()->SetNearPlane(nearPlane); }
108 inline float GetNearPlane() const { return _impl->As<CameraImpl>()->GetNearPlane(); }
109
110 inline void SetFarPlane(float farPlane) { _impl->As<CameraImpl>()->SetFarPlane(farPlane); }
111 inline float GetFarPlane() const { return _impl->As<CameraImpl>()->GetFarPlane(); }
112
113 inline void LookAt(const vcm::Vec3& target) { _impl->As<CameraImpl>()->LookAt(target); }
114 inline vcm::Vec3 GetForwardVector() const { return _impl->As<CameraImpl>()->GetForwardVector(); }
115 inline vcm::Vec3 GetUpVector() const { return _impl->As<CameraImpl>()->GetUpVector(); }
116 inline vcm::Vec3 GetRightVector() const { return _impl->As<CameraImpl>()->GetRightVector(); }
117
118 inline void RotateAround(const vcm::Vec3& target, const vcm::Vec3& planeNormal, float angle) { _impl->As<CameraImpl>()->RotateAround(target, planeNormal, angle); }
119};
120}
121}
Camera class Classic layout with position, rotation and projection matrices.
Definition Camera.h:72
Definition Camera.h:22
Base class for graphics plugin objects.
Definition GraphicsPluginObject.h:80
Interface for the PluginObject different implementations.
Definition PluginObject.h:56
Wrapper for the PluginObjectImpl, inherited by classes like Model or Mesh to make them usable as comp...
Definition PluginObject.h:76
Definition Transform3D.h:17
Contains the entirety of the code of the VenomEngine project.
Definition Config.h:13