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