[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;
|
---|
[1279] | 27 | class HierarchyManager;
|
---|
[1264] | 28 | class BvHierarchy;
|
---|
[1221] | 29 | class Intersectable;
|
---|
[1287] | 30 | class VssRay;
|
---|
[490] | 31 |
|
---|
[372] | 32 | /** Namespace for the external visibility preprocessor
|
---|
| 33 |
|
---|
| 34 | This namespace includes all classes which are created by the VUT (Vienna University
|
---|
| 35 | of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
|
---|
| 36 | (www.gametools.org).
|
---|
| 37 | */
|
---|
| 38 |
|
---|
[1145] | 39 | /** Main class of the visibility preprocessor. Responsible for loading and
|
---|
| 40 | saving of the input and output files. Initiates construction of the kD-tree,
|
---|
| 41 | viewcell loading/generation and the visibility computation itself.
|
---|
| 42 | */
|
---|
| 43 | // matt: remove qt dependencies
|
---|
| 44 | class Preprocessor// : public QObject
|
---|
| 45 | {
|
---|
| 46 | //Q_OBJECT
|
---|
[492] | 47 |
|
---|
[372] | 48 | public:
|
---|
| 49 | /** Default constructor initialising e.g., KD tree and BSP tree.
|
---|
| 50 | */
|
---|
| 51 | Preprocessor();
|
---|
| 52 |
|
---|
| 53 | virtual ~Preprocessor();
|
---|
| 54 |
|
---|
| 55 | /** Load the input scene.
|
---|
| 56 | @param filename file to load
|
---|
[1145] | 57 | @return true on success
|
---|
[372] | 58 | */
|
---|
| 59 | virtual bool LoadScene(const string filename);
|
---|
| 60 |
|
---|
| 61 | /** Export all preprocessed data in a XML format understandable by the
|
---|
| 62 | PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
|
---|
| 63 | on the environement settings.
|
---|
| 64 | @return true on successful export
|
---|
| 65 | */
|
---|
| 66 | virtual bool ExportPreprocessedData(const string filename);
|
---|
| 67 |
|
---|
| 68 | /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
|
---|
| 69 | is driven by the environment settings, which also sais which of the three types of
|
---|
| 70 | entities should be used to drive the heuristical construction (only occluders by default)
|
---|
| 71 | */
|
---|
| 72 | virtual bool BuildKdTree();
|
---|
| 73 |
|
---|
| 74 | /** Compute visibility method. This method has to be reimplemented by the actual
|
---|
| 75 | Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
|
---|
| 76 | GlobalSamplingpreprocessor)
|
---|
| 77 | */
|
---|
| 78 | virtual bool ComputeVisibility() = 0;
|
---|
[871] | 79 |
|
---|
| 80 | /** Post Process the computed visibility. By default applys the visibility filter
|
---|
| 81 | (if specified in the environment and export the preprocessed data */
|
---|
| 82 | virtual bool PostProcessVisibility();
|
---|
| 83 |
|
---|
[439] | 84 | /** View cells are either loaded or prepared for generation, according to the chosen environment
|
---|
| 85 | object. Important evironment options are, e.g, the view cell type.
|
---|
| 86 | Should be done after scene loading (i.e., some options are based on scene type).
|
---|
| 87 | */
|
---|
| 88 | bool PrepareViewCells();
|
---|
[372] | 89 |
|
---|
[1020] | 90 | /** Returns the specified sample strategy, NULL if no valid strategy.
|
---|
| 91 | */
|
---|
| 92 | SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
|
---|
| 93 |
|
---|
[372] | 94 | bool
|
---|
| 95 | Export( const string filename,
|
---|
| 96 | const bool scene,
|
---|
| 97 | const bool kdtree,
|
---|
| 98 | const bool bsptree
|
---|
| 99 | );
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | virtual void KdTreeStatistics(ostream &s);
|
---|
| 103 | virtual void BspTreeStatistics(ostream &s);
|
---|
| 104 |
|
---|
[490] | 105 | /** Loads samples from file.
|
---|
| 106 | @param samples returns the stored sample rays
|
---|
| 107 | @param objects needed to associate the objects ids
|
---|
| 108 | @returns true if samples were loaded successfully
|
---|
| 109 | */
|
---|
| 110 | bool LoadSamples(VssRayContainer &samples,
|
---|
| 111 | ObjectContainer &objects) const;
|
---|
| 112 |
|
---|
| 113 | /** Exports samples to file.
|
---|
| 114 | @returns true if samples were written successfully
|
---|
| 115 | */
|
---|
[508] | 116 | bool ExportSamples(const VssRayContainer &samples) const;
|
---|
| 117 |
|
---|
[1197] | 118 | bool LoadKdTree();
|
---|
| 119 | bool ExportKdTree();
|
---|
| 120 |
|
---|
[563] | 121 | /** Get Sample rays of particular type, returns false if this
|
---|
| 122 | type of rays is not supported by the preprocessor
|
---|
| 123 | */
|
---|
| 124 | enum {
|
---|
| 125 | OBJECT_BASED_DISTRIBUTION,
|
---|
| 126 | DIRECTION_BASED_DISTRIBUTION,
|
---|
| 127 | DIRECTION_BOX_BASED_DISTRIBUTION,
|
---|
| 128 | SPATIAL_BOX_BASED_DISTRIBUTION,
|
---|
| 129 | RSS_BASED_DISTRIBUTION,
|
---|
| 130 | RSS_SILHOUETTE_BASED_DISTRIBUTION,
|
---|
[576] | 131 | VSS_BASED_DISTRIBUTION,
|
---|
[1020] | 132 | OBJECT_DIRECTION_BASED_DISTRIBUTION,
|
---|
| 133 | OBJECTS_INTERIOR_DISTRIBUTION
|
---|
[563] | 134 | };
|
---|
| 135 |
|
---|
[1221] | 136 | enum {
|
---|
[1272] | 137 | INTERNAL_RAYCASTER = 0,
|
---|
[1221] | 138 | INTEL_RAYCASTER
|
---|
| 139 | };
|
---|
| 140 |
|
---|
[563] | 141 | virtual bool
|
---|
| 142 | GenerateRays(
|
---|
| 143 | const int number,
|
---|
| 144 | const int raysType,
|
---|
| 145 | SimpleRayContainer &rays
|
---|
| 146 | );
|
---|
| 147 |
|
---|
[573] | 148 | virtual void CastRays(SimpleRayContainer &rays,
|
---|
[1281] | 149 | VssRayContainer &vssRays);
|
---|
[573] | 150 |
|
---|
[1022] | 151 | /** Returns a view cells manager with respect to the given name.
|
---|
| 152 | */
|
---|
[575] | 153 | ViewCellsManager *CreateViewCellsManager(const char *name);
|
---|
[1221] | 154 |
|
---|
| 155 | GlRendererBuffer *GetRenderer() { return renderer;}
|
---|
| 156 |
|
---|
| 157 | bool InitRayCast(const string externKdTree);
|
---|
| 158 |
|
---|
[1251] | 159 | int CastRay(
|
---|
| 160 | const Vector3 &viewPoint,
|
---|
| 161 | const Vector3 &direction,
|
---|
| 162 | const float probability,
|
---|
| 163 | VssRayContainer &vssRays,
|
---|
| 164 | const AxisAlignedBox3 &box
|
---|
| 165 | );
|
---|
| 166 |
|
---|
[1221] | 167 | ////////////////////////////////////////////////
|
---|
| 168 |
|
---|
[372] | 169 | /// scene graph loaded from file
|
---|
| 170 | SceneGraph *mSceneGraph;
|
---|
[492] | 171 |
|
---|
| 172 | /// raw array of objects
|
---|
| 173 | ObjectContainer mObjects;
|
---|
[372] | 174 |
|
---|
| 175 | /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
|
---|
| 176 | KdTree *mKdTree;
|
---|
[445] | 177 | /// View space partition bsp tree
|
---|
| 178 | VspBspTree *mVspBspTree;
|
---|
[1022] | 179 | // view space partition tree
|
---|
| 180 | VspTree *mVspTree;
|
---|
[1279] | 181 | HierarchyManager *mHierarchyManager;
|
---|
[1022] | 182 | /// BSP tree representing the viewcells
|
---|
| 183 | BspTree *mBspTree;
|
---|
[1264] | 184 |
|
---|
[372] | 185 | /// list of all loaded occluders
|
---|
| 186 | ObjectContainer mOccluders;
|
---|
| 187 | /// list of all loaded occludees
|
---|
| 188 | ObjectContainer mOccludees;
|
---|
[439] | 189 |
|
---|
[1022] | 190 |
|
---|
[439] | 191 | ViewCellsManager *mViewCellsManager;
|
---|
[409] | 192 |
|
---|
[1006] | 193 | /// greedy optimized hierarchy for both objects and view cells
|
---|
| 194 | VspOspTree *mVspOspTree;
|
---|
[429] | 195 |
|
---|
[492] | 196 | bool mUseGlRenderer;
|
---|
[538] | 197 | bool mUseGlDebugger;
|
---|
| 198 |
|
---|
[518] | 199 | bool mLoadViewCells;
|
---|
[534] | 200 |
|
---|
| 201 | bool mDetectEmptyViewSpace;
|
---|
[599] | 202 |
|
---|
| 203 | bool mQuitOnFinish;
|
---|
[658] | 204 | bool mLoadPolygonsAsMeshes;
|
---|
[685] | 205 | bool mComputeVisibility;
|
---|
[658] | 206 |
|
---|
[871] | 207 | bool mExportVisibility;
|
---|
| 208 | string mVisibilityFileName;
|
---|
| 209 |
|
---|
| 210 | bool mApplyVisibilityFilter;
|
---|
[904] | 211 | bool mApplyVisibilitySpatialFilter;
|
---|
[878] | 212 |
|
---|
| 213 | float mVisibilityFilterWidth;
|
---|
[1221] | 214 |
|
---|
| 215 | int GetRayCastMethod() { return mRayCastMethod; }
|
---|
| 216 | void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }
|
---|
| 217 |
|
---|
[1251] | 218 | int mPass;
|
---|
| 219 |
|
---|
[492] | 220 | protected:
|
---|
| 221 |
|
---|
[1251] | 222 | void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction);
|
---|
| 223 |
|
---|
[1281] | 224 | int
|
---|
| 225 | ProcessRay(
|
---|
[1283] | 226 | const Vector3 &viewPoint,
|
---|
| 227 | const Vector3 &direction,
|
---|
[1281] | 228 | Intersectable *objectA,
|
---|
| 229 | Vector3 &pointA,
|
---|
[1283] | 230 | const Vector3 &normalA,
|
---|
[1281] | 231 | Intersectable *objectB,
|
---|
| 232 | Vector3 &pointB,
|
---|
[1283] | 233 | const Vector3 &normalB,
|
---|
[1281] | 234 | const float probability,
|
---|
| 235 | VssRayContainer &vssRays,
|
---|
| 236 | const AxisAlignedBox3 &box);
|
---|
| 237 |
|
---|
| 238 | int CastInternalRay(
|
---|
| 239 | const Vector3 &viewPoint,
|
---|
| 240 | const Vector3 &direction,
|
---|
| 241 | const float probability,
|
---|
| 242 | VssRayContainer &vssRays,
|
---|
| 243 | const AxisAlignedBox3 &box);
|
---|
| 244 |
|
---|
| 245 | int CastIntelDoubleRay(
|
---|
| 246 | const Vector3 &viewPoint,
|
---|
| 247 | const Vector3 &direction,
|
---|
| 248 | const float probability,
|
---|
| 249 | VssRayContainer &vssRays,
|
---|
| 250 | const AxisAlignedBox3 &box);
|
---|
| 251 |
|
---|
| 252 | Intersectable *CastIntelSingleRay(
|
---|
| 253 | const Vector3 &viewPoint,
|
---|
| 254 | const Vector3 &direction,
|
---|
| 255 | Vector3 &tPoint,
|
---|
| 256 | const AxisAlignedBox3 &box);
|
---|
| 257 |
|
---|
[492] | 258 | /////////////////////////
|
---|
| 259 |
|
---|
[1221] | 260 | int mRayCastMethod;
|
---|
[492] | 261 | /// samples used for construction of the BSP view cells tree.
|
---|
| 262 | int mBspConstructionSamples;
|
---|
[1006] | 263 | /// samples used for construction of the VSP OSP tree.
|
---|
| 264 | int mVspOspConstructionSamples;
|
---|
[468] | 265 | /** Simulates rendering of the scene.
|
---|
| 266 | */
|
---|
| 267 | RenderSimulator *mRenderSimulator;
|
---|
[492] | 268 |
|
---|
[1281] | 269 |
|
---|
| 270 | vector<FaceParentInfo> mFaceParents;
|
---|
| 271 |
|
---|
[496] | 272 | GlRendererBuffer *renderer;
|
---|
[1145] | 273 | // matt: remove qt dependencies
|
---|
| 274 | //signals:
|
---|
[492] | 275 | void EvalPvsStat();
|
---|
| 276 |
|
---|
[1281] | 277 | protected:
|
---|
| 278 |
|
---|
| 279 |
|
---|
| 280 | void CastRays16(const int i,
|
---|
| 281 | SimpleRayContainer &rays,
|
---|
| 282 | VssRayContainer &vssRays,
|
---|
| 283 | const AxisAlignedBox3 &sbox);
|
---|
| 284 |
|
---|
[372] | 285 | };
|
---|
| 286 |
|
---|
[1145] | 287 | //extern Preprocessor *preprocessor;
|
---|
[372] | 288 |
|
---|
[860] | 289 | }
|
---|
| 290 |
|
---|
[372] | 291 | #endif
|
---|