added support for .obj objects within the floorplan
include objects within navmesh calculation include objects within 3d mesh generation minor changes/fixes
This commit is contained in:
@@ -275,15 +275,15 @@ namespace Floorplan {
|
||||
bool operator == (const POI& o) const {return (o.type == type) && (o.name == name) && (o.pos == pos);}
|
||||
};
|
||||
|
||||
/** a GroundTruthPoint located somewhere on a floor */
|
||||
struct GroundTruthPoint {
|
||||
int id; //TODO: this value can be changed and isn't set incremental within the indoormap
|
||||
/** a GroundTruthPoint located somewhere on a floor */
|
||||
struct GroundTruthPoint {
|
||||
int id; //TODO: this value can be changed and isn't set incremental within the indoormap
|
||||
Point3 pos; // TODO: splint into 2D position + float for "heightAboveGround" [waypoints' height is relative to the floor's height!
|
||||
GroundTruthPoint() : id(), pos() {;}
|
||||
GroundTruthPoint() : id(), pos() {;}
|
||||
GroundTruthPoint(const int id, const Point3& pos) : id(id), pos(pos) {;}
|
||||
const Point3 getPosition(const Floor& f) const {return pos + Point3(0,0,f.atHeight);}
|
||||
bool operator == (const GroundTruthPoint& o) const {return (o.id == id) && (o.pos == pos);}
|
||||
};
|
||||
bool operator == (const GroundTruthPoint& o) const {return (o.id == id) && (o.pos == pos);}
|
||||
};
|
||||
|
||||
/** an AccessPoint located somewhere on a floor */
|
||||
struct AccessPoint : public HasMeta {
|
||||
@@ -317,7 +317,7 @@ namespace Floorplan {
|
||||
Beacon() : name(), mac(), pos() {;}
|
||||
Beacon(const std::string& name, const std::string& mac, const Point3& pos) : name(name), mac(mac), pos(pos) {;}
|
||||
bool operator == (const Beacon& o) const {return (o.name == name) && (o.mac == mac) && (o.pos == pos);}
|
||||
Point3 getPos(const Floor* f) const {return pos + Point3(0,0,f->atHeight);} // relative to the floor's ground
|
||||
Point3 getPos(const Floor* f) const {return pos + Point3(0,0,f->atHeight);} // relative to the floor's ground
|
||||
};
|
||||
|
||||
|
||||
@@ -371,6 +371,13 @@ namespace Floorplan {
|
||||
float getSize() const {return (to-from).length();}
|
||||
};
|
||||
|
||||
/** 3D obstacle */
|
||||
struct FloorObstacleObject : public FloorObstacle {
|
||||
std::string file;
|
||||
Point3 pos;
|
||||
Point3 rot;
|
||||
FloorObstacleObject(const std::string& file, const Point3 pos, const Point3 rot) : file(file), pos(pos), rot(rot) {;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -391,6 +391,7 @@ namespace Floorplan {
|
||||
if (std::string("line") == n->Name()) {obstacles.push_back(parseFloorObstacleLine(n));}
|
||||
if (std::string("circle") == n->Name()) {obstacles.push_back(parseFloorObstacleCircle(n));}
|
||||
if (std::string("door") == n->Name()) {obstacles.push_back(parseFloorObstacleDoor(n));}
|
||||
if (std::string("object") == n->Name()) {obstacles.push_back(parseFloorObstacleObject(n));}
|
||||
}
|
||||
return obstacles;
|
||||
}
|
||||
@@ -426,6 +427,15 @@ namespace Floorplan {
|
||||
);
|
||||
}
|
||||
|
||||
/** parse one object */
|
||||
static FloorObstacleObject* parseFloorObstacleObject(const XMLElem* el) {
|
||||
return new FloorObstacleObject(
|
||||
el->Attribute("file"),
|
||||
Point3(el->FloatAttribute("x"), el->FloatAttribute("y"), el->FloatAttribute("z")),
|
||||
Point3(el->FloatAttribute("rx"), el->FloatAttribute("ry"), el->FloatAttribute("rz"))
|
||||
);
|
||||
}
|
||||
|
||||
/** parse a floor's <outline> tag */
|
||||
static FloorOutline parseFloorOutline(const XMLElem* el) {
|
||||
FloorOutline outline;
|
||||
|
||||
@@ -170,16 +170,16 @@ namespace Floorplan {
|
||||
}
|
||||
floor->InsertEndChild(pois);
|
||||
|
||||
XMLElem* gtpoints = doc.NewElement("gtpoints");
|
||||
for (const GroundTruthPoint* gtp : mf->gtpoints) {
|
||||
XMLElem* elem = doc.NewElement("gtpoint");
|
||||
elem->SetAttribute("id", gtp->id);
|
||||
elem->SetAttribute("x", gtp->pos.x);
|
||||
elem->SetAttribute("y", gtp->pos.y);
|
||||
elem->SetAttribute("z", gtp->pos.z);
|
||||
gtpoints->InsertEndChild(elem);
|
||||
}
|
||||
floor->InsertEndChild(gtpoints);
|
||||
XMLElem* gtpoints = doc.NewElement("gtpoints");
|
||||
for (const GroundTruthPoint* gtp : mf->gtpoints) {
|
||||
XMLElem* elem = doc.NewElement("gtpoint");
|
||||
elem->SetAttribute("id", gtp->id);
|
||||
elem->SetAttribute("x", gtp->pos.x);
|
||||
elem->SetAttribute("y", gtp->pos.y);
|
||||
elem->SetAttribute("z", gtp->pos.z);
|
||||
gtpoints->InsertEndChild(elem);
|
||||
}
|
||||
floor->InsertEndChild(gtpoints);
|
||||
|
||||
XMLElem* accesspoints = doc.NewElement("accesspoints");
|
||||
for (const AccessPoint* ap : mf->accesspoints) {
|
||||
@@ -315,6 +315,8 @@ namespace Floorplan {
|
||||
addFloorObstacleCircle(doc, obstacles, (FloorObstacleCircle*)fo);
|
||||
} else if (dynamic_cast<FloorObstacleDoor*>(fo)) {
|
||||
addFloorObstacleDoor(doc, obstacles, (FloorObstacleDoor*)fo);
|
||||
} else if (dynamic_cast<FloorObstacleObject*>(fo)) {
|
||||
addFloorObstacleObject(doc, obstacles, (FloorObstacleObject*)fo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,6 +361,19 @@ namespace Floorplan {
|
||||
obstacles->InsertEndChild(obstacle);
|
||||
}
|
||||
|
||||
/** write an object-obstacle */
|
||||
static void addFloorObstacleObject(XMLDoc& doc, XMLElem* obstacles, FloorObstacleObject* obj) {
|
||||
XMLElem* obstacle = doc.NewElement("object");
|
||||
obstacle->SetAttribute("file", obj->file.c_str());
|
||||
obstacle->SetAttribute("x", obj->pos.x);
|
||||
obstacle->SetAttribute("y", obj->pos.y);
|
||||
obstacle->SetAttribute("z", obj->pos.z);
|
||||
obstacle->SetAttribute("rx", obj->rot.x);
|
||||
obstacle->SetAttribute("ry", obj->rot.y);
|
||||
obstacle->SetAttribute("rz", obj->rot.z);
|
||||
obstacles->InsertEndChild(obstacle);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user