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

Revision 411, 2.2 KB checked in by mattausch, 19 years ago (diff)

worked on view space partition kd tree

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        ViewCellPvs &GetPvs();
28
29        int Type() const;
30
31        /** Derives viewcells from object container.
32                @param objects the intersectables the viewcells are derived from
33                @param viewCells the viewcells are returned in this container
34                @param maxViewCells the maximum number of viewcells created. if 0 => unbounded
35        */
36        static void DeriveViewCells(const ObjectContainer &objects,
37                                                                ViewCellContainer &viewCells,
38                                                                const int maxViewCells);
39
40       
41        /** Adds a passing ray to the passing ray container.
42        */
43        void AddPassingRay(const Ray &ray, const int contributions);   
44
45        /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector.
46                @param the base triangle
47                @param the height of the newly created view cell
48        */
49        static ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height);
50
51        /** Merges two view cells.
52                @note the piercing rays of the front and back will be ordered   
53                @returns new view cell based on the merging.
54        */
55        static ViewCell *Merge(ViewCell &front, ViewCell &back);
56
57        /// Ray set description of the rays passing through this node. 
58        PassingRaySet mPassingRays;
59
60        /// Rays piercing this view cell.
61        RayContainer mPiercingRays;
62
63        /// view cells types
64        enum HierarchyType {BSP, KD, VSP};
65
66        /** Generates view cells of type specified by view cells type.
67        */
68        static ViewCell *Generate(Mesh *mesh = NULL);
69
70        /// type of view cells hierarchy (KD, BSP)
71        static HierarchyType sHierarchy;
72
73protected:
74
75        /// the potentially visible objects
76        ViewCellPvs mPvs;
77};
78
79class BspViewCell: public ViewCell
80{
81public:
82        BspViewCell(): mBspLeaves(0) {}
83        BspViewCell(Mesh *mesh):
84        ViewCell(mesh), mBspLeaves(0) {}
85
86        /// Leaves which hold this view cell.
87        vector<BspLeaf *> mBspLeaves;
88};
89
90#endif
Note: See TracBrowser for help on using the repository browser.