aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/camera.h
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2025-01-02 13:25:14 +0100
committervimene <vincent.menegaux@gmail.com>2025-01-02 13:25:14 +0100
commit26b4b82a7be2c029491f3009b66b3cbf8db5d93c (patch)
treeddc247a0600b5933185677212f158ebea5a87530 /src/o3d/camera.h
parent9fdb5881d46f5d80626f961f9c9f133cc25dab70 (diff)
downloadengine-26b4b82a7be2c029491f3009b66b3cbf8db5d93c.tar.gz
various improvements
- cleaned up the computation of the camera's matrix - changed VertexData to being a struct which transmit data between the "vertex shader" and the "fragment shader" - started working on keyboard and mouse controls - added fov (field of view) - changed quaternion to euler angles conversion, from zyx to zxy - fixed computations of z coordinates in triangle rendering - improved naming in the triangle rasterizer
Diffstat (limited to 'src/o3d/camera.h')
-rw-r--r--src/o3d/camera.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/o3d/camera.h b/src/o3d/camera.h
index 27c31eb..832f473 100644
--- a/src/o3d/camera.h
+++ b/src/o3d/camera.h
@@ -1,12 +1,22 @@
#ifndef O3D_CAMERA_H
#define O3D_CAMERA_H
+#include "math/mat4.h"
#include "math/tform.h"
+using
+ engine::math::Matrix4,
+ engine::math::Transform;
+
namespace engine::o3d {
struct Camera {
- engine::math::Transform transform;
+ float fov;
+ Transform transform;
+
+ constexpr Matrix4 to_mat4(float aspect_ratio, float min_z, float max_z) const & {
+ return Matrix4::projection(fov, aspect_ratio, min_z, max_z) * transform.to_inverse_mat4();
+ }
};
}