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