[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 |
|
---|
[1520] | 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;
|
---|
[1279] | 26 | class HierarchyManager;
|
---|
[1264] | 27 | class BvHierarchy;
|
---|
[1221] | 28 | class Intersectable;
|
---|
[1287] | 29 | class VssRay;
|
---|
[1520] | 30 | class RayCaster;
|
---|
[490] | 31 |
|
---|
[1520] | 32 |
|
---|
[372] | 33 | /** Namespace for the external visibility preprocessor
|
---|
| 34 |
|
---|
| 35 | This namespace includes all classes which are created by the VUT (Vienna University
|
---|
| 36 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
|
---|
| 37 | (www.gametools.org).
|
---|
| 38 | */
|
---|
| 39 |
|
---|
[1145] | 40 | /** Main class of the visibility preprocessor. Responsible for loading and
|
---|
| 41 | saving of the input and output files. Initiates construction of the kD-tree,
|
---|
| 42 | viewcell loading/generation and the visibility computation itself.
|
---|
| 43 | */
|
---|
[1521] | 44 | class Preprocessor
|
---|
[1145] | 45 | {
|
---|
[1520] | 46 | friend class RayCaster;
|
---|
| 47 | friend class IntelRayCaster;
|
---|
| 48 | friend class InternalRayCaster;
|
---|
[1564] | 49 |
|
---|
[372] | 50 | public:
|
---|
| 51 | /** Default constructor initialising e.g., KD tree and BSP tree.
|
---|
| 52 | */
|
---|
| 53 | Preprocessor();
|
---|
| 54 |
|
---|
[1520] | 55 | virtual ~Preprocessor();
|
---|
[372] | 56 |
|
---|
[1564] | 57 | /** Load the input scene.
|
---|
| 58 | @param filename file to load
|
---|
| 59 | @return true on success
|
---|
| 60 | */
|
---|
| 61 | virtual bool LoadScene(const string filename);
|
---|
[372] | 62 |
|
---|
[1564] | 63 | /** Export all preprocessed data in a XML format understandable by the
|
---|
| 64 | PreprocessingInterface of the GtpVisibilityPreprocessor Module.
|
---|
| 65 | The file can be compressed depending on the environement settings.
|
---|
| 66 | @return true on successful export
|
---|
| 67 | */
|
---|
| 68 | virtual bool ExportPreprocessedData(const string filename);
|
---|
[871] | 69 |
|
---|
[1564] | 70 | /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
|
---|
| 71 | is driven by the environment settings, which also sais which of the three types of
|
---|
| 72 | entities should be used to drive the heuristical construction (only occluders by default)
|
---|
| 73 | */
|
---|
| 74 | virtual bool BuildKdTree();
|
---|
[871] | 75 |
|
---|
[1564] | 76 | /** Compute visibility method. This method has to be reimplemented by the actual
|
---|
| 77 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
|
---|
| 78 | GlobalSamplingpreprocessor)
|
---|
| 79 | */
|
---|
| 80 | virtual bool ComputeVisibility() = 0;
|
---|
[1292] | 81 |
|
---|
[1564] | 82 | /** Post Process the computed visibility. By default applys the visibility filter
|
---|
| 83 | (if specified in the environment and export the preprocessed data */
|
---|
| 84 | virtual bool PostProcessVisibility();
|
---|
[1292] | 85 |
|
---|
[1564] | 86 | /** View cells are either loaded or prepared for generation, according to the chosen environment
|
---|
| 87 | object. Important evironment options are, e.g, the view cell type.
|
---|
| 88 | Should be done after scene loading (i.e., some options are based on scene type).
|
---|
| 89 | */
|
---|
| 90 | bool PrepareViewCells();
|
---|
[1020] | 91 |
|
---|
[1564] | 92 | /** Construct viewcells from the scratch
|
---|
| 93 | */
|
---|
| 94 | bool ConstructViewCells();
|
---|
| 95 |
|
---|
| 96 | /** Returns the specified sample strategy, NULL if no valid strategy.
|
---|
| 97 | */
|
---|
| 98 | SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
|
---|
| 99 |
|
---|
| 100 | /** Export preprocessor data.
|
---|
| 101 | */
|
---|
[1695] | 102 | bool Export(const string filename, const bool scene, const bool kdtree);
|
---|
[372] | 103 |
|
---|
[1564] | 104 | virtual void KdTreeStatistics(ostream &s);
|
---|
| 105 | virtual void BspTreeStatistics(ostream &s);
|
---|
[490] | 106 |
|
---|
[1564] | 107 | /** Loads samples from file.
|
---|
| 108 | @param samples returns the stored sample rays
|
---|
| 109 | @param objects needed to associate the objects ids
|
---|
| 110 | @returns true if samples were loaded successfully
|
---|
| 111 | */
|
---|
| 112 | bool LoadSamples(VssRayContainer &samples,
|
---|
[1695] | 113 | ObjectContainer &objects) const;
|
---|
[508] | 114 |
|
---|
[1564] | 115 | /** Exports samples to file.
|
---|
| 116 | @returns true if samples were written successfully
|
---|
| 117 | */
|
---|
| 118 | bool ExportSamples(const VssRayContainer &samples) const;
|
---|
[1197] | 119 |
|
---|
[1564] | 120 | bool LoadKdTree(const string filename);
|
---|
| 121 | bool ExportKdTree(const string filename);
|
---|
[1381] | 122 |
|
---|
[1695] | 123 | virtual bool GenerateRays(const int number,
|
---|
| 124 | const int raysType,
|
---|
| 125 | SimpleRayContainer &rays);
|
---|
[573] | 126 |
|
---|
[1695] | 127 | bool GenerateRayBundle(SimpleRayContainer &rayBundle,
|
---|
| 128 | const SimpleRay &mainRay,
|
---|
| 129 | const int number,
|
---|
| 130 | const int shuffleType) const;
|
---|
[1221] | 131 |
|
---|
[1564] | 132 | virtual void CastRays(SimpleRayContainer &rays,
|
---|
[1695] | 133 | VssRayContainer &vssRays,
|
---|
| 134 | const bool castDoubleRays,
|
---|
| 135 | const bool pruneInvalidRays = true);
|
---|
[1221] | 136 |
|
---|
[1564] | 137 | /** Returns a view cells manager of the given name.
|
---|
| 138 | */
|
---|
| 139 | ViewCellsManager *CreateViewCellsManager(const char *name);
|
---|
| 140 | /** Returns a hierarchy manager of the given name.
|
---|
| 141 | */
|
---|
| 142 | HierarchyManager *CreateHierarchyManager(const char *name);
|
---|
[1221] | 143 |
|
---|
[1564] | 144 | GlRendererBuffer *GetRenderer();
|
---|
[492] | 145 |
|
---|
[1564] | 146 | bool InitRayCast(const string externKdTree, const string internKdTree);
|
---|
[409] | 147 |
|
---|
[1695] | 148 | bool ExportObj(const string filename, const ObjectContainer &objects);
|
---|
[429] | 149 |
|
---|
[1564] | 150 | ////////////////////////////////////////////////
|
---|
[538] | 151 |
|
---|
[1564] | 152 | /// scene graph loaded from file
|
---|
| 153 | SceneGraph *mSceneGraph;
|
---|
[599] | 154 |
|
---|
[1564] | 155 | /// raw array of objects
|
---|
| 156 | ObjectContainer mObjects;
|
---|
[658] | 157 |
|
---|
[1564] | 158 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
|
---|
| 159 | KdTree *mKdTree;
|
---|
| 160 | /// View space partition bsp tree
|
---|
| 161 | VspBspTree *mVspBspTree;
|
---|
| 162 | /// Hierarchy manager handling view space and object space partition
|
---|
| 163 | HierarchyManager *mHierarchyManager;
|
---|
| 164 | /// BSP tree representing the viewcells
|
---|
| 165 | BspTree *mBspTree;
|
---|
[878] | 166 |
|
---|
[1564] | 167 | /// list of all loaded occluders
|
---|
| 168 | ObjectContainer mOccluders;
|
---|
| 169 | /// list of all loaded occludees
|
---|
| 170 | ObjectContainer mOccludees;
|
---|
[1221] | 171 |
|
---|
[1251] | 172 |
|
---|
[1564] | 173 | ViewCellsManager *mViewCellsManager;
|
---|
| 174 |
|
---|
| 175 | /// greedy optimized hierarchy for both objects and view cells
|
---|
| 176 | VspOspTree *mVspOspTree;
|
---|
| 177 |
|
---|
| 178 | bool mUseGlRenderer;
|
---|
| 179 | bool mUseGlDebugger;
|
---|
| 180 |
|
---|
| 181 | bool mLoadViewCells;
|
---|
| 182 |
|
---|
| 183 | bool mDetectEmptyViewSpace;
|
---|
| 184 |
|
---|
| 185 | bool mQuitOnFinish;
|
---|
| 186 | bool mLoadMeshes;
|
---|
| 187 | bool mComputeVisibility;
|
---|
| 188 |
|
---|
| 189 | bool mExportVisibility;
|
---|
| 190 | string mVisibilityFileName;
|
---|
| 191 |
|
---|
| 192 | bool mApplyVisibilityFilter;
|
---|
| 193 | bool mApplyVisibilitySpatialFilter;
|
---|
| 194 |
|
---|
| 195 | float mVisibilityFilterWidth;
|
---|
| 196 |
|
---|
| 197 | int mPass;
|
---|
[1613] | 198 |
|
---|
| 199 | bool mDelayVisibilityComputation;
|
---|
| 200 | bool mStopComputation;
|
---|
| 201 |
|
---|
[1695] | 202 | bool mExportObj;
|
---|
| 203 |
|
---|
| 204 |
|
---|
[492] | 205 | protected:
|
---|
| 206 |
|
---|
[1658] | 207 | bool LoadBinaryObj(const string filename,
|
---|
| 208 | SceneGraphNode *root,
|
---|
| 209 | vector<FaceParentInfo> *parents);
|
---|
| 210 |
|
---|
| 211 | bool ExportBinaryObj(const string filename, SceneGraphNode *root);
|
---|
| 212 |
|
---|
| 213 |
|
---|
[1520] | 214 | void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
|
---|
[1251] | 215 |
|
---|
[1520] | 216 | void EvalPvsStat();
|
---|
[492] | 217 |
|
---|
[1520] | 218 | /////////////////////////
|
---|
| 219 |
|
---|
[1564] | 220 | RayCaster *mRayCaster;
|
---|
| 221 | /// samples used for construction of the BSP view cells tree.
|
---|
| 222 | int mBspConstructionSamples;
|
---|
| 223 | /// samples used for construction of the VSP OSP tree.
|
---|
| 224 | int mVspOspConstructionSamples;
|
---|
| 225 | /** Simulates rendering of the scene.
|
---|
| 226 | */
|
---|
| 227 | RenderSimulator *mRenderSimulator;
|
---|
[1520] | 228 |
|
---|
[1564] | 229 | vector<FaceParentInfo> mFaceParents;
|
---|
[492] | 230 |
|
---|
[1564] | 231 | GlRendererBuffer *renderer;
|
---|
| 232 |
|
---|
| 233 |
|
---|
[372] | 234 | };
|
---|
| 235 |
|
---|
| 236 |
|
---|
[860] | 237 | }
|
---|
| 238 |
|
---|
[372] | 239 | #endif
|
---|