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

Revision 441, 2.8 KB checked in by mattausch, 19 years ago (diff)

added visibilitymanager
removed area computation from bsp

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;
11
12class SimulationStatistics: public StatisticsBase
13{
14public:
15        /// view cell with the biggest "cost"
16        float maxCost;
17        /// view cell with the minimal "cost"
18    float minCost;
19        /// average render time
20        float avgRenderTime;
21        /// average render time with the overhead when crossing view cells
22        float avgRtWithoutOverhead;
23 
24        void Reset()
25        {
26                maxCost = 0;
27                minCost = 999999;
28                avgRenderTime = 0;
29                avgRtWithoutOverhead = 0;
30        }
31
32        void Print(ostream &app) const;
33
34        friend ostream &operator<<(ostream &s, const SimulationStatistics &stat)
35        {
36                stat.Print(s);
37                return s;
38        } 
39
40        SimulationStatistics()
41        {
42                Reset();
43        }
44};
45
46/** Simulated rendering using a simple render heuristics. Used to evaluate the
47        quality of the view cell partition.
48*/
49class RenderSimulator
50{
51
52public:
53        RenderSimulator();
54        /** Constructor taking the estimated render cost,
55                the view cell overhead,
56                and the average move speed of the player into account.
57        */
58        RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed);
59
60        /** Simulates rendering of the view cells.
61                @returns the statistics of the simulation.
62        */
63        virtual SimulationStatistics SimulateRendering() = 0;
64
65        /** Sets estimated render time for a single object in the PVS.
66        */
67        void SetObjectRenderCost(const float objRenderCost);
68
69        /** Contant overhead for crossing a view cell border.
70        */
71        void SetVcOverhead(const float vcOverhead);
72
73        /** Average move speed of the player during rendering.
74        */
75        void SetMoveSpeed(const float moveSpeed);
76
77
78protected:
79
80        /// render time for single object of the PVS
81        float mObjRenderCost;
82        /// const overhead for crossing a view cell border
83        float mVcOverhead;
84        /// move speed of player
85        float mMoveSpeed;
86};
87
88class BspRenderSimulator: public RenderSimulator
89{
90public:
91        BspRenderSimulator(BspTree *bspTree);
92
93        BspRenderSimulator(float objRenderCost,
94                                                           float vcOverhead,
95                                                           float moveSpeed,
96                                                           BspTree *bspTree);
97
98        SimulationStatistics SimulateRendering();
99
100protected:
101        /** Simulates rendering of the pvs of one view cell, with given rendering time for an object.
102                @param viewCell the view cell holding the Pvs
103                @param objRenderTime estimated render time for one object of the Pvs
104        */
105        Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const;
106
107        BspTree *mBspTree;
108};
109
110class KdRenderSimulator: public RenderSimulator
111{
112public:
113        KdRenderSimulator(KdTree *kdTree);
114
115        KdRenderSimulator(float objRenderCost,
116                                                          float vcOverhead,
117                                                          float moveSpeed,
118                                                          KdTree *kdTree);
119        SimulationStatistics SimulateRendering();
120
121protected:
122
123        Real RenderPvs(KdLeaf *leaf, float objRenderTime) const;
124
125        KdTree *mKdTree;
126};
127
128#endif // RenderSimulator
Note: See TracBrowser for help on using the repository browser.