From 26b4b82a7be2c029491f3009b66b3cbf8db5d93c Mon Sep 17 00:00:00 2001 From: vimene Date: Thu, 2 Jan 2025 13:25:14 +0100 Subject: 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 --- src/o3d/camera.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/o3d/camera.h') 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(); + } }; } -- cgit v1.2.3