source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h @ 419

Revision 419, 2.3 KB checked in by mattausch, 19 years ago (diff)
Line 
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 
10class BspInterior;
11class BspPvs;
12struct Triangle3;
13class BspLeaf;
14
15/**
16        View cell with an optional mesh representation
17*/
18class ViewCell: public MeshInstance
19{
20public:
21        ViewCell();
22        /** Constructor taking a mesh representing the shape of the viewcell.
23        */
24        ViewCell(Mesh *mesh);
25        /** Returns Pvs.
26        */
27        const ViewCellPvs &GetPvs() const;
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,
38                                                                ViewCellContainer &viewCells,
39                                                                const int maxViewCells);
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
65        enum HierarchyType {BSP, KD, VSP};
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
74protected:
75
76        /// the potentially visible objects
77        ViewCellPvs mPvs;
78};
79
80class BspViewCell: public ViewCell
81{
82public:
83        BspViewCell(): mBspLeaves(0) {}
84        BspViewCell(Mesh *mesh):
85        ViewCell(mesh), mBspLeaves(0) {}
86
87        /// Leaves which hold this view cell.
88        vector<BspLeaf *> mBspLeaves;
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.