forked from crystalboxes/isogrid-houdini-sop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
48 lines (42 loc) · 1.04 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <isogrid.h>
#ifndef WRITEOBJ
#define WRITEOBJ 0
#endif
#if WRITEOBJ
#include <fstream>
#include <sstream>
#ifndef WRITEOBJ_PATH
#define WRITEOBJ_PATH "filename.obj"
#endif
#endif
int main()
{
IsoGridInstance a;
a.setInitResolution(16);
a.executeCommands({ Commands::Maze });
std::vector<IsoGridInstance::Face> faces;
std::vector<IsoGridInstance::Vertex> vertices;
a.getMesh(
[&vertices](float x, float y, float z) {
vertices.push_back({ x, y, z });
},
[&faces](int a, int b, int c, int d) {
faces.push_back({ a, b, c, d });
});
#if WRITEOBJ
std::ofstream file(WRITEOBJ_PATH);
std::stringstream objstr;
objstr << "# generated by WB_CubeGridExporter\n";
for (auto &vertex : vertices)
{
objstr << "v " << vertex.x << " " << vertex.y << " " << vertex.z << '\n';
}
for (auto &face : faces)
{
objstr << "f " << face.a << ' ' << face.b << ' ' << face.c << '\n';
objstr << "f " << face.c << ' ' << face.d << ' ' << face.a << '\n';
}
file << objstr.str();
#endif
return 0;
}