started working on 3D building stuff
This commit is contained in:
48
wifi/estimate/ray3/FloorplanMesh.h
Normal file
48
wifi/estimate/ray3/FloorplanMesh.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef FLOORPLANMESH_H
|
||||
#define FLOORPLANMESH_H
|
||||
|
||||
#include "Obstacle3.h"
|
||||
|
||||
/**
|
||||
* meshed version of the floorplan
|
||||
*/
|
||||
struct FloorplanMesh {
|
||||
|
||||
std::vector<Obstacle3D> elements;
|
||||
|
||||
/** DEBUG: convert to .obj file code for exporting */
|
||||
std::string toOBJ() {
|
||||
|
||||
int nVerts = 1;
|
||||
int nObjs = 0;
|
||||
std::string res;
|
||||
|
||||
// write each obstacle
|
||||
for (const Obstacle3D& o : elements) {
|
||||
|
||||
// write the vertices
|
||||
for (const Triangle3& t : o.triangles) {
|
||||
res += "v " + std::to_string(t.p1.x) + " " + std::to_string(t.p1.y) + " " + std::to_string(t.p1.z) + "\n";
|
||||
res += "v " + std::to_string(t.p2.x) + " " + std::to_string(t.p2.y) + " " + std::to_string(t.p2.z) + "\n";
|
||||
res += "v " + std::to_string(t.p3.x) + " " + std::to_string(t.p3.y) + " " + std::to_string(t.p3.z) + "\n";
|
||||
}
|
||||
|
||||
// create a new group
|
||||
res += "g elem_" + std::to_string(++nObjs) + "\n";
|
||||
|
||||
// write the group's faces
|
||||
for (size_t i = 0; i < o.triangles.size(); ++i) {
|
||||
res += "f " + std::to_string(nVerts+0) + " " + std::to_string(nVerts+1) + " " + std::to_string(nVerts+2) + "\n";
|
||||
nVerts += 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// done
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // FLOORPLANMESH_H
|
||||
Reference in New Issue
Block a user