1 | #ifndef _RayCaster_H__
|
---|
2 | #define _RayCaster_H__
|
---|
3 |
|
---|
4 | #include "Containers.h"
|
---|
5 | #include <string>
|
---|
6 | #include "Vector3.h"
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 |
|
---|
11 | namespace GtpVisibilityPreprocessor {
|
---|
12 |
|
---|
13 |
|
---|
14 | class Intersectable;
|
---|
15 | class VssRay;
|
---|
16 | class SimpleRayContainer;
|
---|
17 | class AxisAlignedBox3;
|
---|
18 | //class Vector3;
|
---|
19 | struct VssRayContainer;
|
---|
20 | class Preprocessor;
|
---|
21 | struct SimpleRay;
|
---|
22 |
|
---|
23 |
|
---|
24 | /** This class provides an interface for ray casting.
|
---|
25 | */
|
---|
26 | class RayCaster
|
---|
27 | {
|
---|
28 |
|
---|
29 | public:
|
---|
30 |
|
---|
31 | enum {
|
---|
32 | INTERNAL_RAYCASTER = 0,
|
---|
33 | INTEL_RAYCASTER
|
---|
34 | };
|
---|
35 |
|
---|
36 | RayCaster(const Preprocessor &preprocessor);
|
---|
37 |
|
---|
38 | virtual ~RayCaster();
|
---|
39 |
|
---|
40 | virtual int Type() const = 0;
|
---|
41 |
|
---|
42 | /** Wrapper for casting single ray.
|
---|
43 | @returns ray or NULL if invalid
|
---|
44 | */
|
---|
45 | VssRay *CastRay(const SimpleRay &simpleRay,
|
---|
46 | const AxisAlignedBox3 &box);
|
---|
47 | //const bool castDoubleRay);
|
---|
48 |
|
---|
49 | virtual int CastRay(const SimpleRay &simpleRay,
|
---|
50 | VssRayContainer &vssRays,
|
---|
51 | const AxisAlignedBox3 &box,
|
---|
52 | const bool castDoubleRay,
|
---|
53 | const bool pruneInvalidRays = true
|
---|
54 | ) = 0;
|
---|
55 |
|
---|
56 | virtual void CastRays16(const int i,
|
---|
57 | SimpleRayContainer &rays,
|
---|
58 | VssRayContainer &vssRays,
|
---|
59 | const AxisAlignedBox3 &sbox,
|
---|
60 | const bool castDoubleRay,
|
---|
61 | const bool pruneInvalidRays = true
|
---|
62 | ) = 0;
|
---|
63 |
|
---|
64 |
|
---|
65 | protected:
|
---|
66 | struct Intersection
|
---|
67 | {
|
---|
68 | Intersection(): mObject(NULL), mFaceId(0)
|
---|
69 | {}
|
---|
70 |
|
---|
71 | Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
|
---|
72 | mPoint(p), mNormal(n), mObject(o), mFaceId(f)
|
---|
73 | {}
|
---|
74 |
|
---|
75 | Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
|
---|
76 | {}
|
---|
77 | Vector3 mPoint;
|
---|
78 | Vector3 mNormal;
|
---|
79 | Intersectable *mObject;
|
---|
80 | int mFaceId;
|
---|
81 | };
|
---|
82 |
|
---|
83 |
|
---|
84 | int ProcessRay(const SimpleRay &ray,
|
---|
85 | Intersection &hitA,
|
---|
86 | Intersection &hitB,
|
---|
87 | VssRayContainer &vssRays,
|
---|
88 | const AxisAlignedBox3 &box,
|
---|
89 | const bool castDoubleRay,
|
---|
90 | const bool pruneInvalidRays = true);
|
---|
91 |
|
---|
92 | /** Checks if ray is valid.
|
---|
93 | I.e., the ray is in valid view space.
|
---|
94 | @note: clamps the ray to valid view space.
|
---|
95 | */
|
---|
96 | bool ValidateRay(const Vector3 &origin,
|
---|
97 | const Vector3 &direction,
|
---|
98 | const AxisAlignedBox3 &box,
|
---|
99 | Intersection &hit);
|
---|
100 |
|
---|
101 | bool
|
---|
102 | ClipToViewSpaceBox(const Vector3 &origin,
|
---|
103 | const Vector3 &termination,
|
---|
104 | Vector3 &clippedOrigin,
|
---|
105 | Vector3 &clippedTermination);
|
---|
106 |
|
---|
107 | const Preprocessor &mPreprocessor;
|
---|
108 | };
|
---|
109 |
|
---|
110 |
|
---|
111 | }
|
---|
112 |
|
---|
113 | #endif
|
---|