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

Revision 1006, 5.4 KB checked in by mattausch, 18 years ago (diff)

started viewspace-objectspace subdivision
removed memory leaks

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 VspOspTree;
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  /// greedy optimized hierarchy for both objects and view cells
154  VspOspTree *mVspOspTree;
155
156  bool mUseGlRenderer;
157  bool mUseGlDebugger;
158
159  bool mLoadViewCells;
160 
161  bool mDetectEmptyViewSpace;
162
163  bool mQuitOnFinish;
164  bool mLoadPolygonsAsMeshes;
165  bool mComputeVisibility;
166
167  bool mExportVisibility;
168  string mVisibilityFileName;
169 
170  bool mApplyVisibilityFilter;
171  bool mApplyVisibilitySpatialFilter;
172
173  float mVisibilityFilterWidth;
174 
175  GlRendererBuffer *GetRenderer() { return renderer;}
176 
177protected:
178
179  /////////////////////////
180
181  /// samples used for construction of the BSP view cells tree.
182  int mBspConstructionSamples;
183  /// samples used for construction of the VSP OSP tree.
184  int mVspOspConstructionSamples;
185  /** Simulates rendering of the scene.
186  */
187  RenderSimulator *mRenderSimulator;
188
189  GlRendererBuffer *renderer;
190 
191  signals:
192  void EvalPvsStat();
193
194};
195
196
197
198extern Preprocessor *preprocessor;
199
200}
201
202#endif
Note: See TracBrowser for help on using the repository browser.