63 lines
1.5 KiB
C++
63 lines
1.5 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 FLOORPLAN_3D_OBJECTS_H
|
||
#define FLOORPLAN_3D_OBJECTS_H
|
||
|
||
#include "Obstacle3.h"
|
||
#include "misc.h"
|
||
#include "objects/OBJPool.h"
|
||
|
||
namespace Floorplan3D {
|
||
|
||
class Objects {
|
||
|
||
public:
|
||
|
||
std::vector<Obstacle3D> getObjects(const Floorplan::Floor* f) {
|
||
std::vector<Obstacle3D> res;
|
||
for (const Floorplan::FloorObstacle* o: f->obstacles) {
|
||
const Floorplan::FloorObstacleObject* obj = dynamic_cast<const Floorplan::FloorObstacleObject*>(o);
|
||
if (obj) {
|
||
res.push_back(getObject(f, obj));
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
|
||
/** 3D Obstacle from .obj 3D mesh */
|
||
Obstacle3D getObject(const Floorplan::Floor* f, const Floorplan::FloorObstacleObject* foo) const {
|
||
|
||
FloorPos fpos(f);
|
||
|
||
const std::string& name = foo->file;
|
||
Obstacle3D obs = OBJPool::get().getObject(name);
|
||
|
||
// perform sanity checks
|
||
if (!obs.isValid()) {
|
||
throw std::runtime_error("invalid obstacle-data detected");
|
||
}
|
||
|
||
// apply scaling/rotation/translation
|
||
obs = obs.scaled(foo->scale);
|
||
obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
|
||
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));
|
||
obs.type = Obstacle3D::Type::OBJECT;
|
||
|
||
return obs;
|
||
|
||
}
|
||
|
||
};
|
||
|
||
}
|
||
|
||
#endif // FLOORPLAN_3D_OBJECTS_H
|