aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/mesh.cpp
blob: 47a1ea29f23b7ff0391465f6adb14d55d9b6aa25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "o3d/mesh.h"
#include <vector>
#include <array>
#include "math/vector.h"
#include "o3d/vertex.h"

using namespace engine::o3d;

Mesh Mesh::cube() {
    return {
        {
            { engine::math::Vector3(-1.f, -1.f, -1.f), {} },
            { engine::math::Vector3(+1.f, -1.f, -1.f), {} },
            { engine::math::Vector3(-1.f, +1.f, -1.f), {} },
            { engine::math::Vector3(+1.f, +1.f, -1.f), {} },
            { engine::math::Vector3(-1.f, -1.f, +1.f), {} },
            { engine::math::Vector3(+1.f, -1.f, +1.f), {} },
            { engine::math::Vector3(-1.f, +1.f, +1.f), {} },
            { engine::math::Vector3(+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} {
}