aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/mesh.cpp
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/mesh.cpp
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/mesh.cpp')
-rw-r--r--src/o3d/mesh.cpp27
1 files changed, 13 insertions, 14 deletions
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}} }},
}
};
}