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