summary refs log tree commit diff
path: root/src/World/BlockSide.hpp
blob: 57d3c68b1eb151deb1b31889f1d2fedcce05c50d (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include <cstdint>
#include <vector>
#include <array>
#include "../Math/Vector.hpp"

namespace MC::World {

class BlockSide {
public:
    enum Value : uint8_t {
        Front,
        Back,

        Top,
        Bottom,

        Left,
        Right,
    };

    BlockSide() = default;
    BlockSide(Value side) : m_side(side) {}

    operator Value() const { return m_side; }

    std::array<Vector<3>, 4> face() {
        switch (m_side) {
            case Front:
                return {{
                    {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f, 1.0f},
                }};
            case Back:
                return {{
                    {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f},
                }};
            case Top:
                return {{
                    {0.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 0.0f}, {0.0f, 1.0f, 0.0f},
                }};
            case Bottom:
                return {{
                    {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f},
                }};
            case Left:
                return {{
                    {0.0f, 0.0f, 0.0f},{0.0f, 0.0f, 1.0f},{0.0f, 1.0f, 1.0f}, {0.0f, 1.0f, 0.0f},
                }};
            case Right:
                return {{
                    {1.0f, 0.0f, 1.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f},
                }};
        }
    }

    static std::vector<BlockSide> all() {
        return {
            Front, Back, Top, Bottom, Left, Right,
        };
    }
private:
    Value m_side;
};

}