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

Revision 1020, 5.6 KB checked in by mattausch, 18 years ago (diff)

worked on view-object space partition
fixed some loading bugs
fixeds some exporting bugs using line segments
enabling other methods for view space sampling in ViewCellsManager? OBJECT_DIRECTION_BASED_DISTRIBUTION)
added class interface for a sampling strategy

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