aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/mesh.cpp
blob: 2423e88d0a97dc611eb2c32b036e1c51dcc01bce (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
#include "o3d/mesh.h"
#include <vector>
#include <array>
#include <cstddef>
#include "math/vector.h"

using namespace engine::o3d;

Mesh Mesh::plane(float width, float height) {
    const float w2 = width / 2,
                h2 = height / 2;
    return {
        {
            {-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, -1.f, 0.f},
            {0.f, +1.f, 0.f},
        },
        {
            {{ {{0, 0}}, {{1, 0}}, {{2, 0}} }},
            {{ {{2, 0}}, {{3, 0}}, {{0, 0}} }},
            {{ {{0, 1}}, {{3, 1}}, {{2, 1}} }},
            {{ {{2, 1}}, {{1, 1}}, {{0, 1}} }},
        }
    };
}