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