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

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