[1138] | 1 | #ifndef __KDINTERSECTABLE_H
|
---|
| 2 | #define __KDINTERSECTABLE_H
|
---|
| 3 |
|
---|
| 4 | #include "AxisAlignedBox3.h"
|
---|
| 5 | #include "Intersectable.h"
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | namespace GtpVisibilityPreprocessor {
|
---|
| 9 |
|
---|
| 10 | struct VssRayContainer;
|
---|
| 11 | class KdNode;
|
---|
[1233] | 12 | class BvhNode;
|
---|
[1314] | 13 | struct Face;
|
---|
[1328] | 14 | class Ray;
|
---|
| 15 | struct Triangle3;
|
---|
[1138] | 16 |
|
---|
[1314] | 17 |
|
---|
[1328] | 18 |
|
---|
[1138] | 19 | /**
|
---|
[1233] | 20 | Wrapper used for creating a PVS compliant intersectable.
|
---|
[1138] | 21 | */
|
---|
[1233] | 22 | template<typename T>
|
---|
| 23 | class IntersectableWrapper: public Intersectable
|
---|
[1138] | 24 | {
|
---|
| 25 | public:
|
---|
[1233] | 26 | IntersectableWrapper(T *item);
|
---|
[1138] | 27 |
|
---|
[1233] | 28 | /** Returns node associated with this instance.
|
---|
[1138] | 29 | */
|
---|
[1233] | 30 | T *GetItem() const;
|
---|
[1138] | 31 |
|
---|
| 32 | /** See get.
|
---|
| 33 | */
|
---|
[1233] | 34 | void SetItem(T *item);
|
---|
[1138] | 35 |
|
---|
| 36 | //-- inherited functions from Intersectable
|
---|
| 37 |
|
---|
| 38 | AxisAlignedBox3 GetBox() const;
|
---|
| 39 |
|
---|
| 40 | int CastRay(Ray &ray);
|
---|
| 41 |
|
---|
| 42 | bool IsConvex() const;
|
---|
| 43 | bool IsWatertight() const;
|
---|
| 44 | float IntersectionComplexity();
|
---|
| 45 |
|
---|
| 46 | int NumberOfFaces() const;
|
---|
[1233] | 47 | //int Type() const;
|
---|
[1138] | 48 |
|
---|
| 49 | int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
| 50 | GtpVisibilityPreprocessor::Vector3 &normal);
|
---|
| 51 |
|
---|
| 52 | int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
| 53 | GtpVisibilityPreprocessor::Vector3 &normal,
|
---|
| 54 | const GtpVisibilityPreprocessor::Vector3 &viewpoint,
|
---|
| 55 | const int maxTries);
|
---|
| 56 |
|
---|
| 57 | ostream &Describe(ostream &s);
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | protected:
|
---|
| 61 |
|
---|
[1233] | 62 | T *mItem;
|
---|
[1138] | 63 | };
|
---|
| 64 |
|
---|
[1314] | 65 |
|
---|
[1233] | 66 | template<typename T>
|
---|
| 67 | IntersectableWrapper<T>::IntersectableWrapper(T *item):
|
---|
| 68 | Intersectable(), mItem(item)
|
---|
| 69 | {
|
---|
| 70 | }
|
---|
[1138] | 71 |
|
---|
[1233] | 72 | template<typename T>
|
---|
| 73 | void IntersectableWrapper<T>::SetItem(T *item)
|
---|
| 74 | {
|
---|
| 75 | mItem = item;
|
---|
[1138] | 76 | }
|
---|
| 77 |
|
---|
[1233] | 78 | template<typename T>
|
---|
| 79 | T *IntersectableWrapper<T>::GetItem() const
|
---|
| 80 | {
|
---|
| 81 | return mItem;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | template<typename T>
|
---|
| 85 | AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const
|
---|
| 86 | { // TODO matt
|
---|
| 87 | return AxisAlignedBox3();
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | template<typename T>
|
---|
| 91 | int IntersectableWrapper<T>::CastRay(Ray &ray)
|
---|
| 92 | { // TODO matt
|
---|
| 93 | return 0;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | template<typename T>
|
---|
| 97 | bool IntersectableWrapper<T>::IsConvex() const
|
---|
| 98 | {
|
---|
| 99 | return true;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | template<typename T>
|
---|
| 103 | bool IntersectableWrapper<T>::IsWatertight() const
|
---|
| 104 | {
|
---|
| 105 | return true;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | template<typename T>
|
---|
| 109 | float IntersectableWrapper<T>::IntersectionComplexity()
|
---|
| 110 | {
|
---|
| 111 | return 1.0f;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | template<typename T>
|
---|
| 115 | int IntersectableWrapper<T>::NumberOfFaces() const
|
---|
| 116 | {
|
---|
| 117 | return 0;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | template<typename T>
|
---|
| 121 | int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point,
|
---|
| 122 | Vector3 &normal)
|
---|
| 123 | {
|
---|
| 124 | return 0;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | template<typename T>
|
---|
| 128 | int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
| 129 | Vector3 &normal,
|
---|
| 130 | const Vector3 &viewpoint,
|
---|
| 131 | const int maxTries)
|
---|
| 132 | {
|
---|
| 133 | return 0;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | template<typename T>
|
---|
| 137 | ostream &IntersectableWrapper<T>::Describe(ostream &s)
|
---|
| 138 | {
|
---|
| 139 | s << mItem;
|
---|
| 140 | return s;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | class KdIntersectable: public IntersectableWrapper<KdNode>
|
---|
| 145 | {
|
---|
| 146 | public:
|
---|
| 147 | KdIntersectable(KdNode *item):
|
---|
| 148 | IntersectableWrapper<KdNode>(item) {}
|
---|
| 149 |
|
---|
| 150 | int Type() const
|
---|
| 151 | {
|
---|
| 152 | return Intersectable::KD_INTERSECTABLE;
|
---|
| 153 | }
|
---|
| 154 | };
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 | class BvhIntersectable: public IntersectableWrapper<BvhNode>
|
---|
| 158 | {
|
---|
| 159 | public:
|
---|
| 160 | BvhIntersectable(BvhNode *item):
|
---|
| 161 | IntersectableWrapper<BvhNode>(item) {}
|
---|
| 162 |
|
---|
| 163 | int Type() const
|
---|
| 164 | {
|
---|
| 165 | return Intersectable::BVH_INTERSECTABLE;
|
---|
| 166 | }
|
---|
| 167 | };
|
---|
| 168 |
|
---|
[1328] | 169 | class TriangleIntersectable: public IntersectableWrapper<Triangle3>
|
---|
[1314] | 170 | {
|
---|
| 171 | public:
|
---|
[1328] | 172 | TriangleIntersectable(Triangle3 *item):
|
---|
| 173 | IntersectableWrapper<Triangle3>(item) {}
|
---|
[1314] | 174 |
|
---|
[1328] | 175 | int CastRay(Ray &ray);
|
---|
| 176 | AxisAlignedBox3 GetBox() const;
|
---|
| 177 |
|
---|
| 178 | int NumberOfFaces() const;
|
---|
| 179 |
|
---|
[1314] | 180 | int Type() const
|
---|
| 181 | {
|
---|
[1328] | 182 | return Intersectable::TRIANGLE_INTERSECTABLE;
|
---|
[1314] | 183 | }
|
---|
| 184 | };
|
---|
| 185 |
|
---|
| 186 |
|
---|
[1233] | 187 | }
|
---|
| 188 |
|
---|
[1138] | 189 | #endif
|
---|