source: trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.h @ 449

Revision 449, 4.0 KB checked in by mattausch, 19 years ago (diff)
Line 
1#ifndef _RenderSimulator_h__
2#define _RenderSimulator_h__
3
4#include "common.h"
5#include "Statistics.h"
6
7class BspTree;
8class KdTree;
9class ViewCell;
10class KdLeaf;
11class VspKdTree;
12class VspBspTree;
13
14class SimulationStatistics: public StatisticsBase
15{
16public:
17        /// view cell with the biggest "cost"
18        float maxCost;
19        /// view cell with the minimal "cost"
20    float minCost;
21        /// average render time
22        float avgRenderTime;
23        /// average render time with the overhead when crossing view cells
24        float avgRtWithoutOverhead;
25 
26        void Reset()
27        {
28                maxCost = 0;
29                minCost = 999999;
30                avgRenderTime = 0;
31                avgRtWithoutOverhead = 0;
32        }
33
34        void Print(ostream &app) const;
35
36        friend ostream &operator<<(ostream &s, const SimulationStatistics &stat)
37        {
38                stat.Print(s);
39                return s;
40        } 
41
42        SimulationStatistics()
43        {
44                Reset();
45        }
46};
47
48/** Simulated rendering using a simple render heuristics. Used to evaluate the
49        quality of the view cell partition.
50*/
51class RenderSimulator
52{
53
54public:
55        RenderSimulator();
56        /** Constructor taking the estimated render cost,
57                the view cell overhead,
58                and the average move speed of the player into account.
59        */
60        RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed);
61
62        /** Simulates rendering of the view cells.
63                @returns the statistics of the simulation.
64        */
65        virtual SimulationStatistics SimulateRendering() = 0;
66
67        /** Sets estimated render time for a single object in the PVS.
68        */
69        void SetObjectRenderCost(const float objRenderCost);
70
71        /** Contant overhead for crossing a view cell border.
72        */
73        void SetVcOverhead(const float vcOverhead);
74
75        /** Average move speed of the player during rendering.
76        */
77        void SetMoveSpeed(const float moveSpeed);
78
79
80protected:
81
82        /// render time for single object of the PVS
83        float mObjRenderCost;
84        /// const overhead for crossing a view cell border
85        float mVcOverhead;
86        /// move speed of player
87        float mMoveSpeed;
88};
89
90class BspRenderSimulator: public RenderSimulator
91{
92public:
93        BspRenderSimulator(BspTree *bspTree);
94
95        BspRenderSimulator(float objRenderCost,
96                                                           float vcOverhead,
97                                                           float moveSpeed,
98                                                           BspTree *bspTree);
99
100        SimulationStatistics SimulateRendering();
101
102protected:
103        /** Simulates rendering of the pvs of one view cell, with given rendering time for an object.
104                @param viewCell the view cell holding the Pvs
105                @param objRenderTime estimated render time for one object of the Pvs
106        */
107        Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const;
108
109private:
110        BspTree *mBspTree;
111};
112
113class VspBspRenderSimulator: public RenderSimulator
114{
115public:
116        VspBspRenderSimulator(VspBspTree *vspBspTree);
117
118        VspBspRenderSimulator(float objRenderCost,
119                                                  float vcOverhead,
120                                                  float moveSpeed,
121                                                  VspBspTree *vspBspTree);
122
123        SimulationStatistics SimulateRendering();
124
125protected:
126        /** Simulates rendering of the pvs of one view cell, with given rendering time for an object.
127                @param viewCell the view cell holding the Pvs
128                @param objRenderTime estimated render time for one object of the Pvs
129        */
130        Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const;
131
132private:
133        VspBspTree *mVspBspTree;
134};
135
136class KdRenderSimulator: public RenderSimulator
137{
138public:
139        KdRenderSimulator(KdTree *kdTree);
140
141        KdRenderSimulator(float objRenderCost,
142                                                          float vcOverhead,
143                                                          float moveSpeed,
144                                                          KdTree *kdTree);
145        SimulationStatistics SimulateRendering();
146
147protected:
148
149        Real RenderPvs(KdLeaf *leaf, float objRenderTime) const;
150
151        KdTree *mKdTree;
152};
153
154class VspKdRenderSimulator: public RenderSimulator
155{
156public:
157        VspKdRenderSimulator(VspKdTree *vspKdTree);
158
159        VspKdRenderSimulator(float objRenderCost,
160                                                 float vcOverhead,
161                                                 float moveSpeed,
162                                                 VspKdTree *vspKdTree);
163
164        SimulationStatistics SimulateRendering();
165
166protected:
167        /** Simulates rendering of the pvs of one view cell, with given rendering time for an object.
168                @param viewCell the view cell holding the Pvs
169                @param objRenderTime estimated render time for one object of the Pvs
170        */
171        Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const;
172
173private:
174        VspKdTree *mVspKdTree;
175};
176
177#endif // RenderSimulator
Note: See TracBrowser for help on using the repository browser.