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