source: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h @ 373

Revision 373, 2.7 KB checked in by mattausch, 19 years ago (diff)

added visualization of view cells versus leaves

Line 
1#ifndef _SamplingPreprocessor_H__
2#define _SamplingPreprocessor_H__
3
4#include <fstream>
5using namespace std;
6
7#include "Preprocessor.h"
8
9
10/** Sampling based visibility preprocessing. The implementation is based on heuristical
11    sampling of view space */
12class SamplingPreprocessor : public Preprocessor {
13public:
14               
15  SamplingPreprocessor();
16
17  ~SamplingPreprocessor();
18
19  virtual bool ComputeVisibility();
20
21protected:
22        int mPass;
23
24  int mSamplesPerPass;
25  int mTotalSamples;
26  int mKdPvsDepth;
27  ofstream mStats;
28  ObjectContainer mObjects;
29  RayContainer mSampleRays;
30  int mBspConstructionSamples;
31  int mPostProcessSamples;
32
33
34  void
35  SetupRay(Ray &ray,
36                   const Vector3 &point,
37                   const Vector3 &direction,
38                   const int type);
39
40  KdNode *
41  GetNodeForPvs(KdLeaf *leaf);
42
43        int
44        AddNodeSamples(const Ray &ray,
45                                                                 Intersectable *sObject,
46                                                                 Intersectable *tObject
47                                                                 );
48
49  void
50  HoleSamplingPass();
51
52        int
53        CastRay(Intersectable *object,
54                                        Ray &ray);
55       
56        KdNode *
57        GetNodeToSample(Intersectable *object);
58        void
59        VerifyVisibility(Intersectable *object);
60
61        int
62        CastEdgeSamples(
63                                                                        Intersectable *object,
64                                                                        const Vector3 &point,
65                                                                        MeshInstance *mi,
66                                                                        const int samples
67                                                                        );
68
69        /** Processes the BSP based view cells during a pass.
70               
71                @param ray the current ray
72                @param object the currently processed object
73                @param faceIndex the sampled face of the object
74                @param contributingSamples samples contributing to pvs
75                @param sampleContributions contribution of the samples
76
77                @returns true if BSP tree has been constructed, false if not yet
78
79        */
80        bool ProcessBspViewCells(Ray &ray,
81                                                         Intersectable *object,
82                                                         int faceIndex,
83                                                         int &contributingSamples,
84                                                         int &sampleContributions);
85
86        /** Adds objects samples to bsp view cells.
87        */
88        int AddObjectSamples(Intersectable *obj, const Ray &ray);
89
90        bool BuildBspTree();
91
92        void ExportSplits(const ObjectContainer &objects);
93
94        void ExportBspPvs(const ObjectContainer &objects);
95
96        /** Post processes view cells (i.e., merges or subdivides view cells based
97                on the PVS and the ray sets.
98                @param rays a set of rays which carries the visibility information
99                the merging / subdivision is based on.
100                @returns number of merged view cells.
101        */
102        int PostprocessViewCells(const RayContainer &rays);
103
104        /** Simulated rendering using a simple render heuristics. Used to evaluate the
105                quality of the view cell partition.
106        */
107        Real SimulateRendering();
108        /** Simulates rendering of the pvs of one view cell, with given rendering time for an object.
109                @param viewCell the view cell holding the Pvs
110                @param objRenderTime estimated render time for one object of the Pvs
111        */
112        Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const;
113
114};
115
116
117
118#endif
Note: See TracBrowser for help on using the repository browser.