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/tri_deriv.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/o3d/tri_deriv.cpp') diff --git a/src/o3d/tri_deriv.cpp b/src/o3d/tri_deriv.cpp index b4184bc..a22067e 100644 --- a/src/o3d/tri_deriv.cpp +++ b/src/o3d/tri_deriv.cpp @@ -51,7 +51,7 @@ static void _perspective_crop_x(std::vector& tris, TriangleDeri { x, q2->vertex.y + fac2 * dq2.y, - fac2_b * q1->vertex.z + (1.f - fac2_b) * q2->vertex.z, + (fac2_b * q1->vertex.w * q1->vertex.z + (1.f - fac2_b) * q2->vertex.w * q2->vertex.z) / r2w, r2w }, fac2_b * q1->b0 + (1.f - fac2_b) * q2->b0, @@ -65,7 +65,7 @@ static void _perspective_crop_x(std::vector& tris, TriangleDeri { x, q3->vertex.y + fac3 * dq3.y, - fac3_b * q1->vertex.z + (1.f - fac3_b) * q3->vertex.z, + (fac3_b * q1->vertex.w * q1->vertex.z + (1.f - fac3_b) * q3->vertex.w * q3->vertex.z) / r3w, r3w }, fac3_b * q1->b0 + (1.f - fac3_b) * q3->b0, @@ -144,7 +144,7 @@ static void _perspective_crop_y(std::vector& tris, TriangleDeri { q2->vertex.x + fac2 * dq2.x, y, - fac2_b * q1->vertex.z + (1.f - fac2_b) * q2->vertex.z, + (fac2_b * q1->vertex.w * q1->vertex.z + (1.f - fac2_b) * q2->vertex.w * q2->vertex.z) / r2w, r2w }, fac2_b * q1->b0 + (1.f - fac2_b) * q2->b0, @@ -158,7 +158,7 @@ static void _perspective_crop_y(std::vector& tris, TriangleDeri { q3->vertex.x + fac3 * dq3.x, y, - fac3_b * q1->vertex.z + (1.f - fac3_b) * q3->vertex.z, + (fac3_b * q1->vertex.w * q1->vertex.z + (1.f - fac3_b) * q3->vertex.w * q3->vertex.z) / r3w, r3w }, fac3_b * q1->b0 + (1.f - fac3_b) * q3->b0, -- cgit v1.2.3