[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"
|
---|
[440] | 8 |
|
---|
| 9 | class ViewCell;
|
---|
| 10 | class Intersectable;
|
---|
| 11 | class RenderSimulator;
|
---|
[480] | 12 | class Renderer;
|
---|
[440] | 13 | class Mesh;
|
---|
| 14 | struct Triangle3;
|
---|
| 15 | class SimulationStatistics;
|
---|
| 16 | class BspTree;
|
---|
| 17 | class KdTree;
|
---|
| 18 | class VspKdTree;
|
---|
| 19 | class VspBspTree;
|
---|
| 20 | class KdNode;
|
---|
| 21 | class KdLeaf;
|
---|
| 22 | class VspKdTree;
|
---|
| 23 | class AxisAlignedBox3;
|
---|
[448] | 24 | class BspLeaf;
|
---|
[475] | 25 | class ViewCellsStatistics;
|
---|
[482] | 26 | class Exporter;
|
---|
[532] | 27 | class Beam;
|
---|
[503] | 28 |
|
---|
[475] | 29 | struct BspRay;
|
---|
| 30 |
|
---|
[440] | 31 | /**
|
---|
| 32 | Manages different higher order operations on the view cells.
|
---|
| 33 | */
|
---|
| 34 | class ViewCellsManager
|
---|
| 35 | {
|
---|
| 36 |
|
---|
| 37 | public:
|
---|
[467] | 38 | struct PvsStatistics {
|
---|
| 39 | int minPvs;
|
---|
| 40 | int maxPvs;
|
---|
| 41 | float avgPvs;
|
---|
| 42 | int viewcells;
|
---|
| 43 | };
|
---|
[466] | 44 |
|
---|
| 45 | /// view cell container types
|
---|
| 46 | enum {BSP, KD, VSP_KD, VSP_BSP};
|
---|
| 47 |
|
---|
[440] | 48 | /** Constructor taking the maximal number of samples used for construction
|
---|
| 49 | */
|
---|
| 50 | ViewCellsManager(const int constructionSamples);
|
---|
| 51 |
|
---|
| 52 | ViewCellsManager();
|
---|
| 53 |
|
---|
[462] | 54 | virtual ~ViewCellsManager();
|
---|
[440] | 55 |
|
---|
[527] | 56 | /** Constructs view cells container taking a preprocessor
|
---|
| 57 | @returns construction rays.
|
---|
| 58 | */
|
---|
| 59 | int Construct(VssRayContainer &rays);
|
---|
| 60 |
|
---|
[440] | 61 | /** Constructs view cell container with a given number of samples.
|
---|
| 62 | */
|
---|
| 63 | virtual int Construct(const ObjectContainer &objects,
|
---|
[487] | 64 | const VssRayContainer &rays) = 0;
|
---|
[440] | 65 |
|
---|
[441] | 66 | /** Computes sample contributions of the rays to the view cells PVS.
|
---|
| 67 |
|
---|
| 68 | @param rays bundle of rays used to find intersections with view cells and
|
---|
| 69 | adding the contribution
|
---|
| 70 | @param castRays true if ray should be cast to gain the information, false if rays
|
---|
| 71 | already hold the view cells intersection information and need not be recast.
|
---|
| 72 | @param sampleContributions returns the number of sample contributions
|
---|
| 73 | @param contributingSamples returns the number of contributingSamples
|
---|
[440] | 74 | */
|
---|
[475] | 75 | void ComputeSampleContributions(const VssRayContainer &rays);
|
---|
[440] | 76 |
|
---|
[441] | 77 |
|
---|
[475] | 78 | /** Computes sample contribution of a simgle ray to the view cells PVS.
|
---|
| 79 | @param ray finds intersections with view cells and holds the contribution
|
---|
| 80 | @param castRay true if ray should be cast to gain the information, false if ray
|
---|
| 81 | is already holding the information and need not be recast.
|
---|
[466] | 82 |
|
---|
[475] | 83 | @returns number of sample contributions
|
---|
| 84 | */
|
---|
| 85 | virtual void ComputeSampleContributions(VssRay &ray);
|
---|
[466] | 86 |
|
---|
[452] | 87 | /** Prints out statistics of the view cells.
|
---|
| 88 | */
|
---|
[475] | 89 | virtual void PrintStatistics(ostream &s) const;
|
---|
[452] | 90 |
|
---|
[440] | 91 | /** Post processes view cells givemŽa number of rays.
|
---|
| 92 | */
|
---|
[475] | 93 | virtual int PostProcess(const ObjectContainer &objects,
|
---|
| 94 | const VssRayContainer &rays) = 0;
|
---|
[440] | 95 |
|
---|
| 96 | /** Show visualization of the view cells.
|
---|
| 97 | */
|
---|
| 98 | virtual void Visualize(const ObjectContainer &objects,
|
---|
[466] | 99 | const VssRayContainer &sampleRays) = 0;
|
---|
[440] | 100 |
|
---|
| 101 | /** type of the view cell container.
|
---|
| 102 | */
|
---|
| 103 | virtual int GetType() const = 0;
|
---|
| 104 |
|
---|
[463] | 105 | /** Load the input viewcells. The input viewcells should be given as a collection
|
---|
| 106 | of meshes. Each mesh is assume to form a bounded polyhedron defining the interior of
|
---|
| 107 | the viewcell. The method then builds a BSP tree of these view cells.
|
---|
| 108 |
|
---|
| 109 | @param filename file to load
|
---|
| 110 | @return true on success
|
---|
| 111 | */
|
---|
[508] | 112 | virtual bool LoadViewCells(const string filename, ObjectContainer *objects);
|
---|
[440] | 113 |
|
---|
| 114 | /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector.
|
---|
| 115 | @param the base triangle
|
---|
| 116 | @param the height of the newly created view cell
|
---|
| 117 | */
|
---|
| 118 | ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const;
|
---|
| 119 |
|
---|
| 120 | /** Merges two view cells.
|
---|
| 121 | @note the piercing rays of the front and back will be ordered
|
---|
| 122 | @returns new view cell based on the merging.
|
---|
| 123 | */
|
---|
[441] | 124 | ViewCell *MergeViewCells(ViewCell &front, ViewCell &back) const;
|
---|
[440] | 125 |
|
---|
| 126 | /** Generates view cell of type specified by this manager
|
---|
| 127 | */
|
---|
| 128 | virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 129 |
|
---|
| 130 | /** Adds a new view cell to the list of predefined view cells.
|
---|
| 131 | */
|
---|
| 132 | void AddViewCell(ViewCell *viewCell);
|
---|
| 133 |
|
---|
| 134 | /** Derive view cells from objects.
|
---|
| 135 | */
|
---|
| 136 | void DeriveViewCells(const ObjectContainer &objects,
|
---|
| 137 | ViewCellContainer &viewCells,
|
---|
| 138 | const int maxViewCells) const;
|
---|
| 139 |
|
---|
| 140 | /** Sets maximal number of samples used for the
|
---|
| 141 | construction of the view cells.
|
---|
| 142 | */
|
---|
| 143 | void SetVisualizationSamples(const int visSamples);
|
---|
| 144 |
|
---|
| 145 | /** Sets maximal number of samples used for the visualization of the view cells.
|
---|
| 146 | */
|
---|
| 147 | void SetConstructionSamples(const int constructionSamples);
|
---|
| 148 |
|
---|
| 149 | /** Sets maximal number of samples used for the post processing of the view cells.
|
---|
| 150 | */
|
---|
| 151 | void SetPostProcessSamples(const int postProcessingSamples);
|
---|
| 152 |
|
---|
| 153 | /** See set.
|
---|
| 154 | */
|
---|
| 155 | int GetVisualizationSamples() const;
|
---|
| 156 |
|
---|
| 157 | /** See set.
|
---|
| 158 | */
|
---|
| 159 | int GetConstructionSamples() const;
|
---|
| 160 |
|
---|
| 161 | /** See set.
|
---|
| 162 | */
|
---|
| 163 | int GetPostProcessSamples() const;
|
---|
| 164 |
|
---|
| 165 | /** Returns true if view cells wer already constructed.
|
---|
| 166 | */
|
---|
| 167 | virtual bool ViewCellsConstructed() const = 0;
|
---|
[441] | 168 |
|
---|
[477] | 169 | /** cast line segment to get a list of unique viewcells which are intersected
|
---|
| 170 | by this line segment
|
---|
| 171 | */
|
---|
[466] | 172 |
|
---|
[477] | 173 | virtual int CastLineSegment(const Vector3 &origin,
|
---|
[466] | 174 | const Vector3 &termination,
|
---|
| 175 | ViewCellContainer &viewcells
|
---|
| 176 | ) = 0;
|
---|
| 177 |
|
---|
[477] | 178 | virtual void GetPvsStatistics(PvsStatistics &stat);
|
---|
[466] | 179 |
|
---|
[503] | 180 | /** Get a viewcell containing the specified point */
|
---|
| 181 | virtual ViewCell *GetViewCell(const Vector3 &point) = 0;
|
---|
[492] | 182 |
|
---|
[503] | 183 | virtual void PrintPvsStatistics(ostream &s);
|
---|
[467] | 184 |
|
---|
[477] | 185 | /** Returns probability that view point lies in one view cell.
|
---|
| 186 | */
|
---|
| 187 | virtual float GetProbability(ViewCell *viewCell) = 0;
|
---|
[468] | 188 |
|
---|
[477] | 189 | /** Returns render cost of a single view cell given the render cost of an object.
|
---|
| 190 | */
|
---|
| 191 | virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const = 0;
|
---|
[468] | 192 |
|
---|
[477] | 193 | /** Returns vector of loaded / generated view cells.
|
---|
| 194 | */
|
---|
| 195 | ViewCellContainer &GetViewCells();
|
---|
[468] | 196 |
|
---|
[485] | 197 | /** Helper function used to split ray sets uniformly
|
---|
| 198 | into one that is currently used and the other that
|
---|
| 199 | is saved for later processing.
|
---|
| 200 | @param sourceRays the input ray set
|
---|
| 201 | @param maxSize the maximal number of rays that will be used
|
---|
| 202 | @param usedRays returns the used ray set
|
---|
| 203 | @param savedRays if not null, returns the saved ray set
|
---|
[477] | 204 | */
|
---|
| 205 | void GetRaySets(const VssRayContainer &sourceRays,
|
---|
[485] | 206 | const int maxSize,
|
---|
| 207 | VssRayContainer &usedRays,
|
---|
| 208 | VssRayContainer *savedRays = NULL) const;
|
---|
| 209 |
|
---|
[480] | 210 | /** Returns accumulated area of all view cells.
|
---|
| 211 | */
|
---|
| 212 | float GetAccVcArea();
|
---|
[470] | 213 |
|
---|
[480] | 214 | /** Returns area of one view cell.
|
---|
| 215 | */
|
---|
| 216 | virtual float GetArea(ViewCell *viewCell) const;
|
---|
[470] | 217 |
|
---|
[551] | 218 | /** Returns volume of view cell.
|
---|
[480] | 219 | */
|
---|
| 220 | virtual float GetVolume(ViewCell *viewCell) const;
|
---|
[470] | 221 |
|
---|
[480] | 222 | /** Sets the current renderer mainly for view cells statistics.
|
---|
| 223 | */
|
---|
| 224 | void SetRenderer(Renderer *renderer);
|
---|
| 225 |
|
---|
[487] | 226 | /** Computes a (random) view point in the valid view space.
|
---|
| 227 | @returns true if valid view point was found
|
---|
| 228 | */
|
---|
| 229 | virtual bool GetViewPoint(Vector3 &viewPoint) const;
|
---|
| 230 |
|
---|
[490] | 231 | /** Returns true if this view point is in the valid view space.
|
---|
| 232 | */
|
---|
| 233 | virtual bool ViewPointValid(const Vector3 &viewPoint) const;
|
---|
| 234 |
|
---|
[487] | 235 | /** Sets a view space boundary.
|
---|
| 236 | */
|
---|
| 237 | void SetViewSpaceBox(const AxisAlignedBox3 &box);
|
---|
| 238 |
|
---|
[519] | 239 | AxisAlignedBox3 GetViewSpaceBox() const;
|
---|
| 240 |
|
---|
[503] | 241 | /** Creates mesh for this view cell.
|
---|
| 242 | */
|
---|
| 243 | virtual void CreateMesh(ViewCell *vc) = NULL;
|
---|
[487] | 244 |
|
---|
[508] | 245 | /** Writes view cells to disc.
|
---|
| 246 | */
|
---|
| 247 | virtual bool ExportViewCells(const string filename);
|
---|
| 248 |
|
---|
[532] | 249 | /** Casts beam to collect view cells.
|
---|
| 250 | */
|
---|
| 251 | virtual int CastBeam(Beam &beam);
|
---|
| 252 |
|
---|
[547] | 253 | /** Checks if view cell is considered as valid.
|
---|
| 254 | */
|
---|
[561] | 255 | virtual bool CheckValidity(ViewCell *vc,
|
---|
| 256 | float minPvsRatio,
|
---|
| 257 | float maxPvsRatio) const;
|
---|
[547] | 258 |
|
---|
| 259 | /** Returns maximal allowed pvs size.
|
---|
| 260 | */
|
---|
| 261 | int GetMaxPvsSize() const;
|
---|
| 262 |
|
---|
[561] | 263 | /** Returns maximal ratio. i.e., currentPVs / maxPvs,
|
---|
| 264 | where pvs is still considered valid.
|
---|
| 265 | */
|
---|
| 266 | float GetMaxPvsRatio() const;
|
---|
| 267 |
|
---|
[547] | 268 | /** Exports view cell geometry.
|
---|
| 269 | */
|
---|
| 270 | virtual void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const = 0;
|
---|
| 271 |
|
---|
[551] | 272 | virtual void FinalizeViewCells(const bool createMesh);
|
---|
| 273 |
|
---|
[469] | 274 | protected:
|
---|
[480] | 275 |
|
---|
[482] | 276 | void ParseEnvironment();
|
---|
| 277 |
|
---|
[508] | 278 | /** Creates unique view cell ids.
|
---|
| 279 | */
|
---|
| 280 | void CreateUniqueViewCellIds();
|
---|
[547] | 281 |
|
---|
[551] | 282 | /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell.
|
---|
| 283 | */
|
---|
| 284 | virtual void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
| 285 |
|
---|
[480] | 286 | /** Recollects view cells and resets statistics.
|
---|
| 287 | */
|
---|
| 288 | void ResetViewCells();
|
---|
[482] | 289 |
|
---|
[480] | 290 | /** Collects the view cells in the view cell container.
|
---|
| 291 | */
|
---|
| 292 | virtual void CollectViewCells() = 0;
|
---|
[482] | 293 |
|
---|
[479] | 294 | /** Evaluates view cells statistics and stores it in
|
---|
| 295 | mViewCellsStatistics.
|
---|
| 296 | */
|
---|
| 297 | void EvaluateViewCellsStats();
|
---|
[482] | 298 |
|
---|
| 299 | //-- helper functions for view cell visualization
|
---|
| 300 |
|
---|
| 301 | /** Exports the view cell partition.
|
---|
| 302 | */
|
---|
[508] | 303 | void ExportViewCellsForViz(Exporter *exporter) const;
|
---|
[482] | 304 |
|
---|
| 305 | /** Sets exporter color.
|
---|
| 306 | */
|
---|
| 307 | virtual void ExportColor(Exporter *exporter, ViewCell *vc) const = 0;
|
---|
| 308 |
|
---|
[556] | 309 |
|
---|
[557] | 310 | virtual float GetViewSpaceVolume();
|
---|
| 311 |
|
---|
[503] | 312 | /** Creates meshes from the view cells.
|
---|
| 313 | */
|
---|
[517] | 314 | void CreateViewCellMeshes();
|
---|
[503] | 315 |
|
---|
[508] | 316 | /**
|
---|
| 317 | Exports single view cell.
|
---|
| 318 | NOTE: should be in exporter!!
|
---|
| 319 | */
|
---|
| 320 | void ExportViewCell(ViewCell *viewCell, ofstream &stream);
|
---|
| 321 |
|
---|
[489] | 322 | /// the view cell corresponding to space ouside the valid view space
|
---|
| 323 | //ViewCell *mOutOfBoundsCell;
|
---|
[440] | 324 |
|
---|
[480] | 325 | /// Renders the view cells.
|
---|
| 326 | Renderer *mRenderer;
|
---|
[440] | 327 |
|
---|
| 328 | /// Loaded view cells
|
---|
[469] | 329 | ViewCellContainer mViewCells;
|
---|
[440] | 330 |
|
---|
| 331 | /// maximum number of samples taken for construction of the view cells
|
---|
| 332 | int mConstructionSamples;
|
---|
| 333 | int mPostProcessSamples;
|
---|
| 334 | int mVisualizationSamples;
|
---|
[441] | 335 |
|
---|
[470] | 336 | float mTotalAreaValid;
|
---|
| 337 | float mTotalArea;
|
---|
[475] | 338 |
|
---|
[547] | 339 | int mMaxPvsSize;
|
---|
| 340 | float mMaxPvsRatio;
|
---|
| 341 |
|
---|
[475] | 342 | ViewCellsStatistics mViewCellsStats;
|
---|
[487] | 343 | /// the scene bounding box
|
---|
[542] | 344 | AxisAlignedBox3 mViewSpaceBox;
|
---|
[508] | 345 | /// holds the view cell meshes
|
---|
[503] | 346 | MeshContainer mMeshContainer;
|
---|
[508] | 347 | /// if view cells should be exported
|
---|
| 348 | bool mExportViewCells;
|
---|
[547] | 349 |
|
---|
| 350 |
|
---|
[487] | 351 | //-- visualization options
|
---|
| 352 |
|
---|
| 353 | /// color code for view cells
|
---|
| 354 | int mColorCode;
|
---|
| 355 | bool mExportGeometry;
|
---|
| 356 | bool mExportRays;
|
---|
[517] | 357 |
|
---|
| 358 | bool mViewCellsFinished;
|
---|
[440] | 359 | };
|
---|
| 360 |
|
---|
[441] | 361 |
|
---|
| 362 |
|
---|
[440] | 363 | /**
|
---|
| 364 | Manages different higher order operations on the view cells.
|
---|
| 365 | */
|
---|
| 366 | class BspViewCellsManager: public ViewCellsManager
|
---|
| 367 | {
|
---|
| 368 |
|
---|
| 369 | public:
|
---|
[485] | 370 | /** Constructor taking the bsp tree and the number of samples
|
---|
| 371 | used to construct the bsp tree.
|
---|
| 372 | */
|
---|
[440] | 373 | BspViewCellsManager(BspTree *tree, int constructionSamples);
|
---|
| 374 |
|
---|
[477] | 375 | ~BspViewCellsManager();
|
---|
| 376 |
|
---|
[440] | 377 | int Construct(const ObjectContainer &objects,
|
---|
[487] | 378 | const VssRayContainer &rays);
|
---|
[440] | 379 |
|
---|
| 380 |
|
---|
| 381 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 382 | const VssRayContainer &rays);
|
---|
[440] | 383 |
|
---|
| 384 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 385 | const VssRayContainer &sampleRays);
|
---|
[440] | 386 |
|
---|
| 387 | int GetType() const;
|
---|
| 388 |
|
---|
| 389 | ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 390 |
|
---|
| 391 | bool ViewCellsConstructed() const;
|
---|
| 392 |
|
---|
[475] | 393 | //void PrintStatistics(ostream &s) const;
|
---|
[452] | 394 |
|
---|
[468] | 395 | int CastLineSegment(const Vector3 &origin,
|
---|
| 396 | const Vector3 &termination,
|
---|
| 397 | ViewCellContainer &viewcells);
|
---|
| 398 |
|
---|
[471] | 399 | float GetProbability(ViewCell *viewCell);
|
---|
[469] | 400 | float GetRendercost(ViewCell *viewCell, float objRendercost) const;
|
---|
[466] | 401 |
|
---|
[503] | 402 | /** Get a viewcell containing the specified point */
|
---|
| 403 | ViewCell *GetViewCell(const Vector3 &point);
|
---|
[492] | 404 |
|
---|
[503] | 405 | void CreateMesh(ViewCell *vc);
|
---|
| 406 |
|
---|
[547] | 407 | void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
|
---|
| 408 |
|
---|
[440] | 409 | protected:
|
---|
| 410 |
|
---|
[480] | 411 | void CollectViewCells();
|
---|
| 412 |
|
---|
[477] | 413 | void ConstructBspRays(const VssRayContainer &rays,
|
---|
| 414 | const int numSamples);
|
---|
[482] | 415 |
|
---|
| 416 | void ExportColor(Exporter *exporter, ViewCell *vc) const;
|
---|
[547] | 417 |
|
---|
[482] | 418 |
|
---|
[547] | 419 |
|
---|
[440] | 420 | /// the BSP tree.
|
---|
| 421 | BspTree *mBspTree;
|
---|
[475] | 422 |
|
---|
| 423 | vector<BspRay *> mBspRays;
|
---|
[440] | 424 |
|
---|
| 425 | private:
|
---|
| 426 |
|
---|
| 427 | /** Exports visualization of the BSP splits.
|
---|
| 428 | */
|
---|
[477] | 429 | void ExportSplits(const ObjectContainer &objects);
|
---|
[440] | 430 |
|
---|
| 431 | /** Exports visualization of the BSP PVS.
|
---|
| 432 | */
|
---|
[477] | 433 | void ExportBspPvs(const ObjectContainer &objects);
|
---|
[440] | 434 |
|
---|
| 435 | };
|
---|
| 436 |
|
---|
| 437 | /**
|
---|
| 438 | Manages different higher order operations on the KD type view cells.
|
---|
| 439 | */
|
---|
| 440 | class KdViewCellsManager: public ViewCellsManager
|
---|
| 441 | {
|
---|
| 442 |
|
---|
| 443 | public:
|
---|
| 444 |
|
---|
| 445 | KdViewCellsManager(KdTree *tree);
|
---|
| 446 |
|
---|
| 447 | int Construct(const ObjectContainer &objects,
|
---|
[487] | 448 | const VssRayContainer &rays);
|
---|
[440] | 449 |
|
---|
[478] | 450 | int CastLineSegment(const Vector3 &origin,
|
---|
| 451 | const Vector3 &termination,
|
---|
| 452 | ViewCellContainer &viewcells);
|
---|
[440] | 453 |
|
---|
| 454 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 455 | const VssRayContainer &rays);
|
---|
[440] | 456 |
|
---|
| 457 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 458 | const VssRayContainer &sampleRays);
|
---|
[440] | 459 |
|
---|
| 460 | int GetType() const;
|
---|
| 461 |
|
---|
| 462 | bool ViewCellsConstructed() const;
|
---|
| 463 |
|
---|
| 464 |
|
---|
[452] | 465 | /** Prints out statistics of this approach.
|
---|
| 466 | */
|
---|
[503] | 467 | // virtual void PrintStatistics(ostream &s) const;
|
---|
| 468 | ViewCell *GetViewCell(const Vector3 &point) { return NULL; }
|
---|
[452] | 469 |
|
---|
[503] | 470 | float GetProbability(ViewCell *viewCell);
|
---|
| 471 | float GetRendercost(ViewCell *viewCell, float objRendercost) const;
|
---|
[468] | 472 |
|
---|
[503] | 473 | void CreateMesh(ViewCell *vc);
|
---|
| 474 |
|
---|
[547] | 475 | void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
|
---|
| 476 |
|
---|
[440] | 477 | protected:
|
---|
| 478 |
|
---|
[480] | 479 | void CollectViewCells();
|
---|
| 480 | KdNode *GetNodeForPvs(KdLeaf *leaf);
|
---|
[440] | 481 |
|
---|
[482] | 482 | void ExportColor(Exporter *exporter, ViewCell *vc) const;
|
---|
[440] | 483 |
|
---|
[547] | 484 |
|
---|
[480] | 485 | /// the BSP tree.
|
---|
| 486 | KdTree *mKdTree;
|
---|
[440] | 487 |
|
---|
[480] | 488 | /// depth of the KD tree nodes with represent the view cells
|
---|
| 489 | int mKdPvsDepth;
|
---|
[440] | 490 | };
|
---|
| 491 |
|
---|
| 492 | /**
|
---|
| 493 | Manages different higher order operations on the view cells
|
---|
| 494 | for vsp kd tree view cells.
|
---|
| 495 | */
|
---|
| 496 | class VspKdViewCellsManager: public ViewCellsManager
|
---|
| 497 | {
|
---|
| 498 |
|
---|
| 499 | public:
|
---|
| 500 |
|
---|
| 501 | VspKdViewCellsManager(VspKdTree *vspKdTree, int constructionSamples);
|
---|
| 502 |
|
---|
| 503 | int Construct(const ObjectContainer &objects,
|
---|
[487] | 504 | const VssRayContainer &rays);
|
---|
[440] | 505 |
|
---|
| 506 |
|
---|
| 507 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 508 | const VssRayContainer &rays);
|
---|
[440] | 509 |
|
---|
| 510 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 511 | const VssRayContainer &sampleRays);
|
---|
[440] | 512 |
|
---|
| 513 | int GetType() const;
|
---|
| 514 |
|
---|
| 515 | bool ViewCellsConstructed() const;
|
---|
| 516 |
|
---|
[475] | 517 | //virtual void PrintStatistics(ostream &s) const;
|
---|
[440] | 518 |
|
---|
[462] | 519 | ViewCell *GenerateViewCell(Mesh *mesh) const;
|
---|
| 520 |
|
---|
[466] | 521 |
|
---|
| 522 | int CastLineSegment(const Vector3 &origin,
|
---|
| 523 | const Vector3 &termination,
|
---|
[468] | 524 | ViewCellContainer &viewcells);
|
---|
[466] | 525 |
|
---|
[503] | 526 | ViewCell *GetViewCell(const Vector3 &point) { return NULL; }
|
---|
[492] | 527 |
|
---|
[471] | 528 | float GetProbability(ViewCell *viewCell);
|
---|
[469] | 529 | float GetRendercost(ViewCell *viewCell, float objRendercost) const;
|
---|
[468] | 530 |
|
---|
[503] | 531 | void CreateMesh(ViewCell *vc);
|
---|
| 532 |
|
---|
[547] | 533 | void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
|
---|
| 534 |
|
---|
[440] | 535 | protected:
|
---|
| 536 |
|
---|
[482] | 537 | void ExportLeaves(const ObjectContainer &objects,
|
---|
| 538 | const VssRayContainer &sampleRays);
|
---|
| 539 |
|
---|
[480] | 540 | void CollectViewCells();
|
---|
| 541 |
|
---|
[482] | 542 | void ExportColor(Exporter *exporter, ViewCell *vc) const;
|
---|
| 543 |
|
---|
| 544 |
|
---|
[547] | 545 |
|
---|
[440] | 546 | /// the BSP tree.
|
---|
| 547 | VspKdTree *mVspKdTree;
|
---|
| 548 | };
|
---|
| 549 |
|
---|
| 550 |
|
---|
[442] | 551 |
|
---|
| 552 | /**
|
---|
| 553 | Manages different higher order operations on the view cells.
|
---|
| 554 | */
|
---|
| 555 | class VspBspViewCellsManager: public ViewCellsManager
|
---|
| 556 | {
|
---|
| 557 |
|
---|
| 558 | public:
|
---|
| 559 |
|
---|
| 560 | VspBspViewCellsManager(VspBspTree *tree, int constructionSamples);
|
---|
[475] | 561 | ~VspBspViewCellsManager();
|
---|
[442] | 562 |
|
---|
| 563 | int Construct(const ObjectContainer &objects,
|
---|
[487] | 564 | const VssRayContainer &rays);
|
---|
[442] | 565 |
|
---|
| 566 | int PostProcess(const ObjectContainer &objects,
|
---|
[466] | 567 | const VssRayContainer &rays);
|
---|
[442] | 568 |
|
---|
| 569 | void Visualize(const ObjectContainer &objects,
|
---|
[466] | 570 | const VssRayContainer &sampleRays);
|
---|
[442] | 571 |
|
---|
| 572 | int GetType() const;
|
---|
| 573 |
|
---|
| 574 | ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
|
---|
| 575 |
|
---|
| 576 | bool ViewCellsConstructed() const;
|
---|
| 577 |
|
---|
[468] | 578 |
|
---|
| 579 | int CastLineSegment(const Vector3 &origin,
|
---|
| 580 | const Vector3 &termination,
|
---|
| 581 | ViewCellContainer &viewcells);
|
---|
[452] | 582 |
|
---|
[471] | 583 | float GetProbability(ViewCell *viewCell);
|
---|
[469] | 584 | float GetRendercost(ViewCell *viewCell, float objRendercost) const;
|
---|
[479] | 585 |
|
---|
[503] | 586 | ViewCell *GetViewCell(const Vector3 &point);
|
---|
[477] | 587 |
|
---|
[487] | 588 | bool GetViewPoint(Vector3 &viewPoint) const;
|
---|
| 589 |
|
---|
[490] | 590 | bool ViewPointValid(const Vector3 &viewPoint) const;
|
---|
[503] | 591 |
|
---|
| 592 | void CreateMesh(ViewCell *vc);
|
---|
| 593 |
|
---|
[508] | 594 | bool LoadViewCells(const string filename, ObjectContainer *objects);
|
---|
| 595 | bool ExportViewCells(const string filename);
|
---|
| 596 |
|
---|
[532] | 597 | int CastBeam(Beam &beam);
|
---|
| 598 |
|
---|
[547] | 599 | void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
|
---|
| 600 |
|
---|
[551] | 601 | //float GetVolume(ViewCell *viewCell) const;
|
---|
| 602 |
|
---|
[555] | 603 | void Finalize(ViewCell *viewCell, const bool createMesh);
|
---|
[551] | 604 |
|
---|
[442] | 605 | protected:
|
---|
[475] | 606 |
|
---|
[503] | 607 | /** Merges the view cells.
|
---|
[442] | 608 | */
|
---|
[508] | 609 | void MergeViewCells(const VssRayContainer &rays,
|
---|
| 610 | const ObjectContainer &objects);
|
---|
[503] | 611 |
|
---|
| 612 | void RefineViewCells(const VssRayContainer &rays);
|
---|
[442] | 613 |
|
---|
[480] | 614 | void CollectViewCells();
|
---|
| 615 |
|
---|
[482] | 616 | /** Returns maximal depth difference of view cell
|
---|
| 617 | leaves in tree.
|
---|
| 618 | */
|
---|
| 619 | int GetMaxTreeDiff(ViewCell *vc) const;
|
---|
[485] | 620 |
|
---|
[482] | 621 |
|
---|
[485] | 622 | void ExportColor(Exporter *exporter, ViewCell *vc) const;
|
---|
| 623 |
|
---|
[442] | 624 | /// the view space partition BSP tree.
|
---|
| 625 | VspBspTree *mVspBspTree;
|
---|
| 626 |
|
---|
| 627 | private:
|
---|
| 628 |
|
---|
| 629 | /** Exports visualization of the BSP splits.
|
---|
| 630 | */
|
---|
[485] | 631 | void ExportSplits(const ObjectContainer &objects,
|
---|
| 632 | const VssRayContainer &rays);
|
---|
[442] | 633 |
|
---|
| 634 | /** Exports visualization of the BSP PVS.
|
---|
| 635 | */
|
---|
[485] | 636 | void ExportBspPvs(const ObjectContainer &objects,
|
---|
| 637 | const VssRayContainer &rays);
|
---|
[442] | 638 |
|
---|
| 639 | };
|
---|
| 640 |
|
---|
[440] | 641 | #endif
|
---|