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