[372] | 1 | #ifndef _ViewCell_H__
|
---|
| 2 | #define _ViewCell_H__
|
---|
| 3 |
|
---|
| 4 | #include "Mesh.h"
|
---|
| 5 | #include "Containers.h"
|
---|
| 6 | #include "Ray.h"
|
---|
| 7 |
|
---|
| 8 | //namespace GtpVisibilityPreprocessor {
|
---|
| 9 |
|
---|
| 10 | class BspInterior;
|
---|
| 11 | class BspPvs;
|
---|
| 12 | struct Triangle3;
|
---|
| 13 | class BspLeaf;
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | View cell with an optional mesh representation
|
---|
| 17 | */
|
---|
| 18 | class ViewCell: public MeshInstance
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
| 21 | ViewCell();
|
---|
| 22 | /** Constructor taking a mesh representing the shape of the viewcell.
|
---|
| 23 | */
|
---|
| 24 | ViewCell(Mesh *mesh);
|
---|
[419] | 25 | /** Returns Pvs.
|
---|
[372] | 26 | */
|
---|
[419] | 27 | const ViewCellPvs &GetPvs() const;
|
---|
[372] | 28 | ViewCellPvs &GetPvs();
|
---|
| 29 |
|
---|
| 30 | int Type() const;
|
---|
| 31 |
|
---|
| 32 | /** Derives viewcells from object container.
|
---|
| 33 | @param objects the intersectables the viewcells are derived from
|
---|
| 34 | @param viewCells the viewcells are returned in this container
|
---|
| 35 | @param maxViewCells the maximum number of viewcells created. if 0 => unbounded
|
---|
| 36 | */
|
---|
| 37 | static void DeriveViewCells(const ObjectContainer &objects,
|
---|
[411] | 38 | ViewCellContainer &viewCells,
|
---|
| 39 | const int maxViewCells);
|
---|
[372] | 40 |
|
---|
| 41 |
|
---|
| 42 | /** Adds a passing ray to the passing ray container.
|
---|
| 43 | */
|
---|
| 44 | void AddPassingRay(const Ray &ray, const int contributions);
|
---|
| 45 |
|
---|
| 46 | /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector.
|
---|
| 47 | @param the base triangle
|
---|
| 48 | @param the height of the newly created view cell
|
---|
| 49 | */
|
---|
| 50 | static ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height);
|
---|
| 51 |
|
---|
| 52 | /** Merges two view cells.
|
---|
| 53 | @note the piercing rays of the front and back will be ordered
|
---|
| 54 | @returns new view cell based on the merging.
|
---|
| 55 | */
|
---|
| 56 | static ViewCell *Merge(ViewCell &front, ViewCell &back);
|
---|
| 57 |
|
---|
| 58 | /// Ray set description of the rays passing through this node.
|
---|
| 59 | PassingRaySet mPassingRays;
|
---|
| 60 |
|
---|
| 61 | /// Rays piercing this view cell.
|
---|
| 62 | RayContainer mPiercingRays;
|
---|
| 63 |
|
---|
| 64 | /// view cells types
|
---|
[411] | 65 | enum HierarchyType {BSP, KD, VSP};
|
---|
[372] | 66 |
|
---|
| 67 | /** Generates view cells of type specified by view cells type.
|
---|
| 68 | */
|
---|
| 69 | static ViewCell *Generate(Mesh *mesh = NULL);
|
---|
| 70 |
|
---|
| 71 | /// type of view cells hierarchy (KD, BSP)
|
---|
| 72 | static HierarchyType sHierarchy;
|
---|
| 73 |
|
---|
| 74 | protected:
|
---|
| 75 |
|
---|
| 76 | /// the potentially visible objects
|
---|
| 77 | ViewCellPvs mPvs;
|
---|
| 78 | };
|
---|
| 79 |
|
---|
[366] | 80 | class BspViewCell: public ViewCell
|
---|
| 81 | {
|
---|
| 82 | public:
|
---|
| 83 | BspViewCell(): mBspLeaves(0) {}
|
---|
| 84 | BspViewCell(Mesh *mesh):
|
---|
| 85 | ViewCell(mesh), mBspLeaves(0) {}
|
---|
| 86 |
|
---|
| 87 | /// Leaves which hold this view cell.
|
---|
[372] | 88 | vector<BspLeaf *> mBspLeaves;
|
---|
| 89 | };
|
---|
| 90 |
|
---|
| 91 | #endif
|
---|