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