[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 | */
|
---|
[1545] | 45 | VssRay *CastRay(
|
---|
[1528] | 46 | const SimpleRay &simpleRay,
|
---|
[1545] | 47 | const AxisAlignedBox3 &box,
|
---|
| 48 | const bool castDoubleRay
|
---|
[1521] | 49 | );
|
---|
| 50 |
|
---|
[1520] | 51 | virtual int CastRay(
|
---|
[1528] | 52 | const SimpleRay &simpleRay,
|
---|
[1520] | 53 | VssRayContainer &vssRays,
|
---|
| 54 | const AxisAlignedBox3 &box,
|
---|
[1528] | 55 | const bool castDoubleRay,
|
---|
| 56 | const bool pruneInvalidRays = true
|
---|
[1520] | 57 | ) = 0;
|
---|
| 58 |
|
---|
| 59 | virtual void CastRays16(
|
---|
| 60 | const int i,
|
---|
| 61 | SimpleRayContainer &rays,
|
---|
| 62 | VssRayContainer &vssRays,
|
---|
| 63 | const AxisAlignedBox3 &sbox,
|
---|
[1528] | 64 | const bool castDoubleRay,
|
---|
| 65 | const bool pruneInvalidRays = true
|
---|
[1520] | 66 | ) = 0;
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | protected:
|
---|
[1528] | 70 | struct Intersection
|
---|
| 71 | {
|
---|
| 72 | Intersection(): mObject(NULL), mFaceId(0)
|
---|
| 73 | {}
|
---|
[1520] | 74 |
|
---|
[1528] | 75 | Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
|
---|
| 76 | mPoint(p), mNormal(n), mObject(o), mFaceId(f)
|
---|
| 77 | {}
|
---|
| 78 |
|
---|
| 79 | Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
|
---|
| 80 | {}
|
---|
| 81 | Vector3 mPoint;
|
---|
| 82 | Vector3 mNormal;
|
---|
| 83 | Intersectable *mObject;
|
---|
| 84 | int mFaceId;
|
---|
| 85 | };
|
---|
| 86 |
|
---|
[1520] | 87 | int ProcessRay(
|
---|
[1528] | 88 | const SimpleRay &ray,
|
---|
| 89 | Intersection &hitA,
|
---|
| 90 | Intersection &hitB,
|
---|
[1520] | 91 | VssRayContainer &vssRays,
|
---|
[1528] | 92 | const AxisAlignedBox3 &box,
|
---|
| 93 | const bool castDoubleRay,
|
---|
| 94 | const bool pruneInvalidRays = true
|
---|
[1520] | 95 | );
|
---|
| 96 |
|
---|
[1528] | 97 | /** Checks if ray is valid.
|
---|
| 98 | I.e., the ray is in valid view space.
|
---|
| 99 | @note: clamps the ray to valid view space.
|
---|
| 100 | */
|
---|
| 101 | bool ValidateRay(const Vector3 &origin,
|
---|
| 102 | const Vector3 &direction,
|
---|
| 103 | const AxisAlignedBox3 &box,
|
---|
| 104 | Intersection &hit);
|
---|
[1520] | 105 |
|
---|
| 106 | const Preprocessor &mPreprocessor;
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | #endif
|
---|