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;
|
---|
12 | class BvhNode;
|
---|
13 | struct Face;
|
---|
14 | class Ray;
|
---|
15 | struct Triangle3;
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 | /**
|
---|
20 | Wrapper used for creating a PVS compliant intersectable.
|
---|
21 | */
|
---|
22 | template<typename T>
|
---|
23 | class IntersectableWrapper: public Intersectable
|
---|
24 | {
|
---|
25 | public:
|
---|
26 | IntersectableWrapper(T *item);
|
---|
27 |
|
---|
28 | /** Returns node associated with this instance.
|
---|
29 | */
|
---|
30 | T *GetItem() const;
|
---|
31 |
|
---|
32 | /** See get.
|
---|
33 | */
|
---|
34 | void SetItem(T *item);
|
---|
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;
|
---|
47 | //int Type() const;
|
---|
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 |
|
---|
62 | T *mItem;
|
---|
63 | };
|
---|
64 |
|
---|
65 |
|
---|
66 | template<typename T>
|
---|
67 | IntersectableWrapper<T>::IntersectableWrapper(T *item):
|
---|
68 | Intersectable(), mItem(item)
|
---|
69 | {
|
---|
70 | }
|
---|
71 |
|
---|
72 | template<typename T>
|
---|
73 | void IntersectableWrapper<T>::SetItem(T *item)
|
---|
74 | {
|
---|
75 | mItem = item;
|
---|
76 | }
|
---|
77 |
|
---|
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 |
|
---|
169 | class TriangleIntersectable: public IntersectableWrapper<Triangle3>
|
---|
170 | {
|
---|
171 | public:
|
---|
172 | TriangleIntersectable(Triangle3 *item):
|
---|
173 | IntersectableWrapper<Triangle3>(item) {}
|
---|
174 |
|
---|
175 | int CastRay(Ray &ray);
|
---|
176 | AxisAlignedBox3 GetBox() const;
|
---|
177 |
|
---|
178 | int NumberOfFaces() const;
|
---|
179 |
|
---|
180 | int Type() const
|
---|
181 | {
|
---|
182 | return Intersectable::TRIANGLE_INTERSECTABLE;
|
---|
183 | }
|
---|
184 | };
|
---|
185 |
|
---|
186 |
|
---|
187 | }
|
---|
188 |
|
---|
189 | #endif
|
---|