-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::Outline(std::vector<glm::vec3> &out, const glm::vec3 &pos) const {
- out.reserve(36);
- 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.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.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 + bot.min.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.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.max.y, pos.z + bot.min.z); // middle
- 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 + top.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.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 + bot.min.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 + bot.min.z); // top
- out.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + bot.max.x, pos.y + top.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + bot.min.x, pos.y + bot.min.y, pos.z + bot.min.z); // verticals, ltr/btf
- 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 + top.min.x, pos.y + top.min.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.max.y, pos.z + bot.min.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.min.y, pos.z + bot.max.z);
- out.emplace_back(pos.x + top.min.x, pos.y + top.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);
- out.emplace_back(pos.x + bot.max.x, pos.y + top.max.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.max.x, pos.y + top.max.y, pos.z + bot.max.z);
-}
-
-bool StairShape::Intersects(const Ray &ray, const glm::mat4 &M, float &dist, glm::vec3 &norm) const {