[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;
|
---|
[1006] | 19 | class VspOspTree;
|
---|
[445] | 20 | class VspBspTree;
|
---|
[468] | 21 | class RenderSimulator;
|
---|
[490] | 22 | struct VssRayContainer;
|
---|
[1020] | 23 | class SamplingStrategy;
|
---|
[496] | 24 | class GlRendererBuffer;
|
---|
[1022] | 25 | class VspTree;
|
---|
| 26 | class OspTree;
|
---|
[490] | 27 |
|
---|
[372] | 28 | /** Namespace for the external visibility preprocessor
|
---|
| 29 |
|
---|
| 30 | This namespace includes all classes which are created by the VUT (Vienna University
|
---|
| 31 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
|
---|
| 32 | (www.gametools.org).
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | /** Main class of the visibility preprocessor. Responsible for loading and
|
---|
| 36 | saving of the input and output files. Initiates construction of the kD-tree,
|
---|
| 37 | viewcell loading/generation and the visibility computation itself.
|
---|
| 38 | */
|
---|
[492] | 39 | class Preprocessor : public QObject {
|
---|
| 40 | Q_OBJECT
|
---|
| 41 |
|
---|
[372] | 42 | public:
|
---|
| 43 | /** Default constructor initialising e.g., KD tree and BSP tree.
|
---|
| 44 | */
|
---|
| 45 | Preprocessor();
|
---|
| 46 |
|
---|
| 47 | virtual ~Preprocessor();
|
---|
| 48 |
|
---|
| 49 | /** Load the input scene.
|
---|
| 50 | @param filename file to load
|
---|
| 51 | @return true on success
|
---|
| 52 | */
|
---|
| 53 | virtual bool LoadScene(const string filename);
|
---|
| 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 |
|
---|
| 68 | /** Compute visibility method. This method has to be reimplemented by the actual
|
---|
| 69 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
|
---|
| 70 | GlobalSamplingpreprocessor)
|
---|
| 71 | */
|
---|
| 72 | virtual bool ComputeVisibility() = 0;
|
---|
[871] | 73 |
|
---|
| 74 | /** Post Process the computed visibility. By default applys the visibility filter
|
---|
| 75 | (if specified in the environment and export the preprocessed data */
|
---|
| 76 | virtual bool PostProcessVisibility();
|
---|
| 77 |
|
---|
[439] | 78 | /** View cells are either loaded or prepared for generation, according to the chosen environment
|
---|
| 79 | object. Important evironment options are, e.g, the view cell type.
|
---|
| 80 | Should be done after scene loading (i.e., some options are based on scene type).
|
---|
| 81 | */
|
---|
| 82 | bool PrepareViewCells();
|
---|
[372] | 83 |
|
---|
[1020] | 84 | /** Returns the specified sample strategy, NULL if no valid strategy.
|
---|
| 85 | */
|
---|
| 86 | SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
|
---|
| 87 |
|
---|
[372] | 88 | bool
|
---|
| 89 | Export( const string filename,
|
---|
| 90 | const bool scene,
|
---|
| 91 | const bool kdtree,
|
---|
| 92 | const bool bsptree
|
---|
| 93 | );
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | virtual void KdTreeStatistics(ostream &s);
|
---|
| 97 | virtual void BspTreeStatistics(ostream &s);
|
---|
| 98 |
|
---|
[490] | 99 | /** Loads samples from file.
|
---|
| 100 | @param samples returns the stored sample rays
|
---|
| 101 | @param objects needed to associate the objects ids
|
---|
| 102 | @returns true if samples were loaded successfully
|
---|
| 103 | */
|
---|
| 104 | bool LoadSamples(VssRayContainer &samples,
|
---|
| 105 | ObjectContainer &objects) const;
|
---|
| 106 |
|
---|
| 107 | /** Exports samples to file.
|
---|
| 108 | @returns true if samples were written successfully
|
---|
| 109 | */
|
---|
[508] | 110 | bool ExportSamples(const VssRayContainer &samples) const;
|
---|
| 111 |
|
---|
[563] | 112 | /** Get Sample rays of particular type, returns false if this
|
---|
| 113 | type of rays is not supported by the preprocessor
|
---|
| 114 | */
|
---|
| 115 | enum {
|
---|
| 116 | OBJECT_BASED_DISTRIBUTION,
|
---|
| 117 | DIRECTION_BASED_DISTRIBUTION,
|
---|
| 118 | DIRECTION_BOX_BASED_DISTRIBUTION,
|
---|
| 119 | SPATIAL_BOX_BASED_DISTRIBUTION,
|
---|
| 120 | RSS_BASED_DISTRIBUTION,
|
---|
| 121 | RSS_SILHOUETTE_BASED_DISTRIBUTION,
|
---|
[576] | 122 | VSS_BASED_DISTRIBUTION,
|
---|
[1020] | 123 | OBJECT_DIRECTION_BASED_DISTRIBUTION,
|
---|
| 124 | OBJECTS_INTERIOR_DISTRIBUTION
|
---|
[563] | 125 | };
|
---|
| 126 |
|
---|
| 127 | virtual bool
|
---|
| 128 | GenerateRays(
|
---|
| 129 | const int number,
|
---|
| 130 | const int raysType,
|
---|
| 131 | SimpleRayContainer &rays
|
---|
| 132 | );
|
---|
| 133 |
|
---|
[573] | 134 | virtual void CastRays(SimpleRayContainer &rays,
|
---|
| 135 | VssRayContainer &vssRays) {};
|
---|
| 136 |
|
---|
[1022] | 137 | /** Returns a view cells manager with respect to the given name.
|
---|
| 138 | */
|
---|
[575] | 139 | ViewCellsManager *CreateViewCellsManager(const char *name);
|
---|
| 140 |
|
---|
[372] | 141 | /// scene graph loaded from file
|
---|
| 142 | SceneGraph *mSceneGraph;
|
---|
[492] | 143 |
|
---|
| 144 | /// raw array of objects
|
---|
| 145 | ObjectContainer mObjects;
|
---|
[372] | 146 |
|
---|
| 147 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
|
---|
| 148 | KdTree *mKdTree;
|
---|
[445] | 149 | /// View space partition bsp tree
|
---|
| 150 | VspBspTree *mVspBspTree;
|
---|
[1022] | 151 | // view space partition tree
|
---|
| 152 | VspTree *mVspTree;
|
---|
| 153 | /// object space partition tree
|
---|
| 154 | OspTree *mOspTree;
|
---|
| 155 | /// BSP tree representing the viewcells
|
---|
| 156 | BspTree *mBspTree;
|
---|
| 157 |
|
---|
| 158 |
|
---|
[372] | 159 | /// list of all loaded occluders
|
---|
| 160 | ObjectContainer mOccluders;
|
---|
| 161 | /// list of all loaded occludees
|
---|
| 162 | ObjectContainer mOccludees;
|
---|
[439] | 163 |
|
---|
[1022] | 164 |
|
---|
[439] | 165 | ViewCellsManager *mViewCellsManager;
|
---|
[409] | 166 |
|
---|
[1006] | 167 | /// greedy optimized hierarchy for both objects and view cells
|
---|
| 168 | VspOspTree *mVspOspTree;
|
---|
[429] | 169 |
|
---|
[492] | 170 | bool mUseGlRenderer;
|
---|
[538] | 171 | bool mUseGlDebugger;
|
---|
| 172 |
|
---|
[518] | 173 | bool mLoadViewCells;
|
---|
[534] | 174 |
|
---|
| 175 | bool mDetectEmptyViewSpace;
|
---|
[599] | 176 |
|
---|
| 177 | bool mQuitOnFinish;
|
---|
[658] | 178 | bool mLoadPolygonsAsMeshes;
|
---|
[685] | 179 | bool mComputeVisibility;
|
---|
[658] | 180 |
|
---|
[871] | 181 | bool mExportVisibility;
|
---|
| 182 | string mVisibilityFileName;
|
---|
| 183 |
|
---|
| 184 | bool mApplyVisibilityFilter;
|
---|
[904] | 185 | bool mApplyVisibilitySpatialFilter;
|
---|
[878] | 186 |
|
---|
| 187 | float mVisibilityFilterWidth;
|
---|
[871] | 188 |
|
---|
[746] | 189 | GlRendererBuffer *GetRenderer() { return renderer;}
|
---|
| 190 |
|
---|
[492] | 191 | protected:
|
---|
| 192 |
|
---|
| 193 | /////////////////////////
|
---|
| 194 |
|
---|
| 195 | /// samples used for construction of the BSP view cells tree.
|
---|
| 196 | int mBspConstructionSamples;
|
---|
[1006] | 197 | /// samples used for construction of the VSP OSP tree.
|
---|
| 198 | int mVspOspConstructionSamples;
|
---|
[468] | 199 | /** Simulates rendering of the scene.
|
---|
| 200 | */
|
---|
| 201 | RenderSimulator *mRenderSimulator;
|
---|
[492] | 202 |
|
---|
[496] | 203 | GlRendererBuffer *renderer;
|
---|
| 204 |
|
---|
[492] | 205 | signals:
|
---|
| 206 | void EvalPvsStat();
|
---|
| 207 |
|
---|
[372] | 208 | };
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 |
|
---|
[492] | 212 | extern Preprocessor *preprocessor;
|
---|
[372] | 213 |
|
---|
[860] | 214 | }
|
---|
| 215 |
|
---|
[372] | 216 | #endif
|
---|