115 lines
2.7 KiB
C++
115 lines
2.7 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 MV3DELEMENTFLOOROBSTACLEWALL_H
|
||
#define MV3DELEMENTFLOOROBSTACLEWALL_H
|
||
|
||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||
#include <Indoor/math/Math.h>
|
||
|
||
#include "misc/Cube.h"
|
||
#include "misc/Window.h"
|
||
#include "misc/Handrail.h"
|
||
|
||
#include "MV3DElement.h"
|
||
|
||
class MV3DElementFloorObstacleWall : public MV3DElement {
|
||
|
||
Floorplan::Floor* f;
|
||
Floorplan::FloorObstacleLine* fo;
|
||
|
||
public:
|
||
|
||
/** ctor */
|
||
MV3DElementFloorObstacleWall(Floorplan::Floor* f, Floorplan::FloorObstacleLine* fo) : f(f), fo(fo) {
|
||
;
|
||
}
|
||
|
||
protected:
|
||
|
||
|
||
|
||
struct Wall {
|
||
|
||
Point2 from;
|
||
Point2 to;
|
||
float thickness_m;
|
||
Floorplan::Material mat;
|
||
float atHeight;
|
||
float height;
|
||
|
||
Wall(const Point2 from, const Point2 to, const float thickness_m, const Floorplan::Material mat, float atHeight, float height) :
|
||
from(from), to(to), thickness_m(thickness_m), mat(mat), atHeight(atHeight), height(height) {;}
|
||
|
||
void render(const RenderSettings& rs) {
|
||
|
||
const float rad = -std::atan2(to.y - from.y, to.x - from.x);
|
||
const float deg = rad * 180 / M_PI;
|
||
|
||
//const Point2 dir = (to - from).normalized();
|
||
//const Point2 dirPerp = dir.perpendicular();
|
||
//const float w = 0.1;
|
||
|
||
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 div = 2.015f; // prevent overlaps
|
||
const float sx = from.getDistance(to) / div;
|
||
const float sy = thickness_m / div;
|
||
const float sz = height / div;
|
||
const Point3 size(sx, sy, sz);
|
||
const Point3 rot(0,0,deg);
|
||
|
||
// build
|
||
Cube cube(pos, size, rot);
|
||
if (mat == Floorplan::Material::CONCRETE) {
|
||
cube.setColor(0.5, 0.5, 0.5);
|
||
} else {
|
||
cube.setColor(0.75, 0.75, 0.75);
|
||
}
|
||
cube.render(rs);
|
||
|
||
}
|
||
|
||
|
||
};
|
||
|
||
/** repaint me */
|
||
void render(const RenderSettings& rs) override {
|
||
|
||
if (fo->material == Floorplan::Material::GLASS) {
|
||
|
||
Window win(fo->from, fo->to, f->atHeight, f->height);
|
||
win.render(rs);
|
||
|
||
} else if (fo->type == Floorplan::ObstacleType::WALL) {
|
||
|
||
Wall wall(fo->from, fo->to, fo->thickness_m, fo->material, f->atHeight, f->height);
|
||
wall.render(rs);
|
||
|
||
} else if (fo->type == Floorplan::ObstacleType::HANDRAIL) {
|
||
|
||
Handrail rail(fo->from, fo->to, f->atHeight, 1.0);
|
||
rail.render(rs);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
bool isTransparent() const override {
|
||
return fo->material == Floorplan::Material::GLASS;
|
||
}
|
||
|
||
|
||
};
|
||
|
||
#endif // MV3DELEMENTFLOOROBSTACLEWALL_H
|