source: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h @ 1283

Revision 1283, 7.7 KB checked in by bittner, 18 years ago (diff)

mlrt tests

Line 
1#ifndef _Preprocessor_H__
2#define _Preprocessor_H__
3
4#include <string>
5using namespace std;
6#include "Containers.h"
7#include "Mesh.h"
8#include "KdTree.h"
9
10// matt: remove qt dependencies
11//#include <QObject>
12
13namespace GtpVisibilityPreprocessor {
14
15class RenderSimulator;
16class SceneGraph;
17class Exporter;
18class ViewCellsManager;
19class BspTree;
20class VspOspTree;
21class VspBspTree;
22class RenderSimulator;
23struct VssRayContainer;
24class SamplingStrategy;
25class GlRendererBuffer;
26class VspTree;
27class HierarchyManager;
28class BvHierarchy;
29class Intersectable;
30
31/** Namespace for the external visibility preprocessor
32
33    This namespace includes all classes which are created by the VUT (Vienna University
34    of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
35    (www.gametools.org).
36*/
37 
38/** Main class of the visibility preprocessor. Responsible for loading and
39    saving of the input and output files. Initiates construction of the kD-tree,
40    viewcell loading/generation and the visibility computation itself.
41*/
42// matt: remove qt dependencies
43class Preprocessor// : public QObject
44{
45  //Q_OBJECT
46
47public:
48        /** Default constructor initialising e.g., KD tree and BSP tree.
49        */
50        Preprocessor();
51
52   virtual ~Preprocessor();
53
54  /** Load the input scene.
55      @param filename file to load
56          @return true on success
57  */
58  virtual bool LoadScene(const string filename);
59 
60  /** Export all preprocessed data in a XML format understandable by the
61      PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
62      on the environement settings.
63      @return true on successful export
64  */
65  virtual bool ExportPreprocessedData(const string filename);
66 
67  /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
68      is driven by the environment settings, which also sais which of the three types of
69      entities should be used to drive the heuristical construction (only occluders by default)
70  */
71  virtual bool BuildKdTree();
72
73  /** Compute visibility method. This method has to be reimplemented by the actual
74      Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
75      GlobalSamplingpreprocessor)
76    */
77  virtual bool ComputeVisibility() = 0;
78
79  /** Post Process the computed visibility. By default applys the visibility filter
80          (if specified in the environment and export the preprocessed data */
81  virtual bool PostProcessVisibility();
82
83  /** View cells are either loaded or prepared for generation, according to the chosen environment
84      object. Important evironment options are, e.g, the view cell type.
85      Should be done after scene loading (i.e., some options are based on scene type).
86  */
87  bool PrepareViewCells();
88 
89  /** Returns the specified sample strategy, NULL if no valid strategy.
90  */
91  SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
92
93  bool
94  Export( const string filename,
95          const bool scene,
96          const bool kdtree,
97          const bool bsptree
98          );
99 
100 
101  virtual void KdTreeStatistics(ostream &s);
102  virtual void BspTreeStatistics(ostream &s);
103
104  /** Loads samples from file.
105          @param samples returns the stored sample rays
106          @param objects needed to associate the objects ids
107          @returns true if samples were loaded successfully
108  */
109  bool LoadSamples(VssRayContainer &samples,
110                                   ObjectContainer &objects) const;
111
112  /** Exports samples to file.
113          @returns true if samples were written successfully
114  */
115  bool ExportSamples(const VssRayContainer &samples) const;
116
117  bool LoadKdTree();
118  bool ExportKdTree();
119
120  /** Get Sample rays of particular type, returns false if this
121          type of rays is not supported by the preprocessor
122  */
123  enum {
124        OBJECT_BASED_DISTRIBUTION,
125        DIRECTION_BASED_DISTRIBUTION,
126        DIRECTION_BOX_BASED_DISTRIBUTION,
127        SPATIAL_BOX_BASED_DISTRIBUTION,
128        RSS_BASED_DISTRIBUTION,
129        RSS_SILHOUETTE_BASED_DISTRIBUTION,
130        VSS_BASED_DISTRIBUTION,
131        OBJECT_DIRECTION_BASED_DISTRIBUTION,
132        OBJECTS_INTERIOR_DISTRIBUTION
133  };
134 
135  enum {
136          INTERNAL_RAYCASTER = 0,
137          INTEL_RAYCASTER
138  };
139
140  virtual bool
141  GenerateRays(
142                           const int number,
143                           const int raysType,
144                           SimpleRayContainer &rays
145                           );
146 
147  virtual void CastRays(SimpleRayContainer &rays,
148                                                VssRayContainer &vssRays);
149
150  /** Returns a view cells manager with respect to the given name.
151  */
152  ViewCellsManager *CreateViewCellsManager(const char *name);
153   
154  GlRendererBuffer *GetRenderer() { return renderer;}
155
156  bool InitRayCast(const string externKdTree);
157
158  int CastRay(
159          const Vector3 &viewPoint,
160          const Vector3 &direction,
161          const float probability,
162          VssRayContainer &vssRays,
163          const AxisAlignedBox3 &box
164          );
165
166  ////////////////////////////////////////////////
167
168  /// scene graph loaded from file
169  SceneGraph *mSceneGraph;
170
171  /// raw array of objects
172  ObjectContainer mObjects;
173 
174  /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
175  KdTree *mKdTree;
176  /// View space partition bsp tree
177  VspBspTree *mVspBspTree;
178  // view space partition tree
179  VspTree *mVspTree;
180  HierarchyManager *mHierarchyManager;
181  /// BSP tree representing the viewcells
182  BspTree *mBspTree;
183 
184  /// list of all loaded occluders
185  ObjectContainer mOccluders;
186  /// list of all loaded occludees
187  ObjectContainer mOccludees;
188   
189 
190  ViewCellsManager *mViewCellsManager;
191
192  /// greedy optimized hierarchy for both objects and view cells
193  VspOspTree *mVspOspTree;
194
195  bool mUseGlRenderer;
196  bool mUseGlDebugger;
197
198  bool mLoadViewCells;
199 
200  bool mDetectEmptyViewSpace;
201
202  bool mQuitOnFinish;
203  bool mLoadPolygonsAsMeshes;
204  bool mComputeVisibility;
205
206  bool mExportVisibility;
207  string mVisibilityFileName;
208 
209  bool mApplyVisibilityFilter;
210  bool mApplyVisibilitySpatialFilter;
211
212  float mVisibilityFilterWidth;
213 
214  int GetRayCastMethod() { return mRayCastMethod; }
215  void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }
216
217  int mPass;
218
219protected:
220
221        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction);
222
223  int
224  ProcessRay(
225                         const Vector3 &viewPoint,
226                         const Vector3 &direction,
227                         Intersectable *objectA,
228                         Vector3 &pointA,
229                         const Vector3 &normalA,
230                         Intersectable *objectB,
231                         Vector3 &pointB,
232                         const Vector3 &normalB,
233                         const float probability,
234                         VssRayContainer &vssRays,
235                         const AxisAlignedBox3 &box);
236 
237  int CastInternalRay(
238                                          const Vector3 &viewPoint,
239                                          const Vector3 &direction,
240                                          const float probability,
241                                          VssRayContainer &vssRays,
242                                          const AxisAlignedBox3 &box);
243 
244  int CastIntelDoubleRay(
245                                                 const Vector3 &viewPoint,
246                                                 const Vector3 &direction,
247                                                 const float probability,
248                                                 VssRayContainer &vssRays,
249                                                 const AxisAlignedBox3 &box);
250 
251  Intersectable *CastIntelSingleRay(
252                                                                        const Vector3 &viewPoint,
253                                                                        const Vector3 &direction,
254                                                                        Vector3 &tPoint,
255                                                                        const AxisAlignedBox3 &box);
256 
257  /////////////////////////
258
259        int mRayCastMethod;
260  /// samples used for construction of the BSP view cells tree.
261  int mBspConstructionSamples;
262  /// samples used for construction of the VSP OSP tree.
263  int mVspOspConstructionSamples;
264  /** Simulates rendering of the scene.
265  */
266  RenderSimulator *mRenderSimulator;
267
268 
269  vector<FaceParentInfo> mFaceParents;
270 
271  GlRendererBuffer *renderer;
272// matt: remove qt dependencies
273//signals:
274  void EvalPvsStat();
275
276  protected:
277
278 
279  void CastRays16(const int i,
280                                  SimpleRayContainer &rays,
281                                  VssRayContainer &vssRays,
282                                  const AxisAlignedBox3 &sbox);
283 
284};
285
286//extern Preprocessor *preprocessor;
287
288}
289
290#endif
Note: See TracBrowser for help on using the repository browser.