[1520] | 1 | #ifndef _RayCaster_H__
|
---|
| 2 | #define _RayCaster_H__
|
---|
| 3 |
|
---|
| 4 | #include "Containers.h"
|
---|
| 5 | #include <string>
|
---|
[1528] | 6 | #include "Vector3.h"
|
---|
| 7 |
|
---|
[1520] | 8 | using namespace std;
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | namespace GtpVisibilityPreprocessor {
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | class Intersectable;
|
---|
| 15 | class VssRay;
|
---|
| 16 | class SimpleRayContainer;
|
---|
| 17 | class AxisAlignedBox3;
|
---|
[1528] | 18 | //class Vector3;
|
---|
[1520] | 19 | struct VssRayContainer;
|
---|
| 20 | class Preprocessor;
|
---|
[1528] | 21 | struct SimpleRay;
|
---|
[1520] | 22 |
|
---|
[1528] | 23 |
|
---|
[1520] | 24 | /** This class provides an interface for ray casting.
|
---|
| 25 | */
|
---|
| 26 | class RayCaster
|
---|
| 27 | {
|
---|
[1528] | 28 |
|
---|
[1520] | 29 | public:
|
---|
| 30 |
|
---|
| 31 | enum {
|
---|
| 32 | INTERNAL_RAYCASTER = 0,
|
---|
| 33 | INTEL_RAYCASTER
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 | RayCaster(const Preprocessor &preprocessor);
|
---|
| 37 |
|
---|
[1521] | 38 | virtual ~RayCaster();
|
---|
[1520] | 39 |
|
---|
| 40 | virtual int Type() const = 0;
|
---|
| 41 |
|
---|
[1521] | 42 | /** Wrapper for casting single ray.
|
---|
[1545] | 43 | @returns ray or NULL if invalid
|
---|
[1521] | 44 | */
|
---|
[1932] | 45 | VssRay *CastRay(const SimpleRay &simpleRay,
|
---|
| 46 | const AxisAlignedBox3 &box);
|
---|
| 47 | //const bool castDoubleRay);
|
---|
[1521] | 48 |
|
---|
[1932] | 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;
|
---|
[1520] | 55 |
|
---|
[1932] | 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;
|
---|
[1520] | 63 |
|
---|
| 64 |
|
---|
| 65 | protected:
|
---|
[1528] | 66 | struct Intersection
|
---|
| 67 | {
|
---|
| 68 | Intersection(): mObject(NULL), mFaceId(0)
|
---|
| 69 | {}
|
---|
[1520] | 70 |
|
---|
[1528] | 71 | Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
|
---|
[1824] | 72 | mPoint(p), mNormal(n), mObject(o), mFaceId(f)
|
---|
[1528] | 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 |
|
---|
[1824] | 83 |
|
---|
[1932] | 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);
|
---|
[1520] | 91 |
|
---|
[1528] | 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);
|
---|
[1942] | 100 |
|
---|
| 101 | bool
|
---|
| 102 | ClipToViewSpaceBox(const Vector3 &origin,
|
---|
| 103 | const Vector3 &termination,
|
---|
| 104 | Vector3 &clippedOrigin,
|
---|
| 105 | Vector3 &clippedTermination);
|
---|
[1520] | 106 |
|
---|
| 107 | const Preprocessor &mPreprocessor;
|
---|
| 108 | };
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | #endif
|
---|