1 #ifndef BLANK_BLOCK_HPP_
2 #define BLANK_BLOCK_HPP_
4 #include "geometry.hpp"
17 using Type = unsigned short;
18 using Pos = glm::vec3;
40 constexpr explicit Block(Type type = 0, Face face = FACE_UP, Turn turn = TURN_NONE)
41 : type(type), orient(face * TURN_COUNT + turn) { }
43 const glm::mat4 &Transform() const;
45 Face GetFace() const { return Face(orient / 4); }
46 void SetFace(Face face) { orient = face * TURN_COUNT + GetTurn(); }
47 Turn GetTurn() const { return Turn(orient % 4); }
48 void SetTurn(Turn turn) { orient = GetFace() * TURN_COUNT + turn; }
53 /// attributes of a type of block
58 glm::vec3 outline_color;
64 // FIXME: fill faces don't respect block orientation
76 const glm::vec3 &color = { 1, 1, 1 },
77 const Shape *shape = &DEFAULT_SHAPE
80 static const NullShape DEFAULT_SHAPE;
85 const glm::mat4 &transform = glm::mat4(1.0f),
86 Model::Index idx_offset = 0
88 void FillOutlineModel(
90 const glm::vec3 &pos_offset = { 0, 0, 0 },
91 OutlineModel::Index idx_offset = 0
97 class BlockTypeRegistry {
103 Block::Type Add(const BlockType &);
105 size_t Size() const { return types.size(); }
107 BlockType *operator [](Block::Type id) { return &types[id]; }
108 const BlockType *Get(Block::Type id) const { return &types[id]; }
111 std::vector<BlockType> types;