1 | #ifndef __KDINTERSECTABLE_H
|
---|
2 | #define __KDINTERSECTABLE_H
|
---|
3 |
|
---|
4 | #include "AxisAlignedBox3.h"
|
---|
5 | #include "Intersectable.h"
|
---|
6 | #include "Triangle3.h"
|
---|
7 |
|
---|
8 |
|
---|
9 | namespace GtpVisibilityPreprocessor {
|
---|
10 |
|
---|
11 |
|
---|
12 | struct VssRayContainer;
|
---|
13 | class KdNode;
|
---|
14 | class BvhNode;
|
---|
15 | struct Face;
|
---|
16 | class Ray;
|
---|
17 | struct Triangle3;
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 | /**
|
---|
22 | Wrapper used for creating a PVS compliant intersectable.
|
---|
23 | */
|
---|
24 | template<typename T>
|
---|
25 | class IntersectableWrapper: public Intersectable
|
---|
26 | {
|
---|
27 | public:
|
---|
28 | IntersectableWrapper(T item);
|
---|
29 |
|
---|
30 | /** Returns node associated with this instance.
|
---|
31 | */
|
---|
32 | T GetItem() const;
|
---|
33 |
|
---|
34 | /** See get.
|
---|
35 | */
|
---|
36 | void SetItem(T item);
|
---|
37 |
|
---|
38 |
|
---|
39 | /////////////////////////////////////////////
|
---|
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;
|
---|
51 |
|
---|
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 |
|
---|
65 | T mItem;
|
---|
66 | };
|
---|
67 |
|
---|
68 |
|
---|
69 | template<typename T>
|
---|
70 | IntersectableWrapper<T>::IntersectableWrapper(T item):
|
---|
71 | Intersectable(), mItem(item)
|
---|
72 | {
|
---|
73 | }
|
---|
74 |
|
---|
75 | template<typename T>
|
---|
76 | void IntersectableWrapper<T>::SetItem(T item)
|
---|
77 | {
|
---|
78 | mItem = item;
|
---|
79 | }
|
---|
80 |
|
---|
81 | template<typename T>
|
---|
82 | T IntersectableWrapper<T>::GetItem() const
|
---|
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,
|
---|
125 | Vector3 &normal)
|
---|
126 | {
|
---|
127 | return 0;
|
---|
128 | }
|
---|
129 |
|
---|
130 | template<typename T>
|
---|
131 | int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
132 | Vector3 &normal,
|
---|
133 | const Vector3 &viewpoint,
|
---|
134 | const int maxTries)
|
---|
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 |
|
---|
147 | class KdIntersectable: public IntersectableWrapper<KdNode *>
|
---|
148 | {
|
---|
149 | public:
|
---|
150 | KdIntersectable(KdNode *item):
|
---|
151 | IntersectableWrapper<KdNode *>(item) {}
|
---|
152 |
|
---|
153 | int Type() const
|
---|
154 | {
|
---|
155 | return Intersectable::KD_INTERSECTABLE;
|
---|
156 | }
|
---|
157 | };
|
---|
158 |
|
---|
159 |
|
---|
160 | class BvhIntersectable: public IntersectableWrapper<BvhNode *>
|
---|
161 | {
|
---|
162 | public:
|
---|
163 | BvhIntersectable(BvhNode *item):
|
---|
164 | IntersectableWrapper<BvhNode *>(item) {}
|
---|
165 |
|
---|
166 | int Type() const
|
---|
167 | {
|
---|
168 | return Intersectable::BVH_INTERSECTABLE;
|
---|
169 | }
|
---|
170 | };
|
---|
171 |
|
---|
172 |
|
---|
173 | class TriangleIntersectable: public IntersectableWrapper<Triangle3>
|
---|
174 | {
|
---|
175 | public:
|
---|
176 | TriangleIntersectable(Triangle3 item):
|
---|
177 | IntersectableWrapper<Triangle3>(item) {}
|
---|
178 |
|
---|
179 | int CastRay(Ray &ray);
|
---|
180 | AxisAlignedBox3 GetBox() const;
|
---|
181 | int NumberOfFaces() const;
|
---|
182 | Vector3 GetNormal(const int idx) const;
|
---|
183 |
|
---|
184 | int Type() const
|
---|
185 | {
|
---|
186 | return Intersectable::TRIANGLE_INTERSECTABLE;
|
---|
187 | }
|
---|
188 | };
|
---|
189 |
|
---|
190 |
|
---|
191 | }
|
---|
192 |
|
---|
193 | #endif
|
---|