source: trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.h @ 209

Revision 209, 2.5 KB checked in by bittner, 19 years ago (diff)

data added

Line 
1#ifndef __MUTUAL_VISIBILITY_H
2#define __MUTUAL_VISIBILITY_H
3
4#include "Vector3.h"
5#include "Ray.h"
6
7class Intersectable;
8class AxisAlignedBox3;
9
10struct SimpleRay {
11  Vector3 mOrigin;
12  Vector3 mDirection;
13};
14
15
16struct RayShaft {
17public:
18  /// evaluted sampling error
19  float mError;
20  /// depth in recursion
21  int mDepth;
22  /// The source triangle
23  Rectangle3 mSource;
24  /// The target triangle
25  Rectangle3 mTarget;
26 
27  /// intersections with the scene
28  vector<Ray::Intersection> mIntersections[4];
29 
30  void ComputeError();
31 
32  RayShaft () {}
33 
34  RayShaft (
35            const Rectangle3 &source,
36            const Rectangle3 &target)
37  {
38    Init(source, target);
39  }
40 
41  // initial triangle sample
42  void Init(
43            const Rectangle3 &source,
44            const Rectangle3 &target);
45 
46  Vector3
47  GetIntersectionPoint(const int rayIndex,
48                       const int depth) const;
49 
50  void GetRay(const int rayIndex,
51              Vector3 &origin,
52              Vector3 &direction) const;
53};
54
55enum { VISIBLE, INVISIBLE };
56
57 
58class MutualVisibilitySampler {
59public:
60  KdTree *mKdTree;
61  AxisAlignedBox3 mSource;
62  AxisAlignedBox3 mTarget;
63  float mSolidAngleThreshold;
64
65
66  MutualVisibilitySampler(KdTree *kdTree,
67                          AxisAlignedBox3 &source,
68                          AxisAlignedBox3 &target,
69                          const float solidAngleThreshold);
70  int
71  ComputeVisibility();
72
73  void
74  ConstructInitialSamples(
75                          const AxisAlignedBox3 &source,
76                          const AxisAlignedBox3 &target,
77                          vector<RayShaft *> &samples
78                          );
79
80  void
81  AddInitialSamples(
82                    const Rectangle3 &sourceRect,
83                    const Rectangle3 &targetRect,
84                    vector<RayShaft *> &samples
85                    );
86
87  // the split sample method contains a methodology to create new samples
88  // or terminate the sampling
89  bool
90  SplitSample(
91              const RayShaft &source,
92              RayShaft &sample1,
93              RayShaft &sample2
94              );
95  void
96  PerformSplit(
97               const RayShaft &sample,
98               const bool splitSource,
99               const int axis,
100               RayShaft &sample1,
101               RayShaft &sample2
102               );
103 
104
105  bool
106  SampleTerminationCriteriaMet(
107                               const RayShaft &sample);
108 
109  float
110  GetSpatialAngle(const RayShaft &sample,
111                  const Vector3 &point
112                  );
113
114  void
115  ComputeError(RayShaft &sample);
116
117  void
118  ExportSamples(vector<RayShaft *> &samples);
119
120
121};
122 
123int
124ComputeBoxVisibility(KdTree *kdTree,
125                     AxisAlignedBox3 &source,
126                     AxisAlignedBox3 &target,
127                     float solidAngleThreshold);
128
129
130
131
132
133
134#endif
Note: See TracBrowser for help on using the repository browser.