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

Revision 1221, 6.4 KB checked in by mattausch, 18 years ago (diff)

added intel ray tracing

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