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

Revision 426, 2.6 KB checked in by mattausch, 19 years ago (diff)

fixed ray bug in vspkdtree
added visualizations

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