[440] | 1 | #ifndef _ViewCellsManager_H__
|
---|
| 2 | #define _ViewCellsManager_H__
|
---|
| 3 |
|
---|
| 4 | #include "Ray.h"
|
---|
| 5 | #include "VssRay.h"
|
---|
| 6 | #include "Containers.h"
|
---|
[475] | 7 | #include "ViewCell.h"
|
---|
[610] | 8 | #include "ViewCellBsp.h"
|
---|
[440] | 9 |
|
---|
[860] | 10 | namespace GtpVisibilityPreprocessor {
|
---|
| 11 |
|
---|
[440] | 12 | class ViewCell;
|
---|
| 13 | class Intersectable;
|
---|
| 14 | class RenderSimulator;
|
---|
[480] | 15 | class Renderer;
|
---|
[440] | 16 | class Mesh;
|
---|
| 17 | struct Triangle3;
|
---|
| 18 | class SimulationStatistics;
|
---|
| 19 | class BspTree;
|
---|
| 20 | class KdTree;
|
---|
[1006] | 21 | class VspOspTree;
|
---|
[440] | 22 | class VspBspTree;
|
---|
| 23 | class KdNode;
|
---|
| 24 | class KdLeaf;
|
---|
| 25 | class AxisAlignedBox3;
|
---|
[448] | 26 | class BspLeaf;
|
---|
[475] | 27 | class ViewCellsStatistics;
|
---|
[482] | 28 | class Exporter;
|
---|
[532] | 29 | class Beam;
|
---|
[570] | 30 | class Preprocessor;
|
---|
[580] | 31 | class ViewCellsTree;
|
---|
| 32 | class MergeCandidate;
|
---|
[931] | 33 | class BoundingBoxConverter;
|
---|
[1021] | 34 | class VspTree;
|
---|
| 35 | class OspTree;
|
---|
| 36 | class VspNode;
|
---|
[1027] | 37 | class HierarchyManager;
|
---|
[1047] | 38 | struct AxisAlignedPlane;
|
---|
[503] | 39 |
|
---|
[475] | 40 | struct BspRay;
|
---|
| 41 |
|
---|
[677] | 42 |
|
---|
[1145] | 43 | /** Probably Visible Set
|
---|
| 44 | */
|
---|
[697] | 45 | class PrVs
|
---|
| 46 | {
|
---|
| 47 | public:
|
---|
[704] | 48 | /// root of view cells tree
|
---|
| 49 | ViewCell *mViewCell;
|
---|
| 50 |
|
---|
[880] | 51 | // input parameter is the render budget for the PrVs
|
---|
[677] | 52 | float mRenderBudget;
|
---|
| 53 |
|
---|
| 54 | /// some characteristic values could be here
|
---|
| 55 |
|
---|
| 56 | };
|
---|
| 57 |
|
---|
[850] | 58 |
|
---|
| 59 | /** Manages different higher order operations on the view cells.
|
---|
[440] | 60 | */
|
---|
| 61 | class ViewCellsManager
|
---|
| 62 | {
|
---|
| 63 | public:
|
---|
[728] | 64 | struct PvsStatistics
|
---|
| 65 | {
|
---|
| 66 | int minPvs;
|
---|
| 67 | int maxPvs;
|
---|
| 68 | float avgPvs;
|
---|
| 69 | int viewcells;
|
---|
[467] | 70 | };
|
---|
[697] | 71 |
|
---|
[728] | 72 | /// view cell container types
|
---|
[1021] | 73 | enum {BSP, KD, VSP_KD, VSP_BSP, VSP_OSP};
|
---|
[466] | 74 |
|
---|
[931] | 75 | /// render cost evaluation type
|
---|
[728] | 76 | enum {PER_OBJECT, PER_TRIANGLE};
|
---|
| 77 |
|
---|
[1004] | 78 | /** Default constructor.
|
---|
[440] | 79 | */
|
---|
[1004] | 80 | ViewCellsManager();
|
---|
[440] | 81 |
|
---|
[462] | 82 | virtual ~ViewCellsManager();
|
---|
[440] | 83 |
|
---|
[527] | 84 | /** Constructs view cells container taking a preprocessor
|
---|
[570] | 85 | @returns the output rays (if not null)
|
---|
| 86 | */
|
---|
| 87 | int Construct(Preprocessor *preprocessor, VssRayContainer *outRays = NULL);
|
---|
[527] | 88 |
|
---|
[440] | 89 | /** Constructs view cell container with a given number of samples.
|
---|
| 90 | */
|
---|
[574] | 91 | virtual int ConstructSubdivision(const ObjectContainer &objects,
|
---|
[487] | 92 | const VssRayContainer &rays) = 0;
|
---|
[440] | 93 |
|
---|
[441] | 94 | /** Computes sample contributions of the rays to the view cells PVS.
|
---|
| 95 |
|
---|
| 96 | @param rays bundle of rays used to find intersections with view cells and
|
---|
| 97 | adding the contribution
|
---|
[563] | 98 | @param addRays true if rays should be added to the PVSs of the viewcells they
|
---|
[574] | 99 | intersect
|
---|
| 100 | @param storeViewCells true if view cells should be stored in the ray
|
---|
| 101 | */
|
---|
[697] | 102 | float ComputeSampleContributions(const VssRayContainer &rays,
|
---|
[574] | 103 | const bool addContributions,
|
---|
| 104 | const bool storeViewCells);
|
---|
[440] | 105 |
|
---|
[697] | 106 | /** Add sample contributions to the viewcells they intersect */
|
---|
| 107 | void AddSampleContributions(const VssRayContainer &rays);
|
---|
[563] | 108 |
|
---|
[441] | 109 |
|
---|
[475] | 110 | /** Computes sample contribution of a simgle ray to the view cells PVS.
|
---|
| 111 | @param ray finds intersections with view cells and holds the contribution
|
---|
| 112 | @param castRay true if ray should be cast to gain the information, false if ray
|
---|
| 113 | is already holding the information and need not be recast.
|
---|
[466] | 114 |
|
---|
[475] | 115 | @returns number of sample contributions
|
---|
| 116 | */
|
---|
[591] | 117 | virtual float ComputeSampleContributions(VssRay &ray,
|
---|
| 118 | const bool addRays,
|
---|
| 119 | const bool storeViewCells);
|
---|
[563] | 120 |
|
---|
[591] | 121 | virtual void AddSampleContributions(VssRay &ray);
|
---|
[563] | 122 |
|
---|
[452] | 123 | /** Prints out statistics of the view cells.
|
---|
| 124 | */
|
---|
[475] | 125 | virtual void PrintStatistics(ostream &s) const;
|
---|
[452] | 126 |
|
---|
[440] | 127 | /** Post processes view cells givemŽa number of rays.
|
---|
| 128 | */
|
---|
[475] | 129 | virtual int PostProcess(const ObjectContainer &objects,
|
---|
| 130 | const VssRayContainer &rays) = 0;
|
---|
[440] | 131 |
|
---|
| 132 | /** Show visualization of the view cells.
|
---|
| 133 | */
|
---|
| 134 | virtual void Visualize(const ObjectContainer &objects,
|
---|
[466] | 135 | const VssRayContainer &sampleRays) = 0;
|
---|
[440] | 136 |
|
---|
| 137 | /** type of the view cell container.
|
---|
| 138 | */
|
---|
| 139 | virtual int GetType() const = 0;
|
---|
| 140 |
|
---|
[463] | 141 | /** Load the input viewcells. The input viewcells should be given as a collection
|
---|
| 142 | of meshes. Each mesh is assume to form a bounded polyhedron defining the interior of
|
---|
| 143 | the viewcell. The method then builds a BSP tree of these view cells.
|
---|
| 144 |
|
---|
| 145 | @param filename file to load
|
---|
| 146 | @return true on success
|
---|
| 147 | */
|
---|
[577] | 148 | virtual bool LoadViewCellsGeometry(const string filename);
|
---|
[440] | 149 |
|
---|
[577] | 150 |
|
---|
[440] | 151 | /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector.
|
---|
| 152 | @param the base triangle
|
---|
| 153 | @param the height of the newly created view cell
|
---|
| 154 | */
|
---|
| 155 | ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const;
|
---|
| 156 |
|
---|
| 157 | /** Merges two view cells.
|
---|
| 158 | @note the piercing rays of the front and back will be ordered
|
---|
| 159 | @returns new view cell based on the merging.
|
---|
| 160 | */
|
---|
[582] | 161 | ViewCellInterior *MergeViewCells(ViewCell *front, ViewCell *back) const;
|
---|
| 162 |
|
---|
| 163 | /** Merges a container of view cells.
|
---|
| 164 | @returns new view cell based on the merging.
|
---|
| 165 | */
|
---|
| 166 | ViewCellInterior *MergeViewCells(ViewCellContainer &children) const;
|
---|
[440] | 167 |
|
---|
| 168 | /** Generates view cell of type specified by this manager
|
---|
| 169 | */
|
---|
[580] | 170 | virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const = 0;
|
---|
[440] | 171 |
|
---|
| 172 | /** Adds a new view cell to the list of predefined view cells.
|
---|
| 173 | */
|
---|
| 174 | void AddViewCell(ViewCell *viewCell);
|
---|
| 175 |
|
---|
[1002] | 176 | /** Derive view cells from scene objects. The view ells are created by taking the object
|
---|
[1001] | 177 | geometry into account.
|
---|
[440] | 178 | */
|
---|
[1002] | 179 | void DeriveViewCellsFromObjects(const ObjectContainer &objects,
|
---|
| 180 | ViewCellContainer &viewCells,
|
---|
| 181 | const int maxViewCells) const;
|
---|
[440] | 182 |
|
---|
| 183 | /** Sets maximal number of samples used for the
|
---|
| 184 | construction of the view cells.
|
---|
| 185 | */
|
---|
| 186 | void SetVisualizationSamples(const int visSamples);
|
---|
| 187 |
|
---|
[574] | 188 | /** Sets maximal number of samples used for the construction of the view cells.
|
---|
[440] | 189 | */
|
---|
| 190 | void SetConstructionSamples(const int constructionSamples);
|
---|
| 191 |
|
---|
[574] | 192 | /** Sets maximal number of samples used for the visualization of the view cells.
|
---|
| 193 | */
|
---|
| 194 | void SetInitialSamples(const int initialSamples);
|
---|
| 195 |
|
---|
[440] | 196 | /** Sets maximal number of samples used for the post processing of the view cells.
|
---|
| 197 | */
|
---|
| 198 | void SetPostProcessSamples(const int postProcessingSamples);
|
---|
| 199 |
|
---|
| 200 | /** See set.
|
---|
| 201 | */
|
---|
| 202 | int GetVisualizationSamples() const;
|
---|
| 203 |
|
---|
| 204 | /** See set.
|
---|
| 205 | */
|
---|
| 206 | int GetConstructionSamples() const;
|
---|
| 207 |
|
---|
| 208 | /** See set.
|
---|
| 209 | */
|
---|
| 210 | int GetPostProcessSamples() const;
|
---|
| 211 |
|
---|
[1002] | 212 | /** Returns true if view cells are already constructed.
|
---|
[440] | 213 | */
|
---|
| 214 | virtual bool ViewCellsConstructed() const = 0;
|
---|
[441] | 215 |
|
---|
[477] | 216 | /** cast line segment to get a list of unique viewcells which are intersected
|
---|
| 217 | by this line segment
|
---|
| 218 | */
|
---|
[466] | 219 |
|
---|
[477] | 220 | virtual int CastLineSegment(const Vector3 &origin,
|
---|
[466] | 221 | const Vector3 &termination,
|
---|
| 222 | ViewCellContainer &viewcells
|
---|
| 223 | ) = 0;
|
---|
| 224 |
|
---|
[477] | 225 | virtual void GetPvsStatistics(PvsStatistics &stat);
|
---|
[466] | 226 |
|
---|
[904] | 227 | virtual void GetPrVS(const Vector3 &viewPoint, PrVs &prvs, const float filterWidth);
|
---|
[677] | 228 |
|
---|
[697] | 229 | /** Get a viewcell containing the specified point
|
---|
[879] | 230 | @param active if the active or elementary view cell should be returned.
|
---|
[697] | 231 | */
|
---|
[879] | 232 | virtual ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const = 0;
|
---|
[492] | 233 |
|
---|
[503] | 234 | virtual void PrintPvsStatistics(ostream &s);
|
---|
[467] | 235 |
|
---|
[719] | 236 | /** Updates pvs of the view cell hierarchy if necessary.
|
---|
| 237 | */
|
---|
| 238 | void UpdatePvs();
|
---|
| 239 |
|
---|
[477] | 240 | /** Returns probability that view point lies in one view cell.
|
---|
| 241 | */
|
---|
| 242 | virtual float GetProbability(ViewCell *viewCell) = 0;
|
---|
[468] | 243 |
|
---|
[477] | 244 | /** Returns render cost of a single view cell given the render cost of an object.
|
---|
| 245 | */
|
---|
[728] | 246 | float GetRendercost(ViewCell *viewCell) const;
|
---|
[468] | 247 |
|
---|
[720] | 248 | /** Returns reference to container of loaded / generated view cells.
|
---|
[477] | 249 | */
|
---|
| 250 | ViewCellContainer &GetViewCells();
|
---|
[468] | 251 |
|
---|
[485] | 252 | /** Helper function used to split ray sets uniformly
|
---|
| 253 | into one that is currently used and the other that
|
---|
| 254 | is saved for later processing.
|
---|
| 255 | @param sourceRays the input ray set
|
---|
| 256 | @param maxSize the maximal number of rays that will be used
|
---|
| 257 | @param usedRays returns the used ray set
|
---|
| 258 | @param savedRays if not null, returns the saved ray set
|
---|
[477] | 259 | */
|
---|
| 260 | void GetRaySets(const VssRayContainer &sourceRays,
|
---|
[485] | 261 | const int maxSize,
|
---|
| 262 | VssRayContainer &usedRays,
|
---|
| 263 | VssRayContainer *savedRays = NULL) const;
|
---|
| 264 |
|
---|
[480] | 265 | /** Returns accumulated area of all view cells.
|
---|
| 266 | */
|
---|
| 267 | float GetAccVcArea();
|
---|
[470] | 268 |
|
---|
[480] | 269 | /** Returns area of one view cell.
|
---|
| 270 | */
|
---|
| 271 | virtual float GetArea(ViewCell *viewCell) const;
|
---|
[470] | 272 |
|
---|
[551] | 273 | /** Returns volume of view cell.
|
---|
[480] | 274 | */
|
---|
| 275 | virtual float GetVolume(ViewCell *viewCell) const;
|
---|
[470] | 276 |
|
---|
[480] | 277 | /** Sets the current renderer mainly for view cells statistics.
|
---|
| 278 | */
|
---|
| 279 | void SetRenderer(Renderer *renderer);
|
---|
| 280 |
|
---|
[487] | 281 | /** Computes a (random) view point in the valid view space.
|
---|
| 282 | @returns true if valid view point was found
|
---|
| 283 | */
|
---|
| 284 | virtual bool GetViewPoint(Vector3 &viewPoint) const;
|
---|
| 285 |
|
---|
[490] | 286 | /** Returns true if this view point is in the valid view space.
|
---|
| 287 | */
|
---|
| 288 | virtual bool ViewPointValid(const Vector3 &viewPoint) const;
|
---|
| 289 |
|
---|
[487] | 290 | /** Sets a view space boundary.
|
---|
| 291 | */
|
---|
| 292 | void SetViewSpaceBox(const AxisAlignedBox3 &box);
|
---|
| 293 |
|
---|
[519] | 294 | AxisAlignedBox3 GetViewSpaceBox() const;
|
---|
| 295 |
|
---|
[503] | 296 | /** Creates mesh for this view cell.
|
---|
| 297 | */
|
---|
| 298 | virtual void CreateMesh(ViewCell *vc) = NULL;
|
---|
[487] | 299 |
|
---|
[508] | 300 | /** Writes view cells to disc.
|
---|
| 301 | */
|
---|
[1027] | 302 | virtual bool ExportViewCells(const string filename,
|
---|
| 303 | const bool exportPvs,
|
---|
| 304 | const ObjectContainer &objects);
|
---|
[508] | 305 |
|
---|
[532] | 306 | /** Casts beam to collect view cells.
|
---|
| 307 | */
|
---|
| 308 | virtual int CastBeam(Beam &beam);
|
---|
| 309 |
|
---|
[547] | 310 | /** Checks if view cell is considered as valid.
|
---|
| 311 | */
|
---|
[561] | 312 | virtual bool CheckValidity(ViewCell *vc,
|
---|
[562] | 313 | int minPvsSize,
|
---|
| 314 | int maxPvsSize) const;
|
---|
[547] | 315 |
|
---|
[562] | 316 |
|
---|
| 317 | /** Sets validity of view cell
|
---|
| 318 | */
|
---|
| 319 | virtual void SetValidity(ViewCell *vc,
|
---|
| 320 | int minPvsSize,
|
---|
| 321 | int maxPvsSize) const;
|
---|
| 322 |
|
---|
[710] | 323 | /** sets validy of all viewcells
|
---|
| 324 | */
|
---|
[810] | 325 | virtual void SetValidity(int minPvsSize,
|
---|
[569] | 326 | int maxPvsSize) const;
|
---|
| 327 |
|
---|
[609] | 328 |
|
---|
| 329 | /** set valid viewcells in the range of pvs. sorts the viewcells
|
---|
[710] | 330 | according to the pvs and then pickups those in the ranges
|
---|
| 331 | */
|
---|
| 332 | void SetValidityPercentage(const float minValid, const float maxValid);
|
---|
[569] | 333 |
|
---|
[609] | 334 | int CountValidViewcells() const;
|
---|
| 335 |
|
---|
[547] | 336 | /** Returns maximal allowed pvs size.
|
---|
| 337 | */
|
---|
| 338 | int GetMaxPvsSize() const;
|
---|
| 339 |
|
---|
[562] | 340 | /** Returns maximal allowed pvs size.
|
---|
| 341 | */
|
---|
| 342 | int GetMinPvsSize() const;
|
---|
| 343 |
|
---|
[561] | 344 | /** Returns maximal ratio. i.e., currentPVs / maxPvs,
|
---|
| 345 | where pvs is still considered valid.
|
---|
| 346 | */
|
---|
| 347 | float GetMaxPvsRatio() const;
|
---|
| 348 |
|
---|
[547] | 349 | /** Exports view cell geometry.
|
---|
| 350 | */
|
---|
[591] | 351 | virtual void ExportViewCellGeometry(Exporter *exporter,
|
---|
| 352 | ViewCell *vc,
|
---|
[1047] | 353 | const AxisAlignedPlane *clipPlane = NULL) const = 0;
|
---|
[547] | 354 |
|
---|
[860] | 355 | /** Brings the view cells into their final state, computes meshes and volume.
|
---|
| 356 | */
|
---|
[551] | 357 | virtual void FinalizeViewCells(const bool createMesh);
|
---|
| 358 |
|
---|
[579] | 359 | /** Evaluates statistics values on view cells.
|
---|
| 360 | */
|
---|
[580] | 361 | void EvaluateRenderStatistics(float &totalRenderCost,
|
---|
| 362 | float &expectedRenderCost,
|
---|
| 363 | float &deviation,
|
---|
| 364 | float &variance,
|
---|
| 365 | int &totalPvs,
|
---|
| 366 | float &avgRenderCost);
|
---|
[579] | 367 |
|
---|
[580] | 368 |
|
---|
| 369 | /** Returns hierarchy of the view cells.
|
---|
| 370 | */
|
---|
| 371 | ViewCellsTree *GetViewCellsTree();
|
---|
| 372 |
|
---|
[581] | 373 | virtual void CollectMergeCandidates(const VssRayContainer &rays,
|
---|
[1022] | 374 | vector<MergeCandidate> &candidates);
|
---|
[580] | 375 |
|
---|
[610] | 376 | void CollectViewCells(const int n);
|
---|
| 377 |
|
---|
[660] | 378 | /** Sets current view cells set to active, i.e., the sampling is done in this view cell set.
|
---|
| 379 | */
|
---|
| 380 | void SetViewCellsActive();
|
---|
[599] | 381 |
|
---|
[1145] | 382 | /** Evaluates render cost statistics of current view cell hierarchy.
|
---|
[660] | 383 | */
|
---|
[1145] | 384 | void EvalViewCellPartition();
|
---|
[660] | 385 |
|
---|
[728] | 386 | /** Sets maximal size of a view cell filter.
|
---|
| 387 | */
|
---|
| 388 | void SetMaxFilterSize(const int size);
|
---|
[697] | 389 |
|
---|
[840] | 390 | /** Returns maximal filter size.
|
---|
| 391 | */
|
---|
| 392 | int GetMaxFilterSize() const;
|
---|
[746] | 393 |
|
---|
[840] | 394 | /** Deletes interior nodes from the tree which have negative merge cost set (local merge).
|
---|
| 395 | */
|
---|
| 396 | void DeleteLocalMergeTree(ViewCell *vc) const;
|
---|
[713] | 397 |
|
---|
[728] | 398 | /** Evaluautes histogram for a given number of view cells.
|
---|
| 399 | */
|
---|
| 400 | void EvalViewCellHistogram(const string filename, const int nViewCells);
|
---|
| 401 |
|
---|
[735] | 402 | /** Evaluautes histogram for a given number of view cells.
|
---|
| 403 | */
|
---|
| 404 | void EvalViewCellHistogramForPvsSize(const string filename, const int nViewCells);
|
---|
| 405 |
|
---|
[728] | 406 | /** Evaluates the render cost of a view cell.
|
---|
| 407 | */
|
---|
| 408 | float EvalRenderCost(Intersectable *obj) const;
|
---|
[1002] | 409 |
|
---|
| 410 | /** Sets pvs size of view cell as a scalar. Used when storing pvs only in the leaves
|
---|
| 411 | of the hierarchy.
|
---|
| 412 | */
|
---|
[1004] | 413 | void SetScalarPvsSize(ViewCell *vc, const int pvsSize) const;
|
---|
[728] | 414 |
|
---|
[1002] | 415 |
|
---|
[870] | 416 | /** Returns bounding box of a view cell.
|
---|
| 417 | */
|
---|
| 418 | AxisAlignedBox3 GetViewCellBox(ViewCell *vc);
|
---|
[859] | 419 |
|
---|
[840] | 420 | /** Exports bounding boxes of objects to file.
|
---|
| 421 | */
|
---|
| 422 | bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const;
|
---|
[931] | 423 |
|
---|
[850] | 424 | /** Load the bounding boxes into the container.
|
---|
| 425 | */
|
---|
| 426 | bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const;
|
---|
[840] | 427 |
|
---|
[1002] | 428 | /** Returns true if pvs should be exported together with the view cells.
|
---|
| 429 | */
|
---|
| 430 | bool GetExportPvs() const;
|
---|
[870] | 431 |
|
---|
| 432 | /** Loads view cells from file. The view cells manager is created with
|
---|
| 433 | respect to the loaded view cells.
|
---|
| 434 |
|
---|
[1002] | 435 | @param filename the filename of the view cells
|
---|
| 436 | @param objects the scene objects
|
---|
| 437 | @param finalizeViewCells if the view cells should be post processed, i.e.
|
---|
| 438 | a mesh is created representing the geometry
|
---|
| 439 | @param bconverter a conversion routine working with the similarities of bounding
|
---|
| 440 | boxes: if there is a certain similarity of overlap between bounding boxes, two tested
|
---|
| 441 | candidate objects are considered to be the same objects
|
---|
[870] | 442 | @returns the view cells manager if loading was successful, false otherwise
|
---|
| 443 | */
|
---|
[938] | 444 | static ViewCellsManager *LoadViewCells(const string &filename,
|
---|
[931] | 445 | ObjectContainer *objects,
|
---|
[944] | 446 | const bool finalizeViewCells,
|
---|
[931] | 447 | BoundingBoxConverter *bconverter = NULL);
|
---|
[870] | 448 |
|
---|
[904] | 449 |
|
---|
[931] | 450 | ////////////////////////////////////////////////////////7
|
---|
| 451 | // visiblity filter options
|
---|
| 452 | // TODO: write own visibiltiy filter class
|
---|
| 453 | void ApplyFilter(KdTree *kdTree,
|
---|
| 454 | const float viewSpaceFilterSize,
|
---|
| 455 | const float spatialFilterSize);
|
---|
[904] | 456 |
|
---|
[931] | 457 | void ApplySpatialFilter(KdTree *kdTree,
|
---|
| 458 | const float spatialFilterSize,
|
---|
| 459 | ObjectPvs &pvs);
|
---|
[480] | 460 |
|
---|
[931] | 461 | void ApplyFilter(ViewCell *viewCell,
|
---|
| 462 | KdTree *kdTree,
|
---|
| 463 | const float viewSpaceFilterSize,
|
---|
| 464 | const float spatialFilterSize,
|
---|
| 465 | ObjectPvs &pvs);
|
---|
| 466 |
|
---|
| 467 | float GetFilterWidth();
|
---|
| 468 |
|
---|
| 469 | float GetAbsFilterWidth();
|
---|
| 470 |
|
---|
| 471 |
|
---|
[697] | 472 | /** Returns the bounding box of filter width.
|
---|
| 473 | */
|
---|
| 474 | AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const;
|
---|
[609] | 475 |
|
---|
[979] | 476 |
|
---|
[1021] | 477 | /** Returns true if this view cell is equivalent to a node of the spatial hierarchy.
|
---|
| 478 | */
|
---|
| 479 | virtual bool EqualToSpatialNode(ViewCell *viewCell) const;
|
---|
| 480 |
|
---|
[931] | 481 | protected:
|
---|
[1145] | 482 |
|
---|
[931] | 483 | /** Exports bounding boxes as xml stream
|
---|
| 484 | */
|
---|
[955] | 485 | //bool ExportBoundingBoxes(ofstream &xmlstream, const ObjectContainer &objects) const;
|
---|
[931] | 486 |
|
---|
[697] | 487 | /** Intersects box with the tree and returns the number of intersected boxes.
|
---|
| 488 | @returns number of view cells found
|
---|
| 489 | */
|
---|
[710] | 490 | virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box,
|
---|
| 491 | ViewCellContainer &viewCells) const;
|
---|
[697] | 492 |
|
---|
[880] | 493 | /** Tests the visibility filter functionality.
|
---|
| 494 | */
|
---|
[697] | 495 | virtual void TestFilter(const ObjectContainer &objects) {};
|
---|
| 496 |
|
---|
[931] | 497 | /** If the view cells tree was already constructed or not.
|
---|
[581] | 498 | */
|
---|
| 499 | bool ViewCellsTreeConstructed() const;
|
---|
| 500 |
|
---|
[574] | 501 | int CastPassSamples(const int samplesPerPass,
|
---|
| 502 | const int sampleType,
|
---|
| 503 | VssRayContainer &vssRays) const;
|
---|
[573] | 504 |
|
---|
[931] | 505 | /** Parse the options from the environment file.
|
---|
| 506 | */
|
---|
[482] | 507 | void ParseEnvironment();
|
---|
| 508 |
|
---|
[508] | 509 | /** Creates unique view cell ids.
|
---|
| 510 | */
|
---|
| 511 | void CreateUniqueViewCellIds();
|
---|
[547] | 512 |
|
---|
[551] | 513 | /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell.
|
---|
| 514 | */
|
---|
| 515 | virtual void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
| 516 |
|
---|
[480] | 517 | /** Recollects view cells and resets statistics.
|
---|
| 518 | */
|
---|
| 519 | void ResetViewCells();
|
---|
[482] | 520 |
|
---|
[480] | 521 | /** Collects the view cells in the view cell container.
|
---|
| 522 | */
|
---|
| 523 | virtual void CollectViewCells() = 0;
|
---|
[482] | 524 |
|
---|
[479] | 525 | /** Evaluates view cells statistics and stores it in
|
---|
| 526 | mViewCellsStatistics.
|
---|
| 527 | */
|
---|
| 528 | void EvaluateViewCellsStats();
|
---|
[482] | 529 |
|
---|
| 530 | //-- helper functions for view cell visualization
|
---|
| 531 |
|
---|
| 532 | /** Exports the view cell partition.
|
---|
| 533 | */
|
---|
[508] | 534 | void ExportViewCellsForViz(Exporter *exporter) const;
|
---|
[482] | 535 |
|
---|
| 536 | /** Sets exporter color.
|
---|
| 537 | */
|
---|
[1021] | 538 | virtual void ExportColor(Exporter *exporter, ViewCell *vc) const;
|
---|
[482] | 539 |
|
---|
[1002] | 540 | /** Returns volume of the view space.
|
---|
| 541 | */
|
---|
[557] | 542 | virtual float GetViewSpaceVolume();
|
---|
| 543 |
|
---|
[503] | 544 | /** Creates meshes from the view cells.
|
---|
| 545 | */
|
---|
[517] | 546 | void CreateViewCellMeshes();
|
---|
[503] | 547 |
|
---|
[610] | 548 | /** Takes different measures to prepares the view cells after loading them from disc.
|
---|
[577] | 549 | */
|
---|
| 550 | virtual void PrepareLoadedViewCells() {};
|
---|
| 551 |
|
---|
[704] | 552 | /** Constructs local view cell merge hierarchy.
|
---|
| 553 | */
|
---|
| 554 | ViewCell *ConstructLocalMergeTree(ViewCell *currentViewCell,
|
---|
| 555 | const ViewCellContainer &viewCells);
|
---|
| 556 |
|
---|
[713] | 557 | /** Constructs local view cell merge hierarchy based solely on similarity with the
|
---|
| 558 | current viewcell
|
---|
| 559 | */
|
---|
| 560 | ViewCell *ConstructLocalMergeTree2(ViewCell *currentViewCell,
|
---|
| 561 | const ViewCellContainer &viewCells);
|
---|
| 562 |
|
---|
[660] | 563 | /** Creates clip plane for visualization.
|
---|
| 564 | */
|
---|
| 565 | void CreateClipPlane();
|
---|
[591] | 566 |
|
---|
[860] | 567 | /** Updates pvs of all view cells for statistical evaluation after some more sampling
|
---|
| 568 | */
|
---|
[752] | 569 | virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) = 0;
|
---|
| 570 |
|
---|
[1002] | 571 |
|
---|
[979] | 572 | ////////////////////////////////////////////////
|
---|
[752] | 573 |
|
---|
[1145] | 574 | Preprocessor *mPreprocessor;
|
---|
| 575 | /// if bounding boxes should be exported together with the view cells
|
---|
[840] | 576 | bool mExportBboxesForPvs;
|
---|
| 577 |
|
---|
[1004] | 578 | //Environment *environment;
|
---|
[1047] | 579 | AxisAlignedPlane mClipPlane;
|
---|
[837] | 580 |
|
---|
[660] | 581 | bool mUseClipPlaneForViz;
|
---|
[591] | 582 |
|
---|
| 583 |
|
---|
[480] | 584 | /// Renders the view cells.
|
---|
| 585 | Renderer *mRenderer;
|
---|
[440] | 586 |
|
---|
| 587 | /// Loaded view cells
|
---|
[469] | 588 | ViewCellContainer mViewCells;
|
---|
[1002] | 589 | /// the corresponding view cell tree holding the logical description of view cells
|
---|
[580] | 590 | ViewCellsTree *mViewCellsTree;
|
---|
[1002] | 591 | /// if empty view cells should be pruned (i.e., invalidated) from this point on
|
---|
[710] | 592 | bool mPruneEmptyViewCells;
|
---|
[706] | 593 |
|
---|
[1002] | 594 | /// if the pvss in the view cell leaves and the interiors are up to date
|
---|
[719] | 595 | bool mViewCellPvsIsUpdated;
|
---|
[1002] | 596 |
|
---|
[440] | 597 | /// maximum number of samples taken for construction of the view cells
|
---|
| 598 | int mConstructionSamples;
|
---|
[574] | 599 | int mSamplesPerPass;
|
---|
| 600 | int mInitialSamples;
|
---|
[440] | 601 | int mPostProcessSamples;
|
---|
| 602 | int mVisualizationSamples;
|
---|
[441] | 603 |
|
---|
[470] | 604 | float mTotalAreaValid;
|
---|
| 605 | float mTotalArea;
|
---|
[475] | 606 |
|
---|
[547] | 607 | int mMaxPvsSize;
|
---|
[562] | 608 | int mMinPvsSize;
|
---|
[547] | 609 | float mMaxPvsRatio;
|
---|
| 610 |
|
---|
[660] | 611 | int mSamplingType;
|
---|
[722] | 612 | int mEvaluationSamplingType;
|
---|
[600] | 613 | int mNumActiveViewCells;
|
---|
[586] | 614 | bool mCompressViewCells;
|
---|
| 615 |
|
---|
[1002] | 616 | /// holds the current view cell statistics
|
---|
[660] | 617 | ViewCellsStatistics mCurrentViewCellsStats;
|
---|
[487] | 618 | /// the scene bounding box
|
---|
[542] | 619 | AxisAlignedBox3 mViewSpaceBox;
|
---|
[1001] | 620 |
|
---|
[508] | 621 | /// if view cells should be exported
|
---|
| 622 | bool mExportViewCells;
|
---|
[547] | 623 |
|
---|
[1002] | 624 | // if only valid view cells should be considered for processing
|
---|
[564] | 625 | bool mOnlyValidViewCells;
|
---|
[547] | 626 |
|
---|
[580] | 627 | /// if rays should be used to collect merge candidates
|
---|
| 628 | bool mUseRaysForMerge;
|
---|
[1021] | 629 |
|
---|
[1002] | 630 | /// if there should be an additional merge step after the subdivision
|
---|
[592] | 631 | bool mMergeViewCells;
|
---|
[697] | 632 |
|
---|
| 633 | /// the width of the box filter
|
---|
| 634 | float mFilterWidth;
|
---|
| 635 | int mMaxFilterSize;
|
---|
| 636 |
|
---|
[487] | 637 | //-- visualization options
|
---|
| 638 |
|
---|
[1002] | 639 | /// color code for view cells visualization
|
---|
[487] | 640 | int mColorCode;
|
---|
| 641 | bool mExportGeometry;
|
---|
| 642 | bool mExportRays;
|
---|
[517] | 643 |
|
---|
| 644 | bool mViewCellsFinished;
|
---|
[664] | 645 |
|
---|
| 646 | bool mEvaluateViewCells;
|
---|
[666] | 647 |
|
---|
[693] | 648 | bool mShowVisualization;
|
---|
| 649 |
|
---|
| 650 | // HACK in order to detect empty view cells
|
---|
| 651 | void CollectEmptyViewCells();
|
---|
[694] | 652 | void TestEmptyViewCells(const ObjectContainer &obj);
|
---|
[693] | 653 |
|
---|
| 654 | ViewCellContainer mEmptyViewCells;
|
---|
[728] | 655 |
|
---|
| 656 | int mRenderCostEvaluationType;
|
---|
[844] | 657 |
|
---|
| 658 | /// if pvs should be exported with view cells
|
---|
| 659 | bool mExportPvs;
|
---|
[440] | 660 | };
|
---|
| 661 |
|
---|
[441] | 662 |
|
---|
[440] | 663 | /**
|
---|
| 664 | Manages different higher order operations on the view cells.
|
---|
| 665 | */
|
---|
| 666 | class BspViewCellsManager: public ViewCellsManager
|
---|
| 667 | {
|
---|
| 668 |
|
---|
| 669 | public:
|
---|
[485] | 670 | /** Constructor taking the bsp tree and the number of samples
|
---|
| 671 | used to construct the bsp tree.
|
---|
| 672 | */
|
---|
[1004] | 673 | BspViewCellsManager(BspTree *tree);
|
---|
[440] | 674 |
|
---|
[477] | 675 | ~BspViewCellsManager();
|
---|
| 676 |
|
---|
[574] | 677 | int ConstructSubdivision(const ObjectContainer &objects,
|
---|
[487] | 678 | const VssRayContainer &rays);
|
---|
[440] | 679 |
|
---|
| 680 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 681 | const VssRayContainer &rays);
|
---|
[440] | 682 |
|
---|
| 683 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 684 | const VssRayContainer &sampleRays);
|
---|
[440] | 685 |
|
---|
| 686 | int GetType() const;
|
---|
| 687 |
|
---|
| 688 | ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 689 |
|
---|
| 690 | bool ViewCellsConstructed() const;
|
---|
| 691 |
|
---|
[475] | 692 | //void PrintStatistics(ostream &s) const;
|
---|
[452] | 693 |
|
---|
[468] | 694 | int CastLineSegment(const Vector3 &origin,
|
---|
| 695 | const Vector3 &termination,
|
---|
| 696 | ViewCellContainer &viewcells);
|
---|
| 697 |
|
---|
[471] | 698 | float GetProbability(ViewCell *viewCell);
|
---|
[605] | 699 |
|
---|
[466] | 700 |
|
---|
[879] | 701 | /** Get a viewcell containing the specified point
|
---|
| 702 | */
|
---|
| 703 | ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
|
---|
[492] | 704 |
|
---|
[503] | 705 | void CreateMesh(ViewCell *vc);
|
---|
| 706 |
|
---|
[591] | 707 | void ExportViewCellGeometry(Exporter *exporter,
|
---|
| 708 | ViewCell *vc,
|
---|
[1047] | 709 | const AxisAlignedPlane *clipPlane = NULL) const;
|
---|
[580] | 710 |
|
---|
[587] | 711 | void CollectMergeCandidates(const VssRayContainer &rays,
|
---|
| 712 | vector<MergeCandidate> &candidates);
|
---|
[547] | 713 |
|
---|
[587] | 714 | void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
| 715 |
|
---|
[931] | 716 | bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects);
|
---|
[590] | 717 |
|
---|
[752] | 718 | /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
|
---|
| 719 | */
|
---|
[650] | 720 | ViewCell *ConstructSpatialMergeTree(BspNode *root);
|
---|
[610] | 721 |
|
---|
[752] | 722 | /** Updates the pvs in the view cells tree.
|
---|
| 723 | */
|
---|
| 724 | void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);
|
---|
[610] | 725 |
|
---|
[859] | 726 |
|
---|
[440] | 727 | protected:
|
---|
| 728 |
|
---|
[480] | 729 | void CollectViewCells();
|
---|
| 730 |
|
---|
[547] | 731 |
|
---|
[440] | 732 | /// the BSP tree.
|
---|
| 733 | BspTree *mBspTree;
|
---|
[475] | 734 |
|
---|
| 735 | vector<BspRay *> mBspRays;
|
---|
[440] | 736 |
|
---|
| 737 | private:
|
---|
| 738 |
|
---|
| 739 | /** Exports visualization of the BSP splits.
|
---|
| 740 | */
|
---|
[477] | 741 | void ExportSplits(const ObjectContainer &objects);
|
---|
[440] | 742 |
|
---|
| 743 | /** Exports visualization of the BSP PVS.
|
---|
| 744 | */
|
---|
[477] | 745 | void ExportBspPvs(const ObjectContainer &objects);
|
---|
[440] | 746 |
|
---|
[1002] | 747 | /** test if subdivision is valid in terms of volume / area.
|
---|
| 748 | */
|
---|
[693] | 749 | void TestSubdivision();
|
---|
[440] | 750 | };
|
---|
| 751 |
|
---|
| 752 | /**
|
---|
| 753 | Manages different higher order operations on the KD type view cells.
|
---|
| 754 | */
|
---|
| 755 | class KdViewCellsManager: public ViewCellsManager
|
---|
| 756 | {
|
---|
| 757 |
|
---|
| 758 | public:
|
---|
| 759 |
|
---|
[1004] | 760 | KdViewCellsManager(KdTree *tree);
|
---|
[440] | 761 |
|
---|
[574] | 762 | int ConstructSubdivision(const ObjectContainer &objects,
|
---|
[487] | 763 | const VssRayContainer &rays);
|
---|
[440] | 764 |
|
---|
[478] | 765 | int CastLineSegment(const Vector3 &origin,
|
---|
| 766 | const Vector3 &termination,
|
---|
| 767 | ViewCellContainer &viewcells);
|
---|
[440] | 768 |
|
---|
| 769 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 770 | const VssRayContainer &rays);
|
---|
[440] | 771 |
|
---|
| 772 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 773 | const VssRayContainer &sampleRays);
|
---|
[440] | 774 |
|
---|
| 775 | int GetType() const;
|
---|
| 776 |
|
---|
| 777 | bool ViewCellsConstructed() const;
|
---|
| 778 |
|
---|
[580] | 779 | ViewCell *GenerateViewCell(Mesh *mesh) const;
|
---|
[440] | 780 |
|
---|
[452] | 781 | /** Prints out statistics of this approach.
|
---|
| 782 | */
|
---|
[503] | 783 | // virtual void PrintStatistics(ostream &s) const;
|
---|
[879] | 784 | ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const { return NULL; }
|
---|
[452] | 785 |
|
---|
[503] | 786 | float GetProbability(ViewCell *viewCell);
|
---|
[609] | 787 |
|
---|
[468] | 788 |
|
---|
[503] | 789 | void CreateMesh(ViewCell *vc);
|
---|
| 790 |
|
---|
[591] | 791 | void ExportViewCellGeometry(Exporter *exporter,
|
---|
| 792 | ViewCell *vc,
|
---|
[1047] | 793 | const AxisAlignedPlane *clipPlane = NULL) const;
|
---|
[547] | 794 |
|
---|
[591] | 795 | void CollectMergeCandidates(const VssRayContainer &rays,
|
---|
| 796 | vector<MergeCandidate> &candidates);
|
---|
[580] | 797 |
|
---|
[752] | 798 |
|
---|
[440] | 799 | protected:
|
---|
| 800 |
|
---|
[752] | 801 | virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) {};
|
---|
[580] | 802 | /** Collects view cells from a hierarchy.
|
---|
| 803 | */
|
---|
[480] | 804 | void CollectViewCells();
|
---|
[580] | 805 |
|
---|
[480] | 806 | KdNode *GetNodeForPvs(KdLeaf *leaf);
|
---|
[440] | 807 |
|
---|
| 808 |
|
---|
[480] | 809 | /// the BSP tree.
|
---|
| 810 | KdTree *mKdTree;
|
---|
[440] | 811 |
|
---|
[480] | 812 | /// depth of the KD tree nodes with represent the view cells
|
---|
| 813 | int mKdPvsDepth;
|
---|
[938] | 814 |
|
---|
| 815 |
|
---|
[440] | 816 | };
|
---|
| 817 |
|
---|
| 818 | /**
|
---|
[442] | 819 | Manages different higher order operations on the view cells.
|
---|
| 820 | */
|
---|
| 821 | class VspBspViewCellsManager: public ViewCellsManager
|
---|
| 822 | {
|
---|
| 823 |
|
---|
| 824 | public:
|
---|
| 825 |
|
---|
[1004] | 826 | VspBspViewCellsManager(VspBspTree *tree);
|
---|
[475] | 827 | ~VspBspViewCellsManager();
|
---|
[442] | 828 |
|
---|
[574] | 829 | int ConstructSubdivision(const ObjectContainer &objects,
|
---|
[487] | 830 | const VssRayContainer &rays);
|
---|
[442] | 831 |
|
---|
| 832 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 833 | const VssRayContainer &rays);
|
---|
[442] | 834 |
|
---|
| 835 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 836 | const VssRayContainer &sampleRays);
|
---|
[442] | 837 |
|
---|
| 838 | int GetType() const;
|
---|
| 839 |
|
---|
| 840 | ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 841 |
|
---|
| 842 | bool ViewCellsConstructed() const;
|
---|
| 843 |
|
---|
[468] | 844 |
|
---|
| 845 | int CastLineSegment(const Vector3 &origin,
|
---|
| 846 | const Vector3 &termination,
|
---|
| 847 | ViewCellContainer &viewcells);
|
---|
[452] | 848 |
|
---|
[471] | 849 | float GetProbability(ViewCell *viewCell);
|
---|
[479] | 850 |
|
---|
[879] | 851 | ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
|
---|
[477] | 852 |
|
---|
[487] | 853 | bool GetViewPoint(Vector3 &viewPoint) const;
|
---|
| 854 |
|
---|
[490] | 855 | bool ViewPointValid(const Vector3 &viewPoint) const;
|
---|
[503] | 856 |
|
---|
| 857 | void CreateMesh(ViewCell *vc);
|
---|
| 858 |
|
---|
[931] | 859 | bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects);
|
---|
[508] | 860 |
|
---|
[532] | 861 | int CastBeam(Beam &beam);
|
---|
| 862 |
|
---|
[591] | 863 | void ExportViewCellGeometry(Exporter *exporter,
|
---|
| 864 | ViewCell *vc,
|
---|
[1047] | 865 | const AxisAlignedPlane *clipPlane = NULL) const;
|
---|
[547] | 866 |
|
---|
[551] | 867 | //float GetVolume(ViewCell *viewCell) const;
|
---|
| 868 |
|
---|
[555] | 869 | void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
[551] | 870 |
|
---|
[580] | 871 | void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
|
---|
| 872 |
|
---|
[697] | 873 | /** Returns true if this view cell is equivavalent to a spatial node.
|
---|
| 874 | */
|
---|
[609] | 875 | bool EqualToSpatialNode(ViewCell *viewCell) const;
|
---|
[607] | 876 |
|
---|
[697] | 877 |
|
---|
[442] | 878 | protected:
|
---|
[475] | 879 |
|
---|
[697] | 880 | int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const;
|
---|
[651] | 881 |
|
---|
[610] | 882 | /** Returns node of the spatial hierarchy corresponding to the view cell
|
---|
| 883 | if such a node exists.
|
---|
| 884 | */
|
---|
[609] | 885 | BspNode *GetSpatialNode(ViewCell *viewCell) const;
|
---|
[610] | 886 |
|
---|
[1021] | 887 | /** Merges view cells according to some criteria
|
---|
[442] | 888 | */
|
---|
[508] | 889 | void MergeViewCells(const VssRayContainer &rays,
|
---|
| 890 | const ObjectContainer &objects);
|
---|
[503] | 891 |
|
---|
[564] | 892 | void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);
|
---|
[442] | 893 |
|
---|
[480] | 894 | void CollectViewCells();
|
---|
| 895 |
|
---|
[482] | 896 | /** Returns maximal depth difference of view cell
|
---|
| 897 | leaves in tree.
|
---|
| 898 | */
|
---|
| 899 | int GetMaxTreeDiff(ViewCell *vc) const;
|
---|
[485] | 900 |
|
---|
[482] | 901 |
|
---|
[752] | 902 | /** Prepare view cells for use after loading them from disc.
|
---|
| 903 | */
|
---|
[577] | 904 | void PrepareLoadedViewCells();
|
---|
| 905 |
|
---|
[752] | 906 | /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
|
---|
| 907 | */
|
---|
[650] | 908 | ViewCell *ConstructSpatialMergeTree(BspNode *root);
|
---|
[649] | 909 |
|
---|
[752] | 910 | void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);
|
---|
| 911 |
|
---|
| 912 |
|
---|
[979] | 913 | /// HACK for testing visibility filter functionality
|
---|
[697] | 914 | void TestFilter(const ObjectContainer &objects);
|
---|
| 915 |
|
---|
| 916 |
|
---|
[979] | 917 | /** Visualization of the pvs difference to exact visubility using
|
---|
| 918 | from point queries.
|
---|
| 919 | */
|
---|
| 920 | void VisualizeWithFromPointQueries();
|
---|
[697] | 921 |
|
---|
[991] | 922 | /** Evaluate from point queries for the current scene.
|
---|
| 923 | */
|
---|
| 924 | void EvalFromPointQueries();
|
---|
[979] | 925 |
|
---|
[1021] | 926 | /** Exports visualization of the BSP splits.
|
---|
| 927 | */
|
---|
| 928 | void ExportSplits(const ObjectContainer &objects,
|
---|
| 929 | const VssRayContainer &rays);
|
---|
[991] | 930 |
|
---|
[1021] | 931 | /** Exports visualization of the BSP PVS.
|
---|
| 932 | */
|
---|
| 933 | void ExportBspPvs(const ObjectContainer &objects,
|
---|
| 934 | const VssRayContainer &rays);
|
---|
| 935 |
|
---|
| 936 |
|
---|
[442] | 937 | /// the view space partition BSP tree.
|
---|
| 938 | VspBspTree *mVspBspTree;
|
---|
| 939 |
|
---|
[591] | 940 |
|
---|
[442] | 941 | private:
|
---|
| 942 |
|
---|
[1021] | 943 | /** test if subdivision is valid in terms of volume / area.
|
---|
[442] | 944 | */
|
---|
[1021] | 945 | void TestSubdivision();
|
---|
| 946 | };
|
---|
[442] | 947 |
|
---|
[1021] | 948 |
|
---|
| 949 | /**
|
---|
| 950 | Manages different higher order operations on the view cells.
|
---|
| 951 | */
|
---|
| 952 | class VspOspViewCellsManager: public ViewCellsManager
|
---|
| 953 | {
|
---|
| 954 |
|
---|
| 955 | public:
|
---|
| 956 |
|
---|
| 957 | VspOspViewCellsManager(VspTree *tree, OspTree *ospTree);
|
---|
| 958 | ~VspOspViewCellsManager();
|
---|
| 959 |
|
---|
| 960 | int ConstructSubdivision(const ObjectContainer &objects,
|
---|
| 961 | const VssRayContainer &rays);
|
---|
| 962 |
|
---|
| 963 | int PostProcess(const ObjectContainer &objects,
|
---|
| 964 | const VssRayContainer &rays);
|
---|
| 965 |
|
---|
| 966 | void Visualize(const ObjectContainer &objects,
|
---|
| 967 | const VssRayContainer &sampleRays);
|
---|
| 968 |
|
---|
| 969 | int GetType() const;
|
---|
| 970 |
|
---|
| 971 | ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 972 |
|
---|
| 973 | bool ViewCellsConstructed() const;
|
---|
| 974 |
|
---|
| 975 |
|
---|
| 976 | int CastLineSegment(const Vector3 &origin,
|
---|
| 977 | const Vector3 &termination,
|
---|
| 978 | ViewCellContainer &viewcells);
|
---|
| 979 |
|
---|
| 980 | float GetProbability(ViewCell *viewCell);
|
---|
| 981 |
|
---|
| 982 | ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
|
---|
| 983 |
|
---|
| 984 | bool GetViewPoint(Vector3 &viewPoint) const;
|
---|
| 985 |
|
---|
| 986 | bool ViewPointValid(const Vector3 &viewPoint) const;
|
---|
| 987 |
|
---|
| 988 | void CreateMesh(ViewCell *vc);
|
---|
| 989 |
|
---|
[1027] | 990 | bool ExportViewCells(const string filename,
|
---|
| 991 | const bool exportPvs,
|
---|
| 992 | const ObjectContainer &objects);
|
---|
[1021] | 993 |
|
---|
| 994 | int CastBeam(Beam &beam);
|
---|
| 995 |
|
---|
| 996 | void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
| 997 |
|
---|
| 998 |
|
---|
| 999 | protected:
|
---|
| 1000 |
|
---|
[1027] | 1001 |
|
---|
| 1002 | /** Exports view cell geometry.
|
---|
| 1003 | */
|
---|
| 1004 | void ExportViewCellGeometry(Exporter *exporter,
|
---|
[1074] | 1005 | ViewCell *vc,
|
---|
| 1006 | const AxisAlignedPlane *clipPlane = NULL) const;
|
---|
[1027] | 1007 |
|
---|
[1074] | 1008 | int ComputeBoxIntersections(const AxisAlignedBox3 &box,
|
---|
| 1009 | ViewCellContainer &viewCells) const;
|
---|
[1021] | 1010 |
|
---|
| 1011 | void CollectViewCells();
|
---|
| 1012 |
|
---|
| 1013 |
|
---|
| 1014 | /** Prepare view cells for use after loading them from disc.
|
---|
| 1015 | */
|
---|
| 1016 | void PrepareLoadedViewCells();
|
---|
| 1017 |
|
---|
| 1018 | /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
|
---|
| 1019 | */
|
---|
| 1020 | ViewCell *ConstructSpatialMergeTree(VspNode *root);
|
---|
| 1021 |
|
---|
| 1022 | void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);
|
---|
| 1023 |
|
---|
[1074] | 1024 | /** Exports visualization of the PVS.
|
---|
[442] | 1025 | */
|
---|
[1074] | 1026 | void ExportPvs(const ObjectContainer &objects,
|
---|
| 1027 | const VssRayContainer &rays);
|
---|
[442] | 1028 |
|
---|
[1021] | 1029 |
|
---|
| 1030 | /// the view space partition tree.
|
---|
| 1031 | VspTree *mVspTree;
|
---|
| 1032 | OspTree *mOspTree;
|
---|
[1027] | 1033 |
|
---|
| 1034 | HierarchyManager *mHierarchyManager;
|
---|
[442] | 1035 | };
|
---|
| 1036 |
|
---|
[575] | 1037 |
|
---|
[1002] | 1038 | /*class ViewCellsManagerFactory
|
---|
[575] | 1039 | {
|
---|
| 1040 | public:
|
---|
| 1041 | ViewCellsManager *Create(const string mName);
|
---|
[1002] | 1042 | };*/
|
---|
[575] | 1043 |
|
---|
[860] | 1044 | }
|
---|
| 1045 |
|
---|
[440] | 1046 | #endif
|
---|