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

Revision 411, 2.5 KB checked in by mattausch, 19 years ago (diff)

worked on view space partition kd tree

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