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