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

Revision 1520, 6.7 KB checked in by mattausch, 18 years ago (diff)

moved raycasting out of preprocessor into specific ray casting interface

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
11
12namespace GtpVisibilityPreprocessor {
13
14class RenderSimulator;
15class SceneGraph;
16class Exporter;
17class ViewCellsManager;
18class BspTree;
19class VspOspTree;
20class VspBspTree;
21class RenderSimulator;
22struct VssRayContainer;
23class SamplingStrategy;
24class GlRendererBuffer;
25class VspTree;
26class HierarchyManager;
27class BvHierarchy;
28class Intersectable;
29class VssRay;
30class RayCaster;
31
32
33/** Namespace for the external visibility preprocessor
34
35    This namespace includes all classes which are created by the VUT (Vienna University
36    of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
37    (www.gametools.org).
38*/
39 
40/** Main class of the visibility preprocessor. Responsible for loading and
41    saving of the input and output files. Initiates construction of the kD-tree,
42    viewcell loading/generation and the visibility computation itself.
43*/
44// matt: remove qt dependencies
45class Preprocessor// : public QObject
46{
47  //Q_OBJECT
48        friend class RayCaster;
49        friend class IntelRayCaster;
50        friend class InternalRayCaster;
51       
52public:
53        /** Default constructor initialising e.g., KD tree and BSP tree.
54        */
55        Preprocessor();
56
57        virtual ~Preprocessor();
58
59  /** Load the input scene.
60      @param filename file to load
61          @return true on success
62  */
63  virtual bool LoadScene(const string filename);
64 
65  /** Export all preprocessed data in a XML format understandable by the
66      PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
67      on the environement settings.
68      @return true on successful export
69  */
70  virtual bool ExportPreprocessedData(const string filename);
71 
72  /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
73      is driven by the environment settings, which also sais which of the three types of
74      entities should be used to drive the heuristical construction (only occluders by default)
75  */
76  virtual bool BuildKdTree();
77
78  /** Compute visibility method. This method has to be reimplemented by the actual
79      Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
80      GlobalSamplingpreprocessor)
81    */
82  virtual bool ComputeVisibility() = 0;
83
84  /** Post Process the computed visibility. By default applys the visibility filter
85          (if specified in the environment and export the preprocessed data */
86  virtual bool PostProcessVisibility();
87
88  /** View cells are either loaded or prepared for generation, according to the chosen environment
89      object. Important evironment options are, e.g, the view cell type.
90      Should be done after scene loading (i.e., some options are based on scene type).
91  */
92  bool PrepareViewCells();
93
94  /** Construct viewcells from the scratch
95  */
96  bool ConstructViewCells(const AxisAlignedBox3 &viewSpaceBox);
97
98  /** Returns the specified sample strategy, NULL if no valid strategy.
99  */
100  SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
101
102  bool
103  Export( const string filename,
104          const bool scene,
105          const bool kdtree,
106          const bool bsptree
107          );
108 
109 
110  virtual void KdTreeStatistics(ostream &s);
111  virtual void BspTreeStatistics(ostream &s);
112
113  /** Loads samples from file.
114          @param samples returns the stored sample rays
115          @param objects needed to associate the objects ids
116          @returns true if samples were loaded successfully
117  */
118  bool LoadSamples(VssRayContainer &samples,
119                                   ObjectContainer &objects) const;
120
121  /** Exports samples to file.
122          @returns true if samples were written successfully
123  */
124  bool ExportSamples(const VssRayContainer &samples) const;
125
126  bool LoadKdTree(const string filename);
127  bool ExportKdTree(const string filename);
128
129  virtual bool
130  GenerateRays(
131                           const int number,
132                           const int raysType,
133                           SimpleRayContainer &rays
134                           );
135 
136  bool GenerateRayBundle(
137          SimpleRayContainer &rayBundle,
138          const SimpleRay &mainRay,
139          const int number,
140          const int shuffleType) const;
141
142  virtual void CastRays(SimpleRayContainer &rays,
143                                                VssRayContainer &vssRays,
144                                                const bool castDoubleRays);
145
146  /** Returns a view cells manager of the given name.
147  */
148  ViewCellsManager *CreateViewCellsManager(const char *name);
149  /** Returns a hierarchy manager of the given name.
150  */
151  HierarchyManager *CreateHierarchyManager(const char *name);
152   
153  GlRendererBuffer *GetRenderer() { return renderer;}
154
155  bool InitRayCast(const string externKdTree, const string internKdTree);
156
157  int CastRay(
158          const Vector3 &viewPoint,
159          const Vector3 &direction,
160          const float probability,
161          VssRayContainer &vssRays,
162          const AxisAlignedBox3 &box
163          );
164
165 
166  ////////////////////////////////////////////////
167
168  /// scene graph loaded from file
169  SceneGraph *mSceneGraph;
170
171  /// raw array of objects
172  ObjectContainer mObjects;
173 
174  /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
175  KdTree *mKdTree;
176  /// View space partition bsp tree
177  VspBspTree *mVspBspTree;
178  /// Hierarchy manager handling view space and object space partition
179  HierarchyManager *mHierarchyManager;
180  /// BSP tree representing the viewcells
181  BspTree *mBspTree;
182 
183  /// list of all loaded occluders
184  ObjectContainer mOccluders;
185  /// list of all loaded occludees
186  ObjectContainer mOccludees;
187   
188 
189  ViewCellsManager *mViewCellsManager;
190
191  /// greedy optimized hierarchy for both objects and view cells
192  VspOspTree *mVspOspTree;
193
194  bool mUseGlRenderer;
195  bool mUseGlDebugger;
196
197  bool mLoadViewCells;
198 
199  bool mDetectEmptyViewSpace;
200
201  bool mQuitOnFinish;
202  bool mLoadMeshes;
203  bool mComputeVisibility;
204
205  bool mExportVisibility;
206  string mVisibilityFileName;
207 
208  bool mApplyVisibilityFilter;
209  bool mApplyVisibilitySpatialFilter;
210
211  float mVisibilityFilterWidth;
212 
213  //int GetRayCastMethod() { return mRayCastMethod; }
214  //void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }
215
216  int mPass;
217
218protected:
219
220        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
221
222        // matt: previously was a signal
223        void EvalPvsStat();
224
225        /////////////////////////
226
227  RayCaster *mRayCaster;
228  /// samples used for construction of the BSP view cells tree.
229  int mBspConstructionSamples;
230  /// samples used for construction of the VSP OSP tree.
231  int mVspOspConstructionSamples;
232  /** Simulates rendering of the scene.
233  */
234  RenderSimulator *mRenderSimulator;
235 
236  vector<FaceParentInfo> mFaceParents;
237
238  GlRendererBuffer *renderer;
239
240 
241};
242
243
244}
245
246#endif
Note: See TracBrowser for help on using the repository browser.