-size_t StairShape::VertexCount() const {
- return 60;
-}
-
-void StairShape::Vertices(std::vector<glm::vec3> &out, const glm::vec3 &pos) const {
- out.reserve(60);
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.max.z); // front, upper
- out.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z); // front, lower
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.min.z); // back, upper
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // back, lower
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z); // top, upper
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z); // top, lower
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // bottom
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.min.z); // left, upper
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // left, lower
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z); // right
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
- out.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.max.z);
-}
-
-void StairShape::Normals(std::vector<glm::vec3> &out) const {
- out.reserve(60);
- out.insert(out.end(), 12, glm::vec3( 0.0f, 0.0f, 1.0f)); // front, x2
- out.insert(out.end(), 12, glm::vec3( 0.0f, 0.0f, -1.0f)); // back, x2
- out.insert(out.end(), 12, glm::vec3( 0.0f, 1.0f, 0.0f)); // top, x2
- out.insert(out.end(), 6, glm::vec3( 0.0f, -1.0f, 0.0f)); // bottom
- out.insert(out.end(), 12, glm::vec3(-1.0f, 0.0f, 0.0f)); // left, x2
- out.insert(out.end(), 6, glm::vec3( 1.0f, 0.0f, 0.0f)); // right
-}
-
-
-size_t StairShape::OutlineCount() const {
- return 36;
+void StairShape::Vertices(
+ std::vector<glm::vec3> &vtx,
+ std::vector<glm::vec3> &norm,
+ std::vector<Model::Index> &index,
+ const glm::vec3 &pos,
+ Model::Index idx
+) const {
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.max.z); // front, upper
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z); // front, lower
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.max.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.min.z); // back, upper
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.min.y, pos.z + top.min.z);
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // back, lower
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.max.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z); // top, upper
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.min.z);
+ vtx.emplace_back(pos.x + top.max.x, pos.y + top.max.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z); // top, lower
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // bottom
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.min.z); // left, upper
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.min.z);
+ vtx.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + top.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // left, lower
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.min.z); // right
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.min.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + bot.min.y, pos.z + bot.max.z);
+ vtx.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.max.z);
+
+ norm.insert(norm.end(), 8, glm::vec3( 0.0f, 0.0f, 1.0f)); // front, x2
+ norm.insert(norm.end(), 8, glm::vec3( 0.0f, 0.0f, -1.0f)); // back, x2
+ norm.insert(norm.end(), 8, glm::vec3( 0.0f, 1.0f, 0.0f)); // top, x2
+ norm.insert(norm.end(), 4, glm::vec3( 0.0f, -1.0f, 0.0f)); // bottom
+ norm.insert(norm.end(), 8, glm::vec3(-1.0f, 0.0f, 0.0f)); // left, x2
+ norm.insert(norm.end(), 4, glm::vec3( 1.0f, 0.0f, 0.0f)); // right
+
+ index.emplace_back(idx + 0); // front, upper
+ index.emplace_back(idx + 1);
+ index.emplace_back(idx + 2);
+ index.emplace_back(idx + 2);
+ index.emplace_back(idx + 1);
+ index.emplace_back(idx + 3);
+ index.emplace_back(idx + 4); // front, lower
+ index.emplace_back(idx + 5);
+ index.emplace_back(idx + 6);
+ index.emplace_back(idx + 6);
+ index.emplace_back(idx + 5);
+ index.emplace_back(idx + 7);
+ index.emplace_back(idx + 8); // back, upper
+ index.emplace_back(idx + 9);
+ index.emplace_back(idx + 10);
+ index.emplace_back(idx + 10);
+ index.emplace_back(idx + 9);
+ index.emplace_back(idx + 11);
+ index.emplace_back(idx + 12); // back, lower
+ index.emplace_back(idx + 13);
+ index.emplace_back(idx + 14);
+ index.emplace_back(idx + 14);
+ index.emplace_back(idx + 13);
+ index.emplace_back(idx + 15);
+ index.emplace_back(idx + 16); // top, upper
+ index.emplace_back(idx + 17);
+ index.emplace_back(idx + 18);
+ index.emplace_back(idx + 18);
+ index.emplace_back(idx + 17);
+ index.emplace_back(idx + 19);
+ index.emplace_back(idx + 20); // top, lower
+ index.emplace_back(idx + 21);
+ index.emplace_back(idx + 22);
+ index.emplace_back(idx + 22);
+ index.emplace_back(idx + 21);
+ index.emplace_back(idx + 23);
+ index.emplace_back(idx + 24); // bottom
+ index.emplace_back(idx + 25);
+ index.emplace_back(idx + 26);
+ index.emplace_back(idx + 26);
+ index.emplace_back(idx + 25);
+ index.emplace_back(idx + 27);
+ index.emplace_back(idx + 28); // left, upper
+ index.emplace_back(idx + 29);
+ index.emplace_back(idx + 30);
+ index.emplace_back(idx + 30);
+ index.emplace_back(idx + 29);
+ index.emplace_back(idx + 31);
+ index.emplace_back(idx + 32); // left, lower
+ index.emplace_back(idx + 33);
+ index.emplace_back(idx + 34);
+ index.emplace_back(idx + 34);
+ index.emplace_back(idx + 33);
+ index.emplace_back(idx + 35);
+ index.emplace_back(idx + 36); // right
+ index.emplace_back(idx + 37);
+ index.emplace_back(idx + 38);
+ index.emplace_back(idx + 38);
+ index.emplace_back(idx + 37);
+ index.emplace_back(idx + 39);