[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 | /** See get.
|
---|
| 34 | */
|
---|
[1344] | 35 | void SetItem(T item);
|
---|
[1138] | 36 |
|
---|
[1344] | 37 |
|
---|
| 38 | /////////////////////////////////////////////
|
---|
[1138] | 39 | //-- inherited functions from Intersectable
|
---|
| 40 |
|
---|
| 41 | AxisAlignedBox3 GetBox() const;
|
---|
| 42 |
|
---|
| 43 | int CastRay(Ray &ray);
|
---|
| 44 |
|
---|
| 45 | bool IsConvex() const;
|
---|
| 46 | bool IsWatertight() const;
|
---|
| 47 | float IntersectionComplexity();
|
---|
| 48 |
|
---|
| 49 | int NumberOfFaces() const;
|
---|
[1344] | 50 |
|
---|
[1138] | 51 | int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
| 52 | GtpVisibilityPreprocessor::Vector3 &normal);
|
---|
| 53 |
|
---|
| 54 | int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
| 55 | GtpVisibilityPreprocessor::Vector3 &normal,
|
---|
| 56 | const GtpVisibilityPreprocessor::Vector3 &viewpoint,
|
---|
| 57 | const int maxTries);
|
---|
| 58 |
|
---|
| 59 | ostream &Describe(ostream &s);
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | protected:
|
---|
| 63 |
|
---|
[1344] | 64 | T mItem;
|
---|
[1138] | 65 | };
|
---|
| 66 |
|
---|
[1314] | 67 |
|
---|
[1233] | 68 | template<typename T>
|
---|
[1344] | 69 | IntersectableWrapper<T>::IntersectableWrapper(T item):
|
---|
[1233] | 70 | Intersectable(), mItem(item)
|
---|
| 71 | {
|
---|
| 72 | }
|
---|
[1138] | 73 |
|
---|
[1233] | 74 | template<typename T>
|
---|
[1344] | 75 | void IntersectableWrapper<T>::SetItem(T item)
|
---|
[1233] | 76 | {
|
---|
| 77 | mItem = item;
|
---|
[1138] | 78 | }
|
---|
| 79 |
|
---|
[1233] | 80 | template<typename T>
|
---|
[1344] | 81 | T IntersectableWrapper<T>::GetItem() const
|
---|
[1233] | 82 | {
|
---|
| 83 | return mItem;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | template<typename T>
|
---|
| 87 | AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const
|
---|
| 88 | { // TODO matt
|
---|
| 89 | return AxisAlignedBox3();
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | template<typename T>
|
---|
| 93 | int IntersectableWrapper<T>::CastRay(Ray &ray)
|
---|
| 94 | { // TODO matt
|
---|
| 95 | return 0;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | template<typename T>
|
---|
| 99 | bool IntersectableWrapper<T>::IsConvex() const
|
---|
| 100 | {
|
---|
| 101 | return true;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | template<typename T>
|
---|
| 105 | bool IntersectableWrapper<T>::IsWatertight() const
|
---|
| 106 | {
|
---|
| 107 | return true;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | template<typename T>
|
---|
| 111 | float IntersectableWrapper<T>::IntersectionComplexity()
|
---|
| 112 | {
|
---|
| 113 | return 1.0f;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | template<typename T>
|
---|
| 117 | int IntersectableWrapper<T>::NumberOfFaces() const
|
---|
| 118 | {
|
---|
| 119 | return 0;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | template<typename T>
|
---|
| 123 | int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point,
|
---|
[1344] | 124 | Vector3 &normal)
|
---|
[1233] | 125 | {
|
---|
| 126 | return 0;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | template<typename T>
|
---|
| 130 | int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
[1344] | 131 | Vector3 &normal,
|
---|
| 132 | const Vector3 &viewpoint,
|
---|
| 133 | const int maxTries)
|
---|
[1233] | 134 | {
|
---|
| 135 | return 0;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | template<typename T>
|
---|
| 139 | ostream &IntersectableWrapper<T>::Describe(ostream &s)
|
---|
| 140 | {
|
---|
| 141 | s << mItem;
|
---|
| 142 | return s;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
[1344] | 146 | class KdIntersectable: public IntersectableWrapper<KdNode *>
|
---|
[1233] | 147 | {
|
---|
| 148 | public:
|
---|
| 149 | KdIntersectable(KdNode *item):
|
---|
[1344] | 150 | IntersectableWrapper<KdNode *>(item) {}
|
---|
[1233] | 151 |
|
---|
| 152 | int Type() const
|
---|
| 153 | {
|
---|
| 154 | return Intersectable::KD_INTERSECTABLE;
|
---|
| 155 | }
|
---|
[1615] | 156 |
|
---|
| 157 | AxisAlignedBox3 GetBox() const { return mBbox; }
|
---|
| 158 | AxisAlignedBox3 mBbox;
|
---|
[1233] | 159 | };
|
---|
| 160 |
|
---|
| 161 |
|
---|
[1594] | 162 | typedef map<KdNode *, KdIntersectable *> KdIntersectableMap;
|
---|
| 163 |
|
---|
[1344] | 164 | class BvhIntersectable: public IntersectableWrapper<BvhNode *>
|
---|
[1233] | 165 | {
|
---|
| 166 | public:
|
---|
| 167 | BvhIntersectable(BvhNode *item):
|
---|
[1344] | 168 | IntersectableWrapper<BvhNode *>(item) {}
|
---|
[1233] | 169 |
|
---|
| 170 | int Type() const
|
---|
| 171 | {
|
---|
| 172 | return Intersectable::BVH_INTERSECTABLE;
|
---|
| 173 | }
|
---|
| 174 | };
|
---|
| 175 |
|
---|
[1344] | 176 |
|
---|
[1328] | 177 | class TriangleIntersectable: public IntersectableWrapper<Triangle3>
|
---|
[1314] | 178 | {
|
---|
| 179 | public:
|
---|
[1344] | 180 | TriangleIntersectable(Triangle3 item):
|
---|
[1328] | 181 | IntersectableWrapper<Triangle3>(item) {}
|
---|
[1314] | 182 |
|
---|
[1328] | 183 | int CastRay(Ray &ray);
|
---|
| 184 | AxisAlignedBox3 GetBox() const;
|
---|
| 185 | int NumberOfFaces() const;
|
---|
[1344] | 186 | Vector3 GetNormal(const int idx) const;
|
---|
[1328] | 187 |
|
---|
[1314] | 188 | int Type() const
|
---|
| 189 | {
|
---|
[1328] | 190 | return Intersectable::TRIANGLE_INTERSECTABLE;
|
---|
[1314] | 191 | }
|
---|
[1586] | 192 |
|
---|
| 193 | int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal);
|
---|
[1587] | 194 |
|
---|
| 195 | int GetRandomVisibleSurfacePoint(
|
---|
| 196 | Vector3 &point,
|
---|
| 197 | Vector3 &normal,
|
---|
| 198 | const Vector3 &viewpoint,
|
---|
| 199 | const int maxTries);
|
---|
[1314] | 200 | };
|
---|
| 201 |
|
---|
| 202 |
|
---|
[1615] | 203 |
|
---|
| 204 |
|
---|
[1233] | 205 | }
|
---|
| 206 |
|
---|
[1138] | 207 | #endif
|
---|