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