#ifndef _ViewCell_H__ #define _ViewCell_H__ #include "Mesh.h" #include "Containers.h" #include "Ray.h" //namespace GtpVisibilityPreprocessor { class BspInterior; class BspPvs; struct Triangle3; class BspLeaf; /** View cell with an optional mesh representation */ class ViewCell: public MeshInstance { public: ViewCell(); /** Constructor taking a mesh representing the shape of the viewcell. */ ViewCell(Mesh *mesh); /** Returns PvS. */ ViewCellPvs &GetPvs(); int Type() const; /** Derives viewcells from object container. @param objects the intersectables the viewcells are derived from @param viewCells the viewcells are returned in this container @param maxViewCells the maximum number of viewcells created. if 0 => unbounded */ static void DeriveViewCells(const ObjectContainer &objects, ViewCellContainer &viewCells, const int maxViewCells); /** Adds a passing ray to the passing ray container. */ void AddPassingRay(const Ray &ray, const int contributions); /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector. @param the base triangle @param the height of the newly created view cell */ static ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height); /** Merges two view cells. @note the piercing rays of the front and back will be ordered @returns new view cell based on the merging. */ static ViewCell *Merge(ViewCell &front, ViewCell &back); /// Ray set description of the rays passing through this node. PassingRaySet mPassingRays; /// Rays piercing this view cell. RayContainer mPiercingRays; /// view cells types enum HierarchyType {BSP, KD}; /** Generates view cells of type specified by view cells type. */ static ViewCell *Generate(Mesh *mesh = NULL); /// type of view cells hierarchy (KD, BSP) static HierarchyType sHierarchy; protected: /// the potentially visible objects ViewCellPvs mPvs; }; class BspViewCell: public ViewCell { public: BspViewCell(): mBspLeaves(0) {} BspViewCell(Mesh *mesh): ViewCell(mesh), mBspLeaves(0) {} /// Leaves which hold this view cell. vector mBspLeaves; }; #endif