1 | #include "SamplingPreprocessor.h"
|
---|
2 | #include "ExactPreprocessor.h"
|
---|
3 | #include "Parser.h"
|
---|
4 | #include "UnigraphicsParser.h"
|
---|
5 | #include "X3dParser.h"
|
---|
6 | #include "Environment.h"
|
---|
7 | #include "Camera.h"
|
---|
8 | #include "MeshKdTree.h"
|
---|
9 | #include "Exporter.h"
|
---|
10 |
|
---|
11 | #define USE_EXE_PATH false
|
---|
12 |
|
---|
13 |
|
---|
14 | int
|
---|
15 | main(int argc, const char **argv)
|
---|
16 | {
|
---|
17 | Debug.open("debug.log");
|
---|
18 | environment = new Environment;
|
---|
19 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
20 | MeshKdTree::ParseEnvironment();
|
---|
21 | BspTree::ParseEnvironment();
|
---|
22 |
|
---|
23 | Preprocessor *p =
|
---|
24 | new SamplingPreprocessor();
|
---|
25 |
|
---|
26 | char buff[128];
|
---|
27 | environment->GetStringValue("Scene.filename", buff);
|
---|
28 | string filename(buff);
|
---|
29 |
|
---|
30 | p->LoadScene(filename);
|
---|
31 |
|
---|
32 | p->BuildKdTree();
|
---|
33 | p->KdTreeStatistics(cout);
|
---|
34 |
|
---|
35 | #ifdef TEST_BSP_VIEWCELLS
|
---|
36 | environment->GetStringValue("Scene.viewcells", buff);
|
---|
37 |
|
---|
38 | string vcFilename(buff);
|
---|
39 |
|
---|
40 | // if BSP tree construction method needs predefined view cells
|
---|
41 | if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS)
|
---|
42 | {
|
---|
43 | if (vcFilename != "")
|
---|
44 | {
|
---|
45 | p->LoadViewCells(vcFilename); |
---|
46 | |
---|
47 | Exporter *exporter = Exporter::GetExporter("viewcells.x3d"); |
---|
48 | if (exporter) |
---|
49 | { exporter->ExportViewCells(&p->mViewCells); |
---|
50 | delete exporter; |
---|
51 | } |
---|
52 | } |
---|
53 | else
|
---|
54 | p->GenerateViewCells();
|
---|
55 |
|
---|
56 | Debug << "Number of view cells: " << p->mViewCells.size() << endl;
|
---|
57 | }
|
---|
58 |
|
---|
59 | p->BuildBspTree();
|
---|
60 | p->BspTreeStatistics(Debug);
|
---|
61 | p->Export(filename + "-bsptree.x3d", false, false, true);
|
---|
62 |
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | // p->mSceneGraph->Export("soda.x3d");
|
---|
66 | if (0) {
|
---|
67 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
68 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | if (1) {
|
---|
73 | p->ComputeVisibility();
|
---|
74 | p->ExportPreprocessedData("scene.vis");
|
---|
75 | }
|
---|
76 |
|
---|
77 | if (1) {
|
---|
78 | Camera camera;
|
---|
79 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
80 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
81 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
82 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
83 |
|
---|
84 |
|
---|
85 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
86 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
87 | camera.SnapImage("camera2.png", p->mKdTree);
|
---|
88 | }
|
---|
89 |
|
---|
90 | // clean up
|
---|
91 | DEL_PTR(p);
|
---|
92 | DEL_PTR(environment);
|
---|
93 |
|
---|
94 | return 0;
|
---|
95 | }
|
---|
96 |
|
---|