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