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

RevLine 
[406]1#ifndef _RenderSimulator_h__
2#define _RenderSimulator_h__
3
4#include "common.h"
[414]5#include "Statistics.h"
[406]6
7class BspTree;
8class KdTree;
9class ViewCell;
[407]10class KdLeaf;
[406]11
[414]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        } 
[441]39
40        SimulationStatistics()
41        {
42                Reset();
43        }
[414]44};
45
[406]46/** Simulated rendering using a simple render heuristics. Used to evaluate the
47        quality of the view cell partition.
48*/
49class RenderSimulator
50{
[414]51
[406]52public:
53        RenderSimulator();
[439]54        /** Constructor taking the estimated render cost,
55                the view cell overhead,
56                and the average move speed of the player into account.
57        */
[409]58        RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed);
[406]59
[439]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
[409]80        /// render time for single object of the PVS
[406]81        float mObjRenderCost;
[409]82        /// const overhead for crossing a view cell border
[406]83        float mVcOverhead;
[409]84        /// move speed of player
85        float mMoveSpeed;
[406]86};
87
[439]88class BspRenderSimulator: public RenderSimulator
[406]89{
90public:
[440]91        BspRenderSimulator(BspTree *bspTree);
92
[439]93        BspRenderSimulator(float objRenderCost,
[411]94                                                           float vcOverhead,
95                                                           float moveSpeed,
96                                                           BspTree *bspTree);
[406]97
[439]98        SimulationStatistics SimulateRendering();
[406]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
[439]110class KdRenderSimulator: public RenderSimulator
[406]111{
112public:
[440]113        KdRenderSimulator(KdTree *kdTree);
114
[439]115        KdRenderSimulator(float objRenderCost,
[411]116                                                          float vcOverhead,
117                                                          float moveSpeed,
118                                                          KdTree *kdTree);
[439]119        SimulationStatistics SimulateRendering();
[406]120
[407]121protected:
[406]122
[407]123        Real RenderPvs(KdLeaf *leaf, float objRenderTime) const;
124
[406]125        KdTree *mKdTree;
126};
127
128#endif // RenderSimulator
Note: See TracBrowser for help on using the repository browser.