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

Revision 223, 2.7 KB checked in by bittner, 19 years ago (diff)
RevLine 
[191]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
[223]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};
[191]23
[209]24struct RayShaft {
[191]25public:
26  /// evaluted sampling error
27  float mError;
28  /// depth in recursion
29  int mDepth;
30  /// The source triangle
[209]31  Rectangle3 mSource;
[191]32  /// The target triangle
[209]33  Rectangle3 mTarget;
[191]34 
[223]35  RaySample mSamples[4];
[191]36 
37  void ComputeError();
38 
[209]39  RayShaft () {}
[191]40 
[209]41  RayShaft (
42            const Rectangle3 &source,
43            const Rectangle3 &target)
[191]44  {
45    Init(source, target);
46  }
[209]47 
[191]48  // initial triangle sample
49  void Init(
[209]50            const Rectangle3 &source,
51            const Rectangle3 &target);
[191]52 
53  Vector3
54  GetIntersectionPoint(const int rayIndex,
55                       const int depth) const;
[209]56 
[191]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,
[209]84                          vector<RayShaft *> &samples
[191]85                          );
86
87  void
88  AddInitialSamples(
89                    const Rectangle3 &sourceRect,
90                    const Rectangle3 &targetRect,
[209]91                    vector<RayShaft *> &samples
[191]92                    );
93
94  // the split sample method contains a methodology to create new samples
95  // or terminate the sampling
96  bool
97  SplitSample(
[209]98              const RayShaft &source,
99              RayShaft &sample1,
100              RayShaft &sample2
[191]101              );
102  void
103  PerformSplit(
[209]104               const RayShaft &sample,
[191]105               const bool splitSource,
[209]106               const int axis,
107               RayShaft &sample1,
108               RayShaft &sample2
[191]109               );
110 
111
112  bool
113  SampleTerminationCriteriaMet(
[209]114                               const RayShaft &sample);
[191]115 
116  float
[209]117  GetSpatialAngle(const RayShaft &sample,
[191]118                  const Vector3 &point
119                  );
120
[223]121  int
122  CastRays(RayShaft &shaft);
123
[191]124  void
[209]125  ComputeError(RayShaft &sample);
[223]126 
[209]127  void
128  ExportSamples(vector<RayShaft *> &samples);
[191]129
[209]130
[191]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.