aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/mesh.cpp
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2023-11-26 17:58:30 +0100
committervimene <vincent.menegaux@gmail.com>2023-11-26 17:58:30 +0100
commite730e8bdc69ef89dfa28d2606d260cb8b72f4740 (patch)
treec219050793df6d1d777e94ea3c887027cde7451e /src/o3d/mesh.cpp
parent5a1d67d1797a3db874e44500e13237d676843185 (diff)
downloadengine-e730e8bdc69ef89dfa28d2606d260cb8b72f4740.tar.gz
added scenes, camera and meshes
Diffstat (limited to 'src/o3d/mesh.cpp')
-rw-r--r--src/o3d/mesh.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/o3d/mesh.cpp b/src/o3d/mesh.cpp
new file mode 100644
index 0000000..7da77aa
--- /dev/null
+++ b/src/o3d/mesh.cpp
@@ -0,0 +1,33 @@
+#include "o3d/mesh.h"
+#include <vector>
+#include <array>
+#include "math/math_vector.h"
+#include "o3d/vertex.h"
+
+using namespace engine::o3d;
+
+Mesh Mesh::cube() {
+ return {
+ {
+ { engine::math::MathVector3(-1.f, -1.f, -1.f), {} },
+ { engine::math::MathVector3(+1.f, -1.f, -1.f), {} },
+ { engine::math::MathVector3(-1.f, +1.f, -1.f), {} },
+ { engine::math::MathVector3(+1.f, +1.f, -1.f), {} },
+ { engine::math::MathVector3(-1.f, -1.f, +1.f), {} },
+ { engine::math::MathVector3(+1.f, -1.f, +1.f), {} },
+ { engine::math::MathVector3(-1.f, +1.f, +1.f), {} },
+ { engine::math::MathVector3(+1.f, +1.f, +1.f), {} },
+ },
+ {
+ { 0, 2, 3 }, { 0, 3, 1 }, // face 1
+ { 0, 4, 6 }, { 0, 6, 2 }, // face 2
+ { 0, 1, 5 }, { 0, 5, 4 }, // face 3
+ { 7, 6, 4 }, { 7, 4, 5 }, // face 4
+ { 7, 3, 2 }, { 7, 2, 6 }, // face 5
+ { 7, 5, 1 }, { 7, 1, 3 }, // face 6
+ }
+ };
+}
+
+Mesh::Mesh(std::vector<Vertex3> pts, std::vector<std::array<int, 3>> faces) : pts{pts}, faces{faces} {
+}