68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#ifndef MV3DELEMENTFLOOROBSTACLEDOOR_H
|
|
#define MV3DELEMENTFLOOROBSTACLEDOOR_H
|
|
|
|
#include <Indoor/floorplan/v2/Floorplan.h>
|
|
#include <Indoor/math/Math.h>
|
|
|
|
#include "misc/Cube.h"
|
|
#include "MV3DElement.h"
|
|
//#include "misc/Plane.h"
|
|
|
|
|
|
|
|
class MV3DElementFloorObstacleDoor : public MV3DElement {
|
|
|
|
Floorplan::Floor* f;
|
|
Floorplan::FloorObstacleDoor* fo;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
MV3DElementFloorObstacleDoor(Floorplan::Floor* f, Floorplan::FloorObstacleDoor* fo) : f(f), fo(fo) {
|
|
;
|
|
}
|
|
|
|
/** repaint me */
|
|
void paintGL() override {
|
|
|
|
const Point2 from = fo->from;
|
|
const Point2 to = fo->to;
|
|
const float atHeight = f->atHeight;
|
|
const float height = fo->height;
|
|
const float thickness_m = 0.05; // 5cm door
|
|
|
|
const float rad = std::atan2(to.y - from.y, to.x - from.x);
|
|
const float deg = rad * 180 / M_PI;
|
|
|
|
const Point2 cen2 = (from+to)/2;
|
|
const Point3 pos(cen2.x, cen2.y, atHeight + height/2);
|
|
|
|
// div by 2.01 to prevent overlapps and z-fi
|
|
const float sx = from.getDistance(to) / 2.01f;
|
|
const float sy = thickness_m / 2.01f;
|
|
const float sz = height / 2.01f; // prevent overlaps
|
|
const Point3 size(sx, sy, sz);
|
|
const Point3 rot(0,0,deg);
|
|
|
|
// fill color
|
|
glColor3f(0.395, 0.263, 0.129);
|
|
|
|
// build
|
|
Cube cube(pos, size, rot);
|
|
cube.paintGL();
|
|
|
|
//glColor3f(0.4, 0.4, 0.4);
|
|
//Plane p(fo->from, fo->to, f->atHeight, fo->height);
|
|
//p.paintGL();
|
|
|
|
}
|
|
|
|
bool isTransparent() const override {
|
|
return false;
|
|
}
|
|
|
|
|
|
};
|
|
|
|
#endif // MV3DELEMENTFLOOROBSTACLEDOOR_H
|