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

Revision 2012, 7.5 KB checked in by bittner, 17 years ago (diff)

vss ray updates

RevLine 
[372]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
[492]10
[860]11namespace GtpVisibilityPreprocessor {
[1867]12  class PreprocessorThread;
13 
[409]14class RenderSimulator;
[372]15class SceneGraph;
[429]16class Exporter;
[439]17class ViewCellsManager;
[445]18class BspTree;
[1006]19class VspOspTree;
[445]20class VspBspTree;
[468]21class RenderSimulator;
[490]22struct VssRayContainer;
[1020]23class SamplingStrategy;
[496]24class GlRendererBuffer;
[1022]25class VspTree;
[1279]26class HierarchyManager;
[1264]27class BvHierarchy;
[1221]28class Intersectable;
[1287]29class VssRay;
[1520]30class RayCaster;
[1968]31class GlobalLinesRenderer;
[490]32
[1520]33
[372]34/** Namespace for the external visibility preprocessor
35
36    This namespace includes all classes which are created by the VUT (Vienna University
37    of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
38    (www.gametools.org).
39*/
40 
[1145]41/** Main class of the visibility preprocessor. Responsible for loading and
42    saving of the input and output files. Initiates construction of the kD-tree,
43    viewcell loading/generation and the visibility computation itself.
44*/
[1521]45class Preprocessor
[1145]46{
[1520]47        friend class RayCaster;
48        friend class IntelRayCaster;
49        friend class InternalRayCaster;
[1564]50
[372]51public:
52        /** Default constructor initialising e.g., KD tree and BSP tree.
53        */
54        Preprocessor();
55
[1520]56        virtual ~Preprocessor();
[372]57
[1564]58        /** Load the input scene.
59        @param filename file to load
60        @return true on success
61        */
62        virtual bool LoadScene(const string filename);
[372]63
[1564]64        /** Export all preprocessed data in a XML format understandable by the
65        PreprocessingInterface of the GtpVisibilityPreprocessor Module.
66        The file can be compressed depending on the environement settings.
67        @return true on successful export
68        */
69        virtual bool ExportPreprocessedData(const string filename);
[871]70
[1564]71        /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
72        is driven by the environment settings, which also sais which of the three types of
73        entities should be used to drive the heuristical construction (only occluders by default)
74        */
75        virtual bool BuildKdTree();
[871]76
[1564]77        /** Compute visibility method. This method has to be reimplemented by the actual
78        Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
79        GlobalSamplingpreprocessor)
80        */
81        virtual bool ComputeVisibility() = 0;
[1292]82
[1564]83        /** Post Process the computed visibility. By default applys the visibility filter
84        (if specified in the environment and export the preprocessed data */
85        virtual bool PostProcessVisibility();
[1292]86
[1564]87        /** View cells are either loaded or prepared for generation, according to the chosen environment
88        object. Important evironment options are, e.g, the view cell type.
89        Should be done after scene loading (i.e., some options are based on scene type).
90        */
91        bool PrepareViewCells();
[1020]92
[1564]93        /** Construct viewcells from the scratch
94        */
95        bool ConstructViewCells();
96
97        /** Returns the specified sample strategy, NULL if no valid strategy.
98        */
[1884]99        SamplingStrategy *GenerateSamplingStrategy(const int strategyId);
[1564]100
101        /** Export preprocessor data.
102        */
[1695]103        bool Export(const string filename, const bool scene, const bool kdtree); 
[372]104
[1564]105        virtual void KdTreeStatistics(ostream &s);
106        virtual void BspTreeStatistics(ostream &s);
[490]107
[1564]108        /** Loads samples from file.
109        @param samples returns the stored sample rays
110        @param objects needed to associate the objects ids
111        @returns true if samples were loaded successfully
112        */
113        bool LoadSamples(VssRayContainer &samples,
[1926]114                ObjectContainer &objects) const;
[508]115
[1564]116        /** Exports samples to file.
117        @returns true if samples were written successfully
118        */
119        bool ExportSamples(const VssRayContainer &samples) const;
[1197]120
[1564]121        bool LoadKdTree(const string filename);
122        bool ExportKdTree(const string filename);
[1381]123
[1926]124        virtual bool
[2001]125        ExportRays(const char *filename,
126                           const VssRayContainer &vssRays,
127                           const int number,
128                           const bool exportScene = false
129                           );
[1926]130
[2002]131  bool
132  ExportRayAnimation(const char *filename,
133                                         const vector<VssRayContainer> &vssRays
134                                         );
135
[1786]136        virtual int
[1926]137                GenerateRays(const int number,
138                SamplingStrategy &strategy,
139                SimpleRayContainer &rays);
[1786]140
[1926]141        virtual int GenerateRays(const int number,
142                const int raysType,
143                SimpleRayContainer &rays);
[1786]144
145        bool GenerateRayBundle(SimpleRayContainer &rayBundle,
146                const SimpleRay &mainRay,
147                const int number,
148                const int shuffleType) const;
149
150        virtual void CastRays(SimpleRayContainer &rays,
[1932]151                                                  VssRayContainer &vssRays,
152                                                  const bool castDoubleRays,
[1996]153                                                  const bool pruneInvalidRays = true);
[1786]154
[1958]155        /** Compute pixel error of the current PVS solution by sampling given number of viewpoints */
156        virtual void ComputeRenderError();
[1931]157
[1564]158        /** Returns a view cells manager of the given name.
159        */
160        ViewCellsManager *CreateViewCellsManager(const char *name);
[1221]161
[1564]162        GlRendererBuffer *GetRenderer();
[492]163
[1564]164        bool InitRayCast(const string externKdTree, const string internKdTree);
[409]165
[2003]166        bool LoadInternKdTree(const string internKdTree);
167
[1786]168        bool ExportObj(const string filename, const ObjectContainer &objects);
[429]169
[1786]170        Intersectable *GetParentObject(const int index) const;
[1926]171        Vector3 GetParentNormal(const int index) const;
172
173        /** Sets a Preprocessor thread.
174        */
175        void SetThread(PreprocessorThread *t);
176
177        /** Returns a Preprocessor thread.
178        */
179        PreprocessorThread *GetThread() const;
180
[1958]181       
182        Intersectable *GetObjectById(const int id);
[1926]183
[1968]184        void PrepareHwGlobalLines();
[1564]185        ////////////////////////////////////////////////
[538]186
[1564]187        /// scene graph loaded from file
188        SceneGraph *mSceneGraph;
[599]189
[1564]190        /// raw array of objects
191        ObjectContainer mObjects;
[658]192
[1564]193        /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
194        KdTree *mKdTree;
195        /// View space partition bsp tree
196        VspBspTree *mVspBspTree;
197        /// BSP tree representing the viewcells
198        BspTree *mBspTree;
[878]199
[1564]200        /// list of all loaded occluders
201        ObjectContainer mOccluders;
202        /// list of all loaded occludees
203        ObjectContainer mOccludees;
[1221]204
[1251]205
[1564]206        ViewCellsManager *mViewCellsManager;
207
208        /// greedy optimized hierarchy for both objects and view cells
209        VspOspTree *mVspOspTree;
210
211        bool mUseGlRenderer;
212        bool mUseGlDebugger;
213
214        bool mLoadViewCells;
215
216        bool mDetectEmptyViewSpace;
217
218        bool mQuitOnFinish;
219        bool mLoadMeshes;
220        bool mComputeVisibility;
221
222        bool mExportVisibility;
223        string mVisibilityFileName;
224
225        bool mApplyVisibilityFilter;
226        bool mApplyVisibilitySpatialFilter;
227
228        float mVisibilityFilterWidth;
229
230        int mPass;
[1723]231 
232        bool mStopComputation;
[1613]233 
[1695]234        bool mExportObj;
235
[1926]236        bool mExportRays;
[2008]237        bool mExportAnimation;
[1926]238        int mExportNumRays;
[1900]239
[1786]240        ofstream mStats;
[1771]241
[1926]242        GlRendererBuffer *renderer;
[1942]243 
[1966]244        int mTotalSamples;
[1968]245        int mSamplesPerPass;
246        int mSamplesPerEvaluation;
[1966]247
[492]248protected:
249
[1658]250        bool LoadBinaryObj(const string filename,
251                                           SceneGraphNode *root,
252                                           vector<FaceParentInfo> *parents);
253
254        bool ExportBinaryObj(const string filename, SceneGraphNode *root);
255
[1520]256        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
[1251]257
[1520]258        void EvalPvsStat();
[492]259
[1786]260        virtual void EvalViewCellHistogram();
[1771]261
[1520]262        /////////////////////////
263
[2012]264  GlobalLinesRenderer *mGlobalLinesRenderer;
265  RayCaster *mRayCaster;
266  /// samples used for construction of the BSP view cells tree.
[1564]267        int mBspConstructionSamples;
268        /// samples used for construction of the VSP OSP tree.
269        int mVspOspConstructionSamples;
[1786]270        /// Simulates rendering of the scene.
[1564]271        RenderSimulator *mRenderSimulator;
[1520]272
[1564]273        vector<FaceParentInfo> mFaceParents;
[492]274
[1564]275
[2012]276 
[1723]277        /// if box around view space should be used
278        bool mUseViewSpaceBox;
[1867]279
[1926]280        PreprocessorThread *mThread;
[372]281};
282
[1867]283  extern Preprocessor *preprocessor;
[372]284
[860]285}
286
[372]287#endif
Note: See TracBrowser for help on using the repository browser.