This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/floorplan/3D/Objects.h
frank 8dd1ba0be6 moved from ray3 to floorplan/3D
worked on new wall models
refactoring
2018-07-24 08:13:16 +02:00

53 lines
1.2 KiB
C++

#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