-/// attributes of a type of block
-struct BlockType {
-
- int id;
-
- bool visible;
- glm::vec3 color;
-
- constexpr explicit BlockType(
- bool v = false,
- const glm::vec3 &color = { 1, 1, 1 })
- : id(-1), visible(v), color(color) { }
-
- static const BlockType DEFAULT;
-
-
- void FillVBO(
- const glm::vec3 &pos,
- std::vector<glm::vec3> &vertices,
- std::vector<glm::vec3> &colors,
- std::vector<glm::vec3> &normals
- ) const;
-
- void FillModel(const glm::vec3 &pos, Model &m) const {
- FillVBO(pos, m.vertices, m.colors, m.normals);
- }
-
-};
-
-
-class BlockTypeRegistry {
-
-public:
- BlockTypeRegistry();
-
-public:
- int Add(const BlockType &);
-
- BlockType *operator [](int id) { return &types[id]; }
- const BlockType *Get(int id) const { return &types[id]; }
-
-private:
- std::vector<BlockType> types;
-
-};
-
-
-/// single 1x1x1 cube
-struct Block {
-
- const BlockType *type;
-
- constexpr explicit Block(const BlockType *t = &BlockType::DEFAULT)
- : type(t) { }
-
-};
-
-
-/// cube of size 16 (256 tiles, 4096 blocks)
-class Chunk {