source: trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp @ 421

Revision 421, 3.0 KB checked in by mattausch, 19 years ago (diff)

fixed controls for terrain demo
fixed member names in vspkdtree

Line 
1#include "SamplingPreprocessor.h"
2#include "VssPreprocessor.h"
3#include "ExactPreprocessor.h"
4#include "Parser.h"
5#include "UnigraphicsParser.h"
6#include "X3dParser.h"
7#include "Environment.h"
8#include "Camera.h"
9#include "MeshKdTree.h"
10#include "Exporter.h"
11#include "X3dExporter.h" // delete later
12#include "ViewCell.h"
13#include "SceneGraph.h"
14
15#define USE_EXE_PATH false
16
17
18int
19main(int argc, const char **argv)
20{
21  Debug.open("debug.log");
22  environment = new Environment;
23  environment->Parse(argc, argv, USE_EXE_PATH);
24  MeshKdTree::ParseEnvironment();
25  BspTree::ParseEnvironment();
26 
27  char buff[128];
28 
29  environment->GetStringValue("Preprocessor.type", buff);
30  string preprocessorType(buff);
31       
32  Preprocessor *p;
33
34        if (preprocessorType == "vss")
35                p = new VssPreprocessor();
36        else
37                if (preprocessorType == "exact")
38                        p = new ExactPreprocessor();
39                else
40                        if (preprocessorType == "sampling")
41                                p = new SamplingPreprocessor();
42                        else {
43                                cerr<<"Unknown preprocessor type"<<endl;
44                                Debug<<"Unknown preprocessor type"<<endl;
45                                exit(1);
46                        }
47       
48
49  environment->GetStringValue("Scene.filename", buff);
50  string filename(buff);
51
52  p->LoadScene(filename);
53       
54  p->BuildKdTree();
55  p->KdTreeStatistics(cout);
56 
57  // parse view cell hierarchy options
58  p->ParseViewCellsOptions();
59
60  // construct tree immediately for "from view cells" or "from scene geometry"
61  // construction method. For "from rays" construction, wait until there is
62  // a certain number of rays collected
63  if (ViewCell::sHierarchy == ViewCell::BSP &&
64          !(BspTree::sConstructionMethod == BspTree::FROM_RAYS))
65  {
66          if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
67          {
68                  // view cells input file name
69                  environment->GetStringValue("ViewCells.filename", buff);
70                  string vcFilename(buff);
71                  p->LoadViewCells(vcFilename);
72                  Debug << (int)p->mViewCells.size() << " view cells loaded" << endl;
73          }
74       
75          p->BuildBspTree();
76       
77          p->Export("vc_bsptree.x3d", false, false, true);
78          p->BspTreeStatistics(Debug);
79  }
80
81  //  p->mSceneGraph->Export("soda.x3d");
82  if (0) {
83    p->Export(filename + "-out.x3d", true, false, false);
84    p->Export(filename + "-kdtree.x3d", false, true, false);   
85  }
86 
87   
88  if (1) {
89    p->ComputeVisibility();
90    p->ExportPreprocessedData("scene.vis");
91  }
92
93        Camera camera;
94  if (0) {
95    //camera.LookAtBox(p->mKdTree->GetBox());
96                camera.LookInBox(p->mKdTree->GetBox());
97                camera.SetPosition(camera.mPosition + Vector3(0,300,0));
98    camera.SnapImage("camera.jpg", p->mKdTree);
99        }
100        if (0) {
101    camera.LookInBox(p->mKdTree->GetBox());
102    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
103    camera.SnapImage("camera2.jpg", p->mKdTree);
104  }
105
106        if (0) {
107    camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
108                camera.SetDirection(Vector3(1, 0, 0));
109                camera.SnapImage("camera3.jpg", p->mKdTree);
110  }
111
112  // clean up
113  DEL_PTR(p);
114  DEL_PTR(environment);
115
116  return 0;
117}
118
Note: See TracBrowser for help on using the repository browser.