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