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