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

Revision 904, 5.5 KB checked in by bittner, 18 years ago (diff)

visibility filter updates

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