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 | class GlRendererBuffer;
|
---|
23 |
|
---|
24 | /** Namespace for the external visibility preprocessor
|
---|
25 |
|
---|
26 | This namespace includes all classes which are created by the VUT (Vienna University
|
---|
27 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
|
---|
28 | (www.gametools.org).
|
---|
29 | */
|
---|
30 |
|
---|
31 | /** Main class of the visibility preprocessor. Responsible for loading and
|
---|
32 | saving of the input and output files. Initiates construction of the kD-tree,
|
---|
33 | viewcell loading/generation and the visibility computation itself.
|
---|
34 | */
|
---|
35 | class Preprocessor : public QObject {
|
---|
36 | Q_OBJECT
|
---|
37 |
|
---|
38 | public:
|
---|
39 | /** Default constructor initialising e.g., KD tree and BSP tree.
|
---|
40 | */
|
---|
41 | Preprocessor();
|
---|
42 |
|
---|
43 | virtual ~Preprocessor();
|
---|
44 |
|
---|
45 | /** Load the input scene.
|
---|
46 | @param filename file to load
|
---|
47 | @return true on success
|
---|
48 | */
|
---|
49 | virtual bool LoadScene(const string filename);
|
---|
50 |
|
---|
51 | /** Export all preprocessed data in a XML format understandable by the
|
---|
52 | PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
|
---|
53 | on the environement settings.
|
---|
54 | @return true on successful export
|
---|
55 | */
|
---|
56 | virtual bool ExportPreprocessedData(const string filename);
|
---|
57 |
|
---|
58 | /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
|
---|
59 | is driven by the environment settings, which also sais which of the three types of
|
---|
60 | entities should be used to drive the heuristical construction (only occluders by default)
|
---|
61 | */
|
---|
62 | virtual bool BuildKdTree();
|
---|
63 |
|
---|
64 | /** Compute visibility method. This method has to be reimplemented by the actual
|
---|
65 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
|
---|
66 | GlobalSamplingpreprocessor)
|
---|
67 | */
|
---|
68 | virtual bool ComputeVisibility() = 0;
|
---|
69 |
|
---|
70 | /** View cells are either loaded or prepared for generation, according to the chosen environment
|
---|
71 | object. Important evironment options are, e.g, the view cell type.
|
---|
72 | Should be done after scene loading (i.e., some options are based on scene type).
|
---|
73 | */
|
---|
74 | bool PrepareViewCells();
|
---|
75 |
|
---|
76 | bool
|
---|
77 | Export( const string filename,
|
---|
78 | const bool scene,
|
---|
79 | const bool kdtree,
|
---|
80 | const bool bsptree
|
---|
81 | );
|
---|
82 |
|
---|
83 |
|
---|
84 | virtual void KdTreeStatistics(ostream &s);
|
---|
85 | virtual void BspTreeStatistics(ostream &s);
|
---|
86 |
|
---|
87 | /** Loads samples from file.
|
---|
88 | @param samples returns the stored sample rays
|
---|
89 | @param objects needed to associate the objects ids
|
---|
90 | @returns true if samples were loaded successfully
|
---|
91 | */
|
---|
92 | bool LoadSamples(VssRayContainer &samples,
|
---|
93 | ObjectContainer &objects) const;
|
---|
94 |
|
---|
95 | /** Exports samples to file.
|
---|
96 | @returns true if samples were written successfully
|
---|
97 | */
|
---|
98 | bool ExportSamples(const VssRayContainer &samples) const;
|
---|
99 |
|
---|
100 | /** Get Sample rays of particular type, returns false if this
|
---|
101 | type of rays is not supported by the preprocessor
|
---|
102 | */
|
---|
103 | enum {
|
---|
104 | OBJECT_BASED_DISTRIBUTION,
|
---|
105 | DIRECTION_BASED_DISTRIBUTION,
|
---|
106 | DIRECTION_BOX_BASED_DISTRIBUTION,
|
---|
107 | SPATIAL_BOX_BASED_DISTRIBUTION,
|
---|
108 | RSS_BASED_DISTRIBUTION,
|
---|
109 | RSS_SILHOUETTE_BASED_DISTRIBUTION,
|
---|
110 | VSS_BASED_DISTRIBUTION,
|
---|
111 | OBJECT_DIRECTION_BASED_DISTRIBUTION
|
---|
112 | };
|
---|
113 |
|
---|
114 | virtual bool
|
---|
115 | GenerateRays(
|
---|
116 | const int number,
|
---|
117 | const int raysType,
|
---|
118 | SimpleRayContainer &rays
|
---|
119 | );
|
---|
120 |
|
---|
121 | virtual void CastRays(SimpleRayContainer &rays,
|
---|
122 | VssRayContainer &vssRays) {};
|
---|
123 |
|
---|
124 | ViewCellsManager *CreateViewCellsManager(const char *name);
|
---|
125 |
|
---|
126 | /// scene graph loaded from file
|
---|
127 | SceneGraph *mSceneGraph;
|
---|
128 |
|
---|
129 | /// raw array of objects
|
---|
130 | ObjectContainer mObjects;
|
---|
131 |
|
---|
132 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
|
---|
133 | KdTree *mKdTree;
|
---|
134 |
|
---|
135 | /// View space partition bsp tree
|
---|
136 | VspBspTree *mVspBspTree;
|
---|
137 | /// list of all loaded occluders
|
---|
138 | ObjectContainer mOccluders;
|
---|
139 | /// list of all loaded occludees
|
---|
140 | ObjectContainer mOccludees;
|
---|
141 |
|
---|
142 | /// BSP tree representing the viewcells
|
---|
143 | BspTree *mBspTree;
|
---|
144 |
|
---|
145 | ViewCellsManager *mViewCellsManager;
|
---|
146 |
|
---|
147 | /** Kd tree inducing a coarse partition of view space that are the building
|
---|
148 | blocks for view cells.
|
---|
149 | */
|
---|
150 | VspKdTree *mVspKdTree;
|
---|
151 |
|
---|
152 | bool mUseGlRenderer;
|
---|
153 | bool mUseGlDebugger;
|
---|
154 |
|
---|
155 | bool mLoadViewCells;
|
---|
156 |
|
---|
157 | bool mDetectEmptyViewSpace;
|
---|
158 |
|
---|
159 | bool mQuitOnFinish;
|
---|
160 | bool mLoadPolygonsAsMeshes;
|
---|
161 |
|
---|
162 | protected:
|
---|
163 |
|
---|
164 | /////////////////////////
|
---|
165 |
|
---|
166 | /// samples used for construction of the BSP view cells tree.
|
---|
167 | int mBspConstructionSamples;
|
---|
168 | /// samples used for construction of the VSP KD tree.
|
---|
169 | int mVspKdConstructionSamples;
|
---|
170 | /** Simulates rendering of the scene.
|
---|
171 | */
|
---|
172 | RenderSimulator *mRenderSimulator;
|
---|
173 |
|
---|
174 | GlRendererBuffer *renderer;
|
---|
175 |
|
---|
176 | signals:
|
---|
177 | void EvalPvsStat();
|
---|
178 |
|
---|
179 | };
|
---|
180 |
|
---|
181 |
|
---|
182 |
|
---|
183 | extern Preprocessor *preprocessor;
|
---|
184 |
|
---|
185 | #endif
|
---|