[162] | 1 | #ifndef _Preprocessor_H__ |
---|
| 2 | #define _Preprocessor_H__ |
---|
| 3 | |
---|
| 4 | #include <string> |
---|
| 5 | using namespace std; |
---|
| 6 | #include "Containers.h" |
---|
| 7 | #include "Mesh.h" |
---|
| 8 | #include "KdTree.h" |
---|
| 9 | #include "ViewCellBsp.h" |
---|
| 10 | //#include "SceneGraph.h" |
---|
| 11 | |
---|
| 12 | class SceneGraph; |
---|
| 13 | |
---|
| 14 | /** Namespace for the external visibility preprocessor |
---|
| 15 | |
---|
| 16 | This namespace includes all classes which are created by the VUT (Vienna University |
---|
| 17 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project) |
---|
| 18 | (www.gametools.org). |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | /** Main class of the visibility preprocessor. Responsible for loading and |
---|
| 22 | saving of the input and output files. Initiates construction of the kD-tree, |
---|
| 23 | viewcell loading/generation and the visibility computation itself. |
---|
| 24 | */ |
---|
| 25 | class Preprocessor { |
---|
| 26 | public: |
---|
[262] | 27 | /** Default constructor initialising e.g., KD tree and BSP tree. |
---|
| 28 | */ |
---|
| 29 | Preprocessor(); |
---|
| 30 | |
---|
[261] | 31 | ~Preprocessor(); |
---|
| 32 | |
---|
[162] | 33 | /** Load the input scene. |
---|
| 34 | @param filename file to load |
---|
| 35 | @return true on success |
---|
| 36 | */ |
---|
| 37 | virtual bool LoadScene(const string filename); |
---|
| 38 | |
---|
| 39 | /** Load the input viewcells. The input viewcells should be given as a collection |
---|
| 40 | of meshes. Each mesh is assume to form a bounded polyhedron defining the interior of |
---|
| 41 | the viewcell. The method then builds a BSP tree of these view cells. |
---|
| 42 | @param filename file to load |
---|
| 43 | @return true on success |
---|
| 44 | */ |
---|
[261] | 45 | virtual bool LoadViewCells(const string filename); |
---|
[162] | 46 | |
---|
| 47 | /** Generate the viewCells automatically. The particular algorithm to be used depends |
---|
| 48 | on the environment setting. Initially the generated viewcells will cover the whole |
---|
| 49 | bounding volume of the scene. They can be pruned later depending on the results |
---|
| 50 | of visibility computations. |
---|
| 51 | @return true on successful viewcell generation. |
---|
| 52 | */ |
---|
[261] | 53 | virtual bool GenerateViewCells(); |
---|
[162] | 54 | |
---|
| 55 | /** Export all preprocessed data in a XML format understandable by the |
---|
| 56 | PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending |
---|
| 57 | on the environement settings. |
---|
| 58 | @return true on successful export |
---|
| 59 | */ |
---|
| 60 | virtual bool ExportPreprocessedData(const string filename); |
---|
| 61 | |
---|
| 62 | /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction |
---|
| 63 | is driven by the environment settings, which also sais which of the three types of |
---|
| 64 | entities should be used to drive the heuristical construction (only occluders by default) |
---|
| 65 | */ |
---|
| 66 | virtual bool BuildKdTree(); |
---|
| 67 | |
---|
[234] | 68 | /** Build the BSP tree of currently loaded occluders/occludees/viewcells. The construction |
---|
[263] | 69 | is driven by the environment settings, which also says which of the three types of |
---|
[234] | 70 | entities should be used to drive the heuristical construction (only occluders by default) |
---|
| 71 | */ |
---|
| 72 | virtual bool BuildBspTree(); |
---|
| 73 | |
---|
[162] | 74 | /** Compute visibility method. This method has to be reimplemented by the actual |
---|
| 75 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor, |
---|
| 76 | GlobalSamplingpreprocessor) |
---|
| 77 | */ |
---|
| 78 | virtual bool ComputeVisibility() = 0; |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | bool |
---|
| 82 | Export( const string filename, |
---|
| 83 | const bool scene, |
---|
[242] | 84 | const bool kdtree, |
---|
| 85 | const bool bsptree |
---|
[162] | 86 | ); |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | virtual void KdTreeStatistics(ostream &s); |
---|
[234] | 90 | virtual void BspTreeStatistics(ostream &s); |
---|
| 91 | |
---|
[308] | 92 | void DeleteViewCells(); |
---|
| 93 | |
---|
[310] | 94 | /** Parses the view cell options |
---|
| 95 | */ |
---|
| 96 | bool ParseViewCellsOptions(); |
---|
| 97 | |
---|
[162] | 98 | /// scene graph loaded from file |
---|
| 99 | SceneGraph *mSceneGraph; |
---|
[262] | 100 | |
---|
[162] | 101 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells |
---|
| 102 | KdTree *mKdTree; |
---|
| 103 | |
---|
| 104 | /// list of all loaded occluders |
---|
[176] | 105 | ObjectContainer mOccluders; |
---|
[162] | 106 | /// list of all loaded occludees |
---|
[176] | 107 | ObjectContainer mOccludees; |
---|
[162] | 108 | /// list of all loaded/generated viewcells |
---|
[261] | 109 | ViewCellContainer mViewCells; |
---|
[162] | 110 | |
---|
[262] | 111 | /// BSP tree representing the viewcells |
---|
| 112 | BspTree *mBspTree; |
---|
[297] | 113 | |
---|
| 114 | /// the root view cell of the bsp tree |
---|
| 115 | ViewCell *mRootViewCell; |
---|
[309] | 116 | |
---|
[310] | 117 | /// view cell hierarchy types |
---|
| 118 | enum {BSP_VIEW_CELLS, KD_VIEW_CELLS, SCENE_DEPENDENT}; |
---|
[309] | 119 | |
---|
[310] | 120 | /// type of the view cells |
---|
[309] | 121 | int mViewCellsType; |
---|
[162] | 122 | }; |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | #endif |
---|