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

Revision 223, 2.7 KB checked in by bittner, 19 years ago (diff)
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
15struct RaySample {
16  /// true if the sample really intersects both boxes
17  float mMinT;
18  float mMaxT;
19  /// intersections of the sample with the scene
20  vector<Ray::Intersection> mIntersections;
21  bool IsValid() const { return mMaxT > 0.0; }
22};
23
24struct RayShaft {
25public:
26  /// evaluted sampling error
27  float mError;
28  /// depth in recursion
29  int mDepth;
30  /// The source triangle
31  Rectangle3 mSource;
32  /// The target triangle
33  Rectangle3 mTarget;
34 
35  RaySample mSamples[4];
36 
37  void ComputeError();
38 
39  RayShaft () {}
40 
41  RayShaft (
42            const Rectangle3 &source,
43            const Rectangle3 &target)
44  {
45    Init(source, target);
46  }
47 
48  // initial triangle sample
49  void Init(
50            const Rectangle3 &source,
51            const Rectangle3 &target);
52 
53  Vector3
54  GetIntersectionPoint(const int rayIndex,
55                       const int depth) const;
56 
57  void GetRay(const int rayIndex,
58              Vector3 &origin,
59              Vector3 &direction) const;
60};
61
62enum { VISIBLE, INVISIBLE };
63
64 
65class MutualVisibilitySampler {
66public:
67  KdTree *mKdTree;
68  AxisAlignedBox3 mSource;
69  AxisAlignedBox3 mTarget;
70  float mSolidAngleThreshold;
71
72
73  MutualVisibilitySampler(KdTree *kdTree,
74                          AxisAlignedBox3 &source,
75                          AxisAlignedBox3 &target,
76                          const float solidAngleThreshold);
77  int
78  ComputeVisibility();
79
80  void
81  ConstructInitialSamples(
82                          const AxisAlignedBox3 &source,
83                          const AxisAlignedBox3 &target,
84                          vector<RayShaft *> &samples
85                          );
86
87  void
88  AddInitialSamples(
89                    const Rectangle3 &sourceRect,
90                    const Rectangle3 &targetRect,
91                    vector<RayShaft *> &samples
92                    );
93
94  // the split sample method contains a methodology to create new samples
95  // or terminate the sampling
96  bool
97  SplitSample(
98              const RayShaft &source,
99              RayShaft &sample1,
100              RayShaft &sample2
101              );
102  void
103  PerformSplit(
104               const RayShaft &sample,
105               const bool splitSource,
106               const int axis,
107               RayShaft &sample1,
108               RayShaft &sample2
109               );
110 
111
112  bool
113  SampleTerminationCriteriaMet(
114                               const RayShaft &sample);
115 
116  float
117  GetSpatialAngle(const RayShaft &sample,
118                  const Vector3 &point
119                  );
120
121  int
122  CastRays(RayShaft &shaft);
123
124  void
125  ComputeError(RayShaft &sample);
126 
127  void
128  ExportSamples(vector<RayShaft *> &samples);
129
130
131};
132 
133int
134ComputeBoxVisibility(KdTree *kdTree,
135                     AxisAlignedBox3 &source,
136                     AxisAlignedBox3 &target,
137                     float solidAngleThreshold);
138
139
140
141
142
143
144#endif
Note: See TracBrowser for help on using the repository browser.