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