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

Revision 1145, 6.0 KB checked in by mattausch, 18 years ago (diff)

vsposp debug version

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  /** Get Sample rays of particular type, returns false if this
116          type of rays is not supported by the preprocessor
117  */
118  enum {
119        OBJECT_BASED_DISTRIBUTION,
120        DIRECTION_BASED_DISTRIBUTION,
121        DIRECTION_BOX_BASED_DISTRIBUTION,
122        SPATIAL_BOX_BASED_DISTRIBUTION,
123        RSS_BASED_DISTRIBUTION,
124        RSS_SILHOUETTE_BASED_DISTRIBUTION,
125        VSS_BASED_DISTRIBUTION,
126        OBJECT_DIRECTION_BASED_DISTRIBUTION,
127        OBJECTS_INTERIOR_DISTRIBUTION
128  };
129 
130  virtual bool
131  GenerateRays(
132                           const int number,
133                           const int raysType,
134                           SimpleRayContainer &rays
135                           );
136 
137  virtual void CastRays(SimpleRayContainer &rays,
138          VssRayContainer &vssRays) {};
139
140  /** Returns a view cells manager with respect to the given name.
141  */
142  ViewCellsManager *CreateViewCellsManager(const char *name);
143
144  /// scene graph loaded from file
145  SceneGraph *mSceneGraph;
146
147  /// raw array of objects
148  ObjectContainer mObjects;
149 
150  /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
151  KdTree *mKdTree;
152  /// View space partition bsp tree
153  VspBspTree *mVspBspTree;
154  // view space partition tree
155  VspTree *mVspTree;
156  /// object space partition tree
157  OspTree *mOspTree;
158  /// BSP tree representing the viewcells
159  BspTree *mBspTree;
160
161
162  /// list of all loaded occluders
163  ObjectContainer mOccluders;
164  /// list of all loaded occludees
165  ObjectContainer mOccludees;
166   
167 
168  ViewCellsManager *mViewCellsManager;
169
170  /// greedy optimized hierarchy for both objects and view cells
171  VspOspTree *mVspOspTree;
172
173  bool mUseGlRenderer;
174  bool mUseGlDebugger;
175
176  bool mLoadViewCells;
177 
178  bool mDetectEmptyViewSpace;
179
180  bool mQuitOnFinish;
181  bool mLoadPolygonsAsMeshes;
182  bool mComputeVisibility;
183
184  bool mExportVisibility;
185  string mVisibilityFileName;
186 
187  bool mApplyVisibilityFilter;
188  bool mApplyVisibilitySpatialFilter;
189
190  float mVisibilityFilterWidth;
191 
192  GlRendererBuffer *GetRenderer() { return renderer;}
193 
194protected:
195
196  /////////////////////////
197
198  /// samples used for construction of the BSP view cells tree.
199  int mBspConstructionSamples;
200  /// samples used for construction of the VSP OSP tree.
201  int mVspOspConstructionSamples;
202  /** Simulates rendering of the scene.
203  */
204  RenderSimulator *mRenderSimulator;
205
206  GlRendererBuffer *renderer;
207// matt: remove qt dependencies
208//signals:
209  void EvalPvsStat();
210
211};
212
213//extern Preprocessor *preprocessor;
214
215}
216
217#endif
Note: See TracBrowser for help on using the repository browser.