76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#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 render(const RenderSettings& rs) 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);
|
||
|
||
// build
|
||
Cube cube(pos, size, rot);
|
||
cube.setColor(0.395, 0.263, 0.129);
|
||
cube.render(rs);
|
||
|
||
//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
|