#define BLANK_WORLD_HPP_
#include "model.hpp"
+#include "geometry.hpp"
#include <vector>
#include <GL/glew.h>
/// attributes of a type of block
struct BlockType {
+ int id;
+
bool visible;
+ glm::vec3 color;
- constexpr explicit BlockType(bool v = false)
- : visible(v) { }
+ constexpr explicit BlockType(
+ bool v = false,
+ const glm::vec3 &color = { 1, 1, 1 })
+ : id(-1), visible(v), color(color) { }
static const BlockType DEFAULT;
};
+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 {
Block &BlockAt(const glm::vec3 &pos) { return blocks[ToIndex(pos)]; }
const Block &BlockAt(const glm::vec3 &pos) const { return blocks[ToIndex(pos)]; }
+ bool Intersection(const Ray &, const glm::mat4 &M, int *blkid = nullptr, float *dist = nullptr) const;
+
void Draw();
private: