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/mesh.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/o3d/mesh.cpp') diff --git a/src/o3d/mesh.cpp b/src/o3d/mesh.cpp index 60c7f8b..2423e88 100644 --- a/src/o3d/mesh.cpp +++ b/src/o3d/mesh.cpp @@ -6,26 +6,25 @@ using namespace engine::o3d; -Mesh Mesh::plane() { +Mesh Mesh::plane(float width, float height) { + const float w2 = width / 2, + h2 = height / 2; return { { - {-1.f, 0.f, -1.f, 1.f}, - {+1.f, 0.f, -1.f, 1.f}, - {+1.f, 0.f, +1.f, 1.f}, - {-1.f, 0.f, +1.f, 1.f}, + {-w2 / 2, 0.f, -h2 / 2, 1.f}, + {+w2 / 2, 0.f, -h2 / 2, 1.f}, + {+w2 / 2, 0.f, +h2 / 2, 1.f}, + {-w2 / 2, 0.f, +h2 / 2, 1.f}, }, - { {0.f, 0.f, -1.f} }, { - {0.f, 0.f}, - {1.f, 0.f}, - {1.f, 1.f}, - {0.f, 1.f}, + {0.f, -1.f, 0.f}, + {0.f, +1.f, 0.f}, }, { - {{ {{0, 0, 0}}, {{1, 0, 1}}, {{2, 0, 2}} }}, - {{ {{2, 0, 2}}, {{3, 0, 3}}, {{0, 0, 0}} }}, - {{ {{0, 0, 0}}, {{3, 0, 3}}, {{2, 0, 2}} }}, - {{ {{2, 0, 2}}, {{1, 0, 1}}, {{0, 0, 0}} }}, + {{ {{0, 0}}, {{1, 0}}, {{2, 0}} }}, + {{ {{2, 0}}, {{3, 0}}, {{0, 0}} }}, + {{ {{0, 1}}, {{3, 1}}, {{2, 1}} }}, + {{ {{2, 1}}, {{1, 1}}, {{0, 1}} }}, } }; } -- cgit v1.2.3