1 | #ifndef _Preprocessor_H__
|
---|
2 | #define _Preprocessor_H__
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | using namespace std;
|
---|
6 | #include "Containers.h"
|
---|
7 | #include "Mesh.h"
|
---|
8 | #include "KdTree.h"
|
---|
9 |
|
---|
10 | #include <QObject>
|
---|
11 |
|
---|
12 | class RenderSimulator;
|
---|
13 | class SceneGraph;
|
---|
14 | class Exporter;
|
---|
15 | class ViewCellsManager;
|
---|
16 | class BspTree;
|
---|
17 | class VspKdTree;
|
---|
18 | class VspBspTree;
|
---|
19 | class RenderSimulator;
|
---|
20 | struct VssRayContainer;
|
---|
21 |
|
---|
22 |
|
---|
23 | /** Namespace for the external visibility preprocessor
|
---|
24 |
|
---|
25 | This namespace includes all classes which are created by the VUT (Vienna University
|
---|
26 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
|
---|
27 | (www.gametools.org).
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** Main class of the visibility preprocessor. Responsible for loading and
|
---|
31 | saving of the input and output files. Initiates construction of the kD-tree,
|
---|
32 | viewcell loading/generation and the visibility computation itself.
|
---|
33 | */
|
---|
34 | class Preprocessor : public QObject {
|
---|
35 | Q_OBJECT
|
---|
36 |
|
---|
37 | public:
|
---|
38 | /** Default constructor initialising e.g., KD tree and BSP tree.
|
---|
39 | */
|
---|
40 | Preprocessor();
|
---|
41 |
|
---|
42 | virtual ~Preprocessor();
|
---|
43 |
|
---|
44 | /** Load the input scene.
|
---|
45 | @param filename file to load
|
---|
46 | @return true on success
|
---|
47 | */
|
---|
48 | virtual bool LoadScene(const string filename);
|
---|
49 |
|
---|
50 | /** Export all preprocessed data in a XML format understandable by the
|
---|
51 | PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
|
---|
52 | on the environement settings.
|
---|
53 | @return true on successful export
|
---|
54 | */
|
---|
55 | virtual bool ExportPreprocessedData(const string filename);
|
---|
56 |
|
---|
57 | /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
|
---|
58 | is driven by the environment settings, which also sais which of the three types of
|
---|
59 | entities should be used to drive the heuristical construction (only occluders by default)
|
---|
60 | */
|
---|
61 | virtual bool BuildKdTree();
|
---|
62 |
|
---|
63 | /** Compute visibility method. This method has to be reimplemented by the actual
|
---|
64 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
|
---|
65 | GlobalSamplingpreprocessor)
|
---|
66 | */
|
---|
67 | virtual bool ComputeVisibility() = 0;
|
---|
68 |
|
---|
69 | /** View cells are either loaded or prepared for generation, according to the chosen environment
|
---|
70 | object. Important evironment options are, e.g, the view cell type.
|
---|
71 | Should be done after scene loading (i.e., some options are based on scene type).
|
---|
72 | */
|
---|
73 | bool PrepareViewCells();
|
---|
74 |
|
---|
75 | bool
|
---|
76 | Export( const string filename,
|
---|
77 | const bool scene,
|
---|
78 | const bool kdtree,
|
---|
79 | const bool bsptree
|
---|
80 | );
|
---|
81 |
|
---|
82 |
|
---|
83 | virtual void KdTreeStatistics(ostream &s);
|
---|
84 | virtual void BspTreeStatistics(ostream &s);
|
---|
85 |
|
---|
86 | /** Loads samples from file.
|
---|
87 | @param samples returns the stored sample rays
|
---|
88 | @param objects needed to associate the objects ids
|
---|
89 | @returns true if samples were loaded successfully
|
---|
90 | */
|
---|
91 | bool LoadSamples(VssRayContainer &samples,
|
---|
92 | ObjectContainer &objects) const;
|
---|
93 |
|
---|
94 | /** Exports samples to file.
|
---|
95 | @returns true if samples were written successfully
|
---|
96 | */
|
---|
97 | bool WriteSamples(const VssRayContainer &samples) const;
|
---|
98 | /// scene graph loaded from file
|
---|
99 | SceneGraph *mSceneGraph;
|
---|
100 |
|
---|
101 | /// raw array of objects
|
---|
102 | ObjectContainer mObjects;
|
---|
103 |
|
---|
104 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
|
---|
105 | KdTree *mKdTree;
|
---|
106 |
|
---|
107 | /// View space partition bsp tree
|
---|
108 | VspBspTree *mVspBspTree;
|
---|
109 | /// list of all loaded occluders
|
---|
110 | ObjectContainer mOccluders;
|
---|
111 | /// list of all loaded occludees
|
---|
112 | ObjectContainer mOccludees;
|
---|
113 |
|
---|
114 | /// BSP tree representing the viewcells
|
---|
115 | BspTree *mBspTree;
|
---|
116 |
|
---|
117 | ViewCellsManager *mViewCellsManager;
|
---|
118 |
|
---|
119 | /** Kd tree inducing a coarse partition of view space that are the building
|
---|
120 | blocks for view cells.
|
---|
121 | */
|
---|
122 | VspKdTree *mVspKdTree;
|
---|
123 |
|
---|
124 | bool mUseGlRenderer;
|
---|
125 |
|
---|
126 | protected:
|
---|
127 |
|
---|
128 | /////////////////////////
|
---|
129 |
|
---|
130 | /// samples used for construction of the BSP view cells tree.
|
---|
131 | int mBspConstructionSamples;
|
---|
132 | /// samples used for construction of the VSP KD tree.
|
---|
133 | int mVspKdConstructionSamples;
|
---|
134 | /** Simulates rendering of the scene.
|
---|
135 | */
|
---|
136 | RenderSimulator *mRenderSimulator;
|
---|
137 |
|
---|
138 | signals:
|
---|
139 | void EvalPvsStat();
|
---|
140 |
|
---|
141 | };
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 | extern Preprocessor *preprocessor;
|
---|
146 |
|
---|
147 | #endif
|
---|