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

Revision 1272, 7.2 KB checked in by bittner, 18 years ago (diff)

mlrta configuration changes

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 OspTree;
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  /// object space partition tree
181  OspTree *mOspTree;
182  /// BSP tree representing the viewcells
183  BspTree *mBspTree;
184
185  BvHierarchy *mBvHierarchy;
186 
187  /// list of all loaded occluders
188  ObjectContainer mOccluders;
189  /// list of all loaded occludees
190  ObjectContainer mOccludees;
191   
192 
193  ViewCellsManager *mViewCellsManager;
194
195  /// greedy optimized hierarchy for both objects and view cells
196  VspOspTree *mVspOspTree;
197
198  bool mUseGlRenderer;
199  bool mUseGlDebugger;
200
201  bool mLoadViewCells;
202 
203  bool mDetectEmptyViewSpace;
204
205  bool mQuitOnFinish;
206  bool mLoadPolygonsAsMeshes;
207  bool mComputeVisibility;
208
209  bool mExportVisibility;
210  string mVisibilityFileName;
211 
212  bool mApplyVisibilityFilter;
213  bool mApplyVisibilitySpatialFilter;
214
215  float mVisibilityFilterWidth;
216 
217  int GetRayCastMethod() { return mRayCastMethod; }
218  void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }
219
220  int mPass;
221
222protected:
223
224        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction);
225
226        int CastInternalRay(
227                const Vector3 &viewPoint,
228                const Vector3 &direction,
229                const float probability,
230                VssRayContainer &vssRays,
231                const AxisAlignedBox3 &box);
232
233        int CastIntelDoubleRay(
234                const Vector3 &viewPoint,
235                const Vector3 &direction,
236                const float probability,
237                VssRayContainer &vssRays,
238                const AxisAlignedBox3 &box);
239
240        Intersectable *CastIntelSingleRay(
241                        const Vector3 &viewPoint,
242                        const Vector3 &direction,
243                        Vector3 &tPoint,
244                        const AxisAlignedBox3 &box);
245
246  /////////////////////////
247
248        int mRayCastMethod;
249  /// samples used for construction of the BSP view cells tree.
250  int mBspConstructionSamples;
251  /// samples used for construction of the VSP OSP tree.
252  int mVspOspConstructionSamples;
253  /** Simulates rendering of the scene.
254  */
255  RenderSimulator *mRenderSimulator;
256
257  vector<Intersectable *> mFaceParents;
258  GlRendererBuffer *renderer;
259// matt: remove qt dependencies
260//signals:
261  void EvalPvsStat();
262
263};
264
265//extern Preprocessor *preprocessor;
266
267}
268
269#endif
Note: See TracBrowser for help on using the repository browser.