world.Generate();
- outline.vertices = std::vector<glm::vec3>({
- { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f },
- { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f },
- { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
- { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 0.0f },
- { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f },
- { 1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 1.0f },
- { 1.0f, 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f },
- { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 1.0f },
- { 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f },
- { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f },
- { 0.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 1.0f },
- });
- outline.colors.resize(24, { -1, -1, -1 });
- outline.Invalidate();
-
glClearColor(0.0, 0.0, 0.0, 1.0);
}
if (world.Intersection(aim, glm::mat4(1.0f), &chunk, &blkid, &dist, &normal)) {
glm::vec3 pos = Chunk::ToCoords(blkid);
outline_visible = true;
+ chunk->BlockAt(blkid).type->FillOutlineModel(outline);
outline_transform = glm::translate(chunk->Transform(), pos);
} else {
outline_visible = false;
normals.insert(normals.end(), 6, glm::vec3( 1.0f, 0.0f, 0.0f)); // right
}
+void BlockType::FillOutlineVBO(
+ std::vector<glm::vec3> &vertices,
+ std::vector<glm::vec3> &colors
+) const {
+ vertices = std::vector<glm::vec3>({
+ { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f },
+ { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f },
+ { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
+ { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 0.0f },
+ { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f },
+ { 1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 1.0f },
+ { 1.0f, 1.0f, 0.0f }, { 1.0f, 1.0f, 1.0f },
+ { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 1.0f },
+ { 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f },
+ { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f },
+ { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f },
+ { 0.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 1.0f },
+ });
+ colors.resize(24, outline_color);
+}
+
BlockTypeRegistry::BlockTypeRegistry() {
Add(BlockType::DEFAULT);
bool visible;
glm::vec3 color;
+ glm::vec3 outline_color;
constexpr explicit BlockType(
bool v = false,
- const glm::vec3 &color = { 1, 1, 1 })
- : id(-1), visible(v), color(color) { }
+ const glm::vec3 &color = { 1, 1, 1 },
+ const glm::vec3 &outline_color = { -1, -1, -1 })
+ : id(-1), visible(v), color(color), outline_color(outline_color) { }
static const BlockType DEFAULT;
void FillModel(const glm::vec3 &pos, Model &m) const {
FillVBO(pos, m.vertices, m.colors, m.normals);
+ m.Invalidate();
+ }
+
+
+ void FillOutlineVBO(
+ std::vector<glm::vec3> &vertices,
+ std::vector<glm::vec3> &colors
+ ) const;
+
+ void FillOutlineModel(OutlineModel &m) const {
+ FillOutlineVBO(m.vertices, m.colors);
+ m.Invalidate();
}
};