aboutsummaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2023-12-03 09:27:32 +0100
committervimene <vincent.menegaux@gmail.com>2023-12-03 09:27:32 +0100
commit48ec7df0fd27fab05c9918e83a3a7da1cc32d7a0 (patch)
tree259ec6e395e44b0af117adc9605203f8affb4b0f /src/engine.cpp
parent5a8bc0a4936cdd461c43740437541f8c991ff117 (diff)
downloadengine-48ec7df0fd27fab05c9918e83a3a7da1cc32d7a0.tar.gz
renamed MathVector{2,3,4} to Vector{2,3,4} and Mat4 to Matrix4 in engine::math
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 145c1f9..aeae21c 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -25,7 +25,7 @@
#include "o3d/vertex_data.h"
#include "o3d/tri_vertex.h"
#include "o3d/camera.h"
-#include "math/math_vector.h"
+#include "math/vector.h"
#include "math/mat4.h"
#define FPS 60
@@ -60,17 +60,17 @@ static void scene_main(FB& fb, std::function<bool()> update_frame) {
{ // objects
engine::o3d::Object3D{
engine::o3d::Mesh::cube(),
- -rad * engine::math::MathVector3(.5f, .5f, .5f),
+ -rad * engine::math::Vector3(.5f, .5f, .5f),
rad, 0.f, 0.f, 0.f
},
engine::o3d::Object3D{
engine::o3d::Mesh::cube(),
- +rad * engine::math::MathVector3(.5f, .5f, .5f),
+ +rad * engine::math::Vector3(.5f, .5f, .5f),
rad, 0.f, 0.f, 0.f
},
}
};
- auto scale_mat = engine::math::Mat4::scale(rad);
+ auto scale_mat = engine::math::Matrix4::scale(rad);
while (cont) {
scene.camera.rot_x += .0050f;
scene.camera.rot_y += .0065f;
@@ -78,21 +78,21 @@ static void scene_main(FB& fb, std::function<bool()> update_frame) {
fb.clear();
auto transform_mat =
- engine::math::Mat4::translate(-scene.camera.loc)
- * engine::math::Mat4::rot_x(-scene.camera.rot_x)
- * engine::math::Mat4::rot_y(-scene.camera.rot_y)
- * engine::math::Mat4::rot_z(-scene.camera.rot_z);
- std::array<engine::math::Mat4, 2> mats{{
- transform_mat * engine::math::Mat4::translate(engine::math::MathVector3{-.5f * rad, -.5f * rad, -.5f * rad}) * scale_mat,
- transform_mat * engine::math::Mat4::translate(engine::math::MathVector3{+.5f * rad, +.5f * rad, +.5f * rad}) * scale_mat,
+ engine::math::Matrix4::translate(-scene.camera.loc)
+ * engine::math::Matrix4::rot_x(-scene.camera.rot_x)
+ * engine::math::Matrix4::rot_y(-scene.camera.rot_y)
+ * engine::math::Matrix4::rot_z(-scene.camera.rot_z);
+ std::array<engine::math::Matrix4, 2> mats{{
+ transform_mat * engine::math::Matrix4::translate(engine::math::Vector3{-.5f * rad, -.5f * rad, -.5f * rad}) * scale_mat,
+ transform_mat * engine::math::Matrix4::translate(engine::math::Vector3{+.5f * rad, +.5f * rad, +.5f * rad}) * scale_mat,
}};
- auto projection_mat = engine::math::Mat4::projection(static_cast<float>(fb.height()) / static_cast<float>(fb.width()), 2.f, 50.f);
+ auto projection_mat = engine::math::Matrix4::projection(static_cast<float>(fb.height()) / static_cast<float>(fb.width()), 2.f, 50.f);
for (int i = 0; i < 2; i++) {
auto final_mat = projection_mat * mats[i];
const auto& mesh = scene.objs[i].mesh;
std::vector<engine::o3d::Vertex4> pts;
for (const auto& vert : mesh.pts)
- pts.push_back({ final_mat * engine::math::MathVector4{vert.point}, vert.data });
+ pts.push_back({ final_mat * engine::math::Vector4{vert.point}, vert.data });
for (auto face : mesh.faces)
fb.draw_triangle({pts[face[0]], pts[face[1]], pts[face[2]]});
}