diff options
author | vimene <vincent.menegaux@gmail.com> | 2025-01-02 13:25:14 +0100 |
---|---|---|
committer | vimene <vincent.menegaux@gmail.com> | 2025-01-02 13:25:14 +0100 |
commit | 26b4b82a7be2c029491f3009b66b3cbf8db5d93c (patch) | |
tree | ddc247a0600b5933185677212f158ebea5a87530 /src/o3d/tri_deriv.cpp | |
parent | 9fdb5881d46f5d80626f961f9c9f133cc25dab70 (diff) | |
download | engine-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/tri_deriv.cpp')
-rw-r--r-- | src/o3d/tri_deriv.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
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<TriangleDerived>& 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<TriangleDerived>& 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<TriangleDerived>& 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<TriangleDerived>& 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, |