68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#ifndef MV3DELEMENTSTAIR_H
|
|
#define MV3DELEMENTSTAIR_H
|
|
|
|
#include <Indoor/floorplan/v2/Floorplan.h>
|
|
|
|
#include "misc/Cube.h"
|
|
#include "MV3DElement.h"
|
|
|
|
class MV3DElementStair : public MV3DElement {
|
|
|
|
Floorplan::Floor* floor;
|
|
Floorplan::Stair* stair;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
MV3DElementStair(Floorplan::Floor* floor, Floorplan::Stair* stair) : floor(floor), stair(stair) {
|
|
;
|
|
}
|
|
|
|
protected:
|
|
|
|
|
|
/** repaint me */
|
|
void paintGL() override {
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
//glColor3f(1.0, 0.55, 0.55);
|
|
glColor3f(0.3, 0.3, 0.3);
|
|
glBegin(GL_QUADS);
|
|
|
|
const std::vector<Floorplan::StairPart> parts = stair->getParts();
|
|
const std::vector<Floorplan::Quad3> quads = Floorplan::getQuads(parts, floor);
|
|
|
|
for (int i = 0; i < (int) parts.size(); ++i) {
|
|
|
|
//const Floorplan::StairPart& part = parts[i];
|
|
const Floorplan::Quad3& quad = quads[i];
|
|
|
|
//const Floorplan::Quad3 quad = part.getQuad(floor);
|
|
const Point3 p1 = quad.p2-quad.p1;
|
|
const Point3 p2 = quad.p4-quad.p1;
|
|
|
|
Point3 n = Math::normal(p1,p2);
|
|
if (n.z < 0) {n = -n;}
|
|
|
|
glNormal3f(n.x, n.z, n.z);
|
|
glVertex3f(quad.p1.x, quad.p1.z, quad.p1.y);
|
|
glVertex3f(quad.p2.x, quad.p2.z, quad.p2.y);
|
|
glVertex3f(quad.p3.x, quad.p3.z, quad.p3.y);
|
|
glVertex3f(quad.p4.x, quad.p4.z, quad.p4.y);
|
|
|
|
}
|
|
glEnd();
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
bool isTransparent() const override {
|
|
return false;
|
|
}
|
|
|
|
};
|
|
|
|
#endif // MV3DELEMENTSTAIR_H
|