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