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