1 | #ifndef _SamplingPreprocessor_H__ |
---|
2 | #define _SamplingPreprocessor_H__ |
---|
3 | |
---|
4 | #include <fstream> |
---|
5 | using namespace std; |
---|
6 | |
---|
7 | #include "Preprocessor.h" |
---|
8 | #include "VssRay.h" |
---|
9 | |
---|
10 | class Exporter; |
---|
11 | |
---|
12 | /** Sampling based visibility preprocessing. The implementation is based on heuristical |
---|
13 | sampling of view space */ |
---|
14 | class SamplingPreprocessor : public Preprocessor { |
---|
15 | public: |
---|
16 | |
---|
17 | SamplingPreprocessor(); |
---|
18 | ~SamplingPreprocessor(); |
---|
19 | |
---|
20 | virtual bool ComputeVisibility(); |
---|
21 | |
---|
22 | |
---|
23 | protected: |
---|
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(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 | /** Post processes view cells (i.e., merges or subdivides view cells based |
---|
86 | on the PVS and the ray sets. |
---|
87 | @param rays a set of rays which carries the visibility information |
---|
88 | the merging / subdivision is based on. |
---|
89 | @returns number of merged view cells. |
---|
90 | */ |
---|
91 | int PostprocessViewCells(const RayContainer &rays); |
---|
92 | |
---|
93 | protected: |
---|
94 | |
---|
95 | |
---|
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 | |
---|
106 | int mVspConstructionSamples; |
---|
107 | |
---|
108 | int mPostProcessSamples; |
---|
109 | int mVisualizationSamples; |
---|
110 | |
---|
111 | }; |
---|
112 | |
---|
113 | #endif |
---|