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

Revision 462, 2.5 KB checked in by mattausch, 19 years ago (diff)

worked on vsp kd view cells

Line 
1#ifndef _ViewCell_H__
2#define _ViewCell_H__
3
4#include "Mesh.h"
5#include "Containers.h"
6#include "Ray.h"
7#include "Statistics.h"
8//namespace GtpVisibilityPreprocessor {
9 
10class BspInterior;
11class BspPvs;
12struct Triangle3;
13class BspLeaf;
14class VspKdTree;
15class VspKdLeaf;
16
17
18/**
19        View cell with an optional mesh representation
20*/
21class ViewCell: public MeshInstance
22{
23public:
24        ViewCell();
25       
26        /** Constructor taking a mesh representing the shape of the viewcell.
27        */
28        ViewCell(Mesh *mesh);
29
30
31        virtual ~ViewCell() {}
32        /** Returns Pvs.
33        */
34        const ViewCellPvs &GetPvs() const;
35        ViewCellPvs &GetPvs();
36
37        int Type() const;
38       
39        /** Adds a passing ray to the passing ray container.
40        */
41        void AddPassingRay(const Ray &ray, const int contributions);   
42
43
44        /// Ray set description of the rays passing through this node. 
45        PassingRaySet mPassingRays;
46
47        /// Rays piercing this view cell.
48        RayContainer mPiercingRays;
49
50protected:
51
52        /// the potentially visible objects
53        ViewCellPvs mPvs;
54};
55
56class BspViewCell: public ViewCell
57{
58public:
59        BspViewCell(): mBspLeaves(0) {}
60        BspViewCell(Mesh *mesh):
61        ViewCell(mesh), mBspLeaves(0) {}
62
63        /// Leaves which hold this view cell.
64        vector<BspLeaf *> mBspLeaves;
65};
66
67class VspKdViewCell: public ViewCell
68{
69public:
70        VspKdViewCell(): mVspKdLeaves(0) {}
71        VspKdViewCell(Mesh *mesh):
72        ViewCell(mesh), mVspKdLeaves(0) {}
73
74        float GetSize() {return mSize;}
75        void SetSize(float size) {mSize = size;}
76
77        /// Leaves which hold this view cell.
78        vector<VspKdLeaf *> mVspKdLeaves;
79
80protected:
81        float mSize;
82};
83
84class ViewCellsStatistics: public StatisticsBase
85{
86public:
87
88        /// number of view cells
89        int viewCells;
90
91        /// size of the PVS
92        int pvs;
93 
94        /// largest PVS of all view cells
95        int maxPvs;
96
97        /// smallest PVS of all view cells
98        int minPvs;
99
100        /// view cells with empty PVS
101        int emptyPvs;
102
103        /// number of leaves covering the view space
104        int leaves;
105
106        /// largest number of leaves covered by one view cell 
107        int maxLeaves;
108
109    // Constructor
110        ViewCellsStatistics()
111        {
112                Reset();
113        }
114
115        double AvgLeaves() const {return (double)leaves / (double)viewCells;};
116        double AvgPvs() const {return (double)pvs / (double)viewCells;};
117 
118        void Reset()
119        {
120                viewCells = 0; 
121                pvs = 0; 
122                maxPvs = 0;
123
124                minPvs = 999999;
125                emptyPvs = 0;
126                leaves = 0;
127                maxLeaves = 0;
128        }
129
130        void Print(ostream &app) const;
131
132        friend ostream &operator<<(ostream &s, const ViewCellsStatistics &stat)
133        {
134                stat.Print(s);
135                return s;
136        } 
137};
138
139#endif
Note: See TracBrowser for help on using the repository browser.