1 | #ifndef _OGREODEGEOMETRY_H_ |
---|
2 | #define _OGREODEGEOMETRY_H_ |
---|
3 | |
---|
4 | #include "OgreOdePreReqs.h" |
---|
5 | #include "OgreOdeMaintainedList.h" |
---|
6 | |
---|
7 | namespace OgreOde |
---|
8 | { |
---|
9 | /** |
---|
10 | This object is the base class for all Geometry objects in OgreOde. |
---|
11 | @remarks |
---|
12 | This object is tied either to a Body (acting as collision proxy for a physic object) |
---|
13 | or to a Entity Object (which then is physically "static") |
---|
14 | @remarks |
---|
15 | It extends the OGRE UserDefinedObject to allow reverse links from Ogre::Entity. |
---|
16 | Note that this class does not override the UserDefinedObject's getTypeId method |
---|
17 | because this class is abstract. |
---|
18 | */ |
---|
19 | class _OgreOdeExport Geometry : public Ogre::UserDefinedObject |
---|
20 | { |
---|
21 | friend class Space; |
---|
22 | friend class World; |
---|
23 | friend class Body; |
---|
24 | friend class TransformGeometry; |
---|
25 | |
---|
26 | public: |
---|
27 | enum Class |
---|
28 | { |
---|
29 | Class_Sphere = dSphereClass, |
---|
30 | Class_Box = dBoxClass, |
---|
31 | Class_Capsule = dCapsuleClass, |
---|
32 | Class_Cylinder = dCCylinderClass, |
---|
33 | Class_InfinitePlane = dPlaneClass, |
---|
34 | Class_Ray = dRayClass, |
---|
35 | Class_TriangleMesh = dTriMeshClass, |
---|
36 | Class_Terrain = dHeightfieldClass, |
---|
37 | Class_Convex = dConvexClass, |
---|
38 | Class_Transform = dGeomTransformClass, |
---|
39 | Class_NoGeometry |
---|
40 | }; |
---|
41 | |
---|
42 | public: |
---|
43 | Geometry(World *world, Space* space = 0); |
---|
44 | virtual ~Geometry(); |
---|
45 | |
---|
46 | virtual void setBody(Body* body); |
---|
47 | Body* getBody(); |
---|
48 | |
---|
49 | |
---|
50 | virtual void setPosition(const Ogre::Vector3& position); |
---|
51 | virtual void setOrientation(const Ogre::Quaternion& orientation); |
---|
52 | virtual const Ogre::Vector3& getPosition(); |
---|
53 | virtual const Ogre::Quaternion& getOrientation(); |
---|
54 | virtual const Ogre::AxisAlignedBox& getAxisAlignedBox(); |
---|
55 | |
---|
56 | |
---|
57 | Space* getSpace(); |
---|
58 | |
---|
59 | void enable(); |
---|
60 | void disable(); |
---|
61 | bool isEnabled(); |
---|
62 | |
---|
63 | Geometry::Class getClass() const; |
---|
64 | |
---|
65 | void setCategoryBitfield(unsigned long bits); |
---|
66 | void setCollisionBitfield(unsigned long bits); |
---|
67 | unsigned long getCategoryBitfield(); |
---|
68 | unsigned long getCollisionBitfield(); |
---|
69 | |
---|
70 | int collide(Geometry* geometry, CollisionListener* listener = 0); |
---|
71 | |
---|
72 | void setMaxContacts(unsigned int max_contacts); |
---|
73 | unsigned int getMaxContacts() const; |
---|
74 | unsigned int getContactHighWaterMark() const; |
---|
75 | |
---|
76 | void setEncapsulator(Geometry* encapsulator); |
---|
77 | Geometry* getEncapsulator(){return _encapsulator;} |
---|
78 | |
---|
79 | void setUserData(unsigned long user_data){_user_data = user_data;} |
---|
80 | unsigned long getUserData() const {return _user_data;} |
---|
81 | |
---|
82 | void setUserObject(void* object){_user_object = object;} |
---|
83 | void* getUserObject(){return _user_object;} |
---|
84 | |
---|
85 | virtual unsigned long getID() const ; |
---|
86 | virtual void notify(Body* body); |
---|
87 | |
---|
88 | |
---|
89 | virtual void setDebug(const bool debug); |
---|
90 | virtual void createDebugObject(); |
---|
91 | virtual void destroyDebugObject(); |
---|
92 | void reparentDebugObject(Ogre::Node* node); |
---|
93 | |
---|
94 | virtual void setDebugContact(const bool debug); |
---|
95 | void updateDebugContact(); |
---|
96 | |
---|
97 | void clearOffset(); |
---|
98 | int isOffset(); |
---|
99 | |
---|
100 | void setOffsetPosition (const Ogre::Vector3 &position); |
---|
101 | void setOffsetQuaternion(const Ogre::Quaternion &orientation); |
---|
102 | |
---|
103 | void setOffsetWorldPosition(const Ogre::Vector3 &position); |
---|
104 | void setOffsetWorldQuaternion(const Ogre::Quaternion &orientation) ; |
---|
105 | |
---|
106 | Ogre::Vector3 getOffsetPosition() ; |
---|
107 | Ogre::Quaternion getOffsetQuaternion() ; |
---|
108 | |
---|
109 | protected: |
---|
110 | dGeomID getGeometryID() const; |
---|
111 | void registerGeometry(); |
---|
112 | dSpaceID getSpaceID(Space* space) const; |
---|
113 | |
---|
114 | protected: |
---|
115 | dGeomID _geom; |
---|
116 | unsigned int _max_contacts; |
---|
117 | unsigned int _contact_high_water_mark; |
---|
118 | unsigned int _last_contact_num; |
---|
119 | dContact* _contacts; |
---|
120 | |
---|
121 | DebugObject* _debug_obj; |
---|
122 | Ogre::Node* _debug_node; |
---|
123 | DebugContact** _debug_contacts; |
---|
124 | |
---|
125 | Geometry* _encapsulator; |
---|
126 | Ogre::AxisAlignedBox _bounding_box; |
---|
127 | Ogre::Quaternion _orientation; |
---|
128 | Ogre::Vector3 _position; |
---|
129 | |
---|
130 | static int _geometry_count; |
---|
131 | unsigned long _user_data; |
---|
132 | void* _user_object; |
---|
133 | World *_world; |
---|
134 | |
---|
135 | }; |
---|
136 | |
---|
137 | //------------------------------------------------------------------------------------------------ |
---|
138 | class _OgreOdeExport SphereGeometry:public Geometry |
---|
139 | { |
---|
140 | public: |
---|
141 | SphereGeometry(Ogre::Real radius, World *world, Space* space = 0); |
---|
142 | ~SphereGeometry(); |
---|
143 | |
---|
144 | virtual void createDebugObject(); |
---|
145 | |
---|
146 | void setRadius(Ogre::Real radius); |
---|
147 | Ogre::Real getRadius(); |
---|
148 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
149 | /** Return a string identifying the type of user defined object. |
---|
150 | @remarks |
---|
151 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
152 | */ |
---|
153 | const Ogre::String& getTypeName(void) const |
---|
154 | {static Ogre::String sName("Geometry Sphere");return sName;}; |
---|
155 | |
---|
156 | }; |
---|
157 | |
---|
158 | //------------------------------------------------------------------------------------------------ |
---|
159 | class _OgreOdeExport BoxGeometry:public Geometry |
---|
160 | { |
---|
161 | public: |
---|
162 | BoxGeometry(const Ogre::Vector3& size, World *world, Space* space = 0); |
---|
163 | ~BoxGeometry(); |
---|
164 | |
---|
165 | virtual void createDebugObject(); |
---|
166 | |
---|
167 | void setSize(const Ogre::Vector3& size); |
---|
168 | const Ogre::Vector3& getSize(); |
---|
169 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
170 | |
---|
171 | /** Return a string identifying the type of user defined object. |
---|
172 | @remarks |
---|
173 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
174 | */ |
---|
175 | const Ogre::String& getTypeName(void) const |
---|
176 | {static Ogre::String sName("Geometry Box");return sName;}; |
---|
177 | |
---|
178 | protected: |
---|
179 | Ogre::Vector3 _size; |
---|
180 | }; |
---|
181 | |
---|
182 | //------------------------------------------------------------------------------------------------ |
---|
183 | class _OgreOdeExport InfinitePlaneGeometry:public Geometry |
---|
184 | { |
---|
185 | public: |
---|
186 | InfinitePlaneGeometry(const Ogre::Plane& plane, World *world, Space* space = 0); |
---|
187 | ~InfinitePlaneGeometry(); |
---|
188 | |
---|
189 | void setDefinition(const Ogre::Plane& plane); |
---|
190 | const Ogre::Plane& getDefinition(); |
---|
191 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
192 | |
---|
193 | void setPosition(const Ogre::Vector3& position); |
---|
194 | void setOrientation(const Ogre::Quaternion& orientation); |
---|
195 | const Ogre::Vector3& getPosition(); |
---|
196 | const Ogre::Quaternion& getOrientation(); |
---|
197 | const Ogre::AxisAlignedBox& getAxisAlignedBox(); |
---|
198 | |
---|
199 | /** Return a string identifying the type of user defined object. |
---|
200 | @remarks |
---|
201 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
202 | */ |
---|
203 | const Ogre::String& getTypeName(void) const |
---|
204 | {static Ogre::String sName("Geometry Infinity Plane");return sName;}; |
---|
205 | |
---|
206 | protected: |
---|
207 | Ogre::Plane _plane; |
---|
208 | }; |
---|
209 | //------------------------------------------------------------------------------------------------ |
---|
210 | class _OgreOdeExport CapsuleGeometry:public Geometry |
---|
211 | { |
---|
212 | public: |
---|
213 | CapsuleGeometry(Ogre::Real radius, Ogre::Real length, World *world, Space* space = 0); |
---|
214 | ~CapsuleGeometry(); |
---|
215 | |
---|
216 | virtual void createDebugObject(); |
---|
217 | |
---|
218 | void setDefinition(Ogre::Real radius, Ogre::Real length); |
---|
219 | Ogre::Real getRadius(); |
---|
220 | Ogre::Real getLength(); |
---|
221 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
222 | |
---|
223 | |
---|
224 | /** Return a string identifying the type of user defined object. |
---|
225 | @remarks |
---|
226 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
227 | */ |
---|
228 | const Ogre::String& getTypeName(void) const |
---|
229 | {static Ogre::String sName("Geometry Capsule");return sName;}; |
---|
230 | |
---|
231 | }; |
---|
232 | //------------------------------------------------------------------------------------------------ |
---|
233 | class _OgreOdeExport CylinderGeometry:public Geometry |
---|
234 | { |
---|
235 | public: |
---|
236 | CylinderGeometry(Ogre::Real radius, Ogre::Real length, World *world, Space* space = 0); |
---|
237 | ~CylinderGeometry(); |
---|
238 | |
---|
239 | virtual void createDebugObject(); |
---|
240 | |
---|
241 | void setDefinition(Ogre::Real radius, Ogre::Real length); |
---|
242 | Ogre::Real getRadius(); |
---|
243 | Ogre::Real getLength(); |
---|
244 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
245 | |
---|
246 | /** Return a string identifying the type of user defined object. |
---|
247 | @remarks |
---|
248 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
249 | */ |
---|
250 | const Ogre::String& getTypeName(void) const |
---|
251 | {static Ogre::String sName("Geometry Cylinder");return sName;}; |
---|
252 | |
---|
253 | }; |
---|
254 | //------------------------------------------------------------------------------------------------ |
---|
255 | class _OgreOdeExport RayGeometry:public Geometry |
---|
256 | { |
---|
257 | public: |
---|
258 | RayGeometry(Ogre::Real length, World *world, Space* space = 0); |
---|
259 | ~RayGeometry(); |
---|
260 | |
---|
261 | virtual void createDebugObject(); |
---|
262 | |
---|
263 | void setLength(Ogre::Real length); |
---|
264 | Ogre::Real getLength(); |
---|
265 | void setDefinition(const Ogre::Vector3& start, const Ogre::Vector3& direction); |
---|
266 | const Ogre::Vector3& getStart(); |
---|
267 | const Ogre::Vector3& getDirection(); |
---|
268 | |
---|
269 | /** Return a string identifying the type of user defined object. |
---|
270 | @remarks |
---|
271 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
272 | */ |
---|
273 | const Ogre::String& getTypeName(void) const |
---|
274 | {static Ogre::String sName("Geometry Ray");return sName;}; |
---|
275 | |
---|
276 | protected: |
---|
277 | Ogre::Vector3 _direction,_start; |
---|
278 | }; |
---|
279 | |
---|
280 | //------------------------------------------------------------------------------------------------ |
---|
281 | class _OgreOdeExport TransformGeometry:public Geometry |
---|
282 | { |
---|
283 | public: |
---|
284 | TransformGeometry(World *world, Space* space); |
---|
285 | ~TransformGeometry(); |
---|
286 | |
---|
287 | virtual void createDebugObject(); |
---|
288 | virtual void destroyDebugObject(); |
---|
289 | |
---|
290 | void setEncapsulatedGeometry(Geometry* geometry); |
---|
291 | Geometry* getEncapsulatedGeometry() const; |
---|
292 | |
---|
293 | /** Return a string identifying the type of user defined object. |
---|
294 | @remarks |
---|
295 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
296 | */ |
---|
297 | const Ogre::String& getTypeName(void) const |
---|
298 | {static Ogre::String sName("Geometry Transform");return sName;}; |
---|
299 | |
---|
300 | }; |
---|
301 | //------------------------------------------------------------------------------------------------ |
---|
302 | class _OgreOdeExport TriangleMeshCollisionListener |
---|
303 | { |
---|
304 | public: |
---|
305 | TriangleMeshCollisionListener(){} |
---|
306 | virtual ~TriangleMeshCollisionListener(){} |
---|
307 | |
---|
308 | virtual bool collide(TriangleMeshGeometry* triangle_mesh, Geometry* geometry, int triangle) {return true;} |
---|
309 | }; |
---|
310 | |
---|
311 | //------------------------------------------------------------------------------------------------ |
---|
312 | class _OgreOdeExport TriangleMeshIntersectionListener |
---|
313 | { |
---|
314 | public: |
---|
315 | TriangleMeshIntersectionListener(){} |
---|
316 | virtual ~TriangleMeshIntersectionListener(){} |
---|
317 | |
---|
318 | virtual void intersect(TriangleMeshGeometry* triangle_mesh, Geometry* geometry, const int* triangles, int triangle_count){} |
---|
319 | }; |
---|
320 | |
---|
321 | //------------------------------------------------------------------------------------------------ |
---|
322 | class _OgreOdeExport TriangleMeshRayListener |
---|
323 | { |
---|
324 | public: |
---|
325 | TriangleMeshRayListener(){} |
---|
326 | virtual ~TriangleMeshRayListener(){} |
---|
327 | |
---|
328 | virtual bool collide(TriangleMeshGeometry* triangle_mesh, RayGeometry* ray,int triangle, const Ogre::Vector3& uv){return true;} |
---|
329 | }; |
---|
330 | |
---|
331 | //------------------------------------------------------------------------------------------------ |
---|
332 | struct _OgreOdeExport TriangleMeshTriangle |
---|
333 | { |
---|
334 | Ogre::Vector3 v0,v1,v2; |
---|
335 | }; |
---|
336 | |
---|
337 | //------------------------------------------------------------------------------------------------ |
---|
338 | class _OgreOdeExport TriangleMeshGeometry:public Geometry |
---|
339 | { |
---|
340 | public: |
---|
341 | TriangleMeshGeometry(const Ogre::Vector3* vertices, |
---|
342 | unsigned int vertex_count, |
---|
343 | const unsigned int* indices, |
---|
344 | unsigned int index_count, |
---|
345 | World *world, |
---|
346 | Space* space = 0); |
---|
347 | ~TriangleMeshGeometry(); |
---|
348 | |
---|
349 | Ogre::Vector3 getPoint(unsigned int index, const Ogre::Vector3& uv); |
---|
350 | TriangleMeshTriangle getTriangle(int index); |
---|
351 | |
---|
352 | void clearTemporalCoherenceCache(); |
---|
353 | void enableTemporalCoherence(Geometry::Class geometry_class,bool enable); |
---|
354 | bool isTemporalCoherenceEnabled(Geometry::Class geometry_class); |
---|
355 | |
---|
356 | static int _collisionCallback(dGeomID mesh,dGeomID object,int triangle); |
---|
357 | void setCollisionListener(TriangleMeshCollisionListener* collision_listener); |
---|
358 | |
---|
359 | static void _intersectionCallback(dGeomID mesh,dGeomID object,const int* triangles,int triangle_count); |
---|
360 | void setIntersectionListener(TriangleMeshIntersectionListener* intersection_listener); |
---|
361 | |
---|
362 | static int _rayCallback(dGeomID mesh,dGeomID ray,int triangle,dReal u,dReal v); |
---|
363 | void setRayListener(TriangleMeshRayListener* ray_listener); |
---|
364 | |
---|
365 | virtual void createDebugObject(); |
---|
366 | |
---|
367 | /** Return a string identifying the type of user defined object. |
---|
368 | @remarks |
---|
369 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
370 | */ |
---|
371 | const Ogre::String& getTypeName(void) const |
---|
372 | {static Ogre::String sName("Geometry Trimesh");return sName;}; |
---|
373 | |
---|
374 | protected: |
---|
375 | dTriMeshDataID _data; |
---|
376 | dVector3* _vertices; |
---|
377 | unsigned int* _indices; |
---|
378 | unsigned int _vertex_count; |
---|
379 | unsigned int _index_count; |
---|
380 | |
---|
381 | TriangleMeshCollisionListener* _collision_listener; |
---|
382 | TriangleMeshIntersectionListener* _intersection_listener; |
---|
383 | TriangleMeshRayListener* _ray_listener; |
---|
384 | }; |
---|
385 | |
---|
386 | //------------------------------------------------------------------------------------------------ |
---|
387 | class _OgreOdeExport ConvexGeometry:public Geometry |
---|
388 | { |
---|
389 | public: |
---|
390 | ConvexGeometry(const Ogre::Vector3* vertices, |
---|
391 | unsigned int vertex_count, |
---|
392 | const unsigned int* indices, |
---|
393 | unsigned int index_count, |
---|
394 | World *world, |
---|
395 | Space* space = 0); |
---|
396 | ~ConvexGeometry(); |
---|
397 | |
---|
398 | |
---|
399 | virtual void createDebugObject(); |
---|
400 | |
---|
401 | /** Return a string identifying the type of user defined object. |
---|
402 | @remarks |
---|
403 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
404 | */ |
---|
405 | const Ogre::String& getTypeName(void) const |
---|
406 | {static Ogre::String sName("Geometry Convex");return sName;}; |
---|
407 | |
---|
408 | protected: |
---|
409 | dReal * _vertices; |
---|
410 | unsigned int* _indices; |
---|
411 | unsigned int _vertex_count; |
---|
412 | unsigned int _index_count; |
---|
413 | }; |
---|
414 | |
---|
415 | //------------------------------------------------------------------------------------------------ |
---|
416 | class _OgreOdeExport TerrainGeometryHeightListener |
---|
417 | { |
---|
418 | public: |
---|
419 | TerrainGeometryHeightListener(){} |
---|
420 | virtual ~TerrainGeometryHeightListener(){} |
---|
421 | |
---|
422 | virtual Ogre::Real heightAt(const Ogre::Vector3& position) = 0; |
---|
423 | }; |
---|
424 | |
---|
425 | //------------------------------------------------------------------------------------------------ |
---|
426 | class _OgreOdeExport TerrainGeometry:public Geometry, public Ogre::RaySceneQueryListener |
---|
427 | { |
---|
428 | public: |
---|
429 | TerrainGeometry(World *world, |
---|
430 | Space* space, |
---|
431 | const Ogre::Vector3 &scale, |
---|
432 | int nodes_per_sideX, |
---|
433 | int nodes_per_sideY, |
---|
434 | Ogre::Real worldSizeX, |
---|
435 | Ogre::Real worldSizeZ, |
---|
436 | bool centered, |
---|
437 | Ogre::Real thickness = 10.0f); |
---|
438 | |
---|
439 | ~TerrainGeometry(); |
---|
440 | |
---|
441 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
442 | const Ogre::Vector3& getPosition(); |
---|
443 | const Ogre::Quaternion& getOrientation(); |
---|
444 | |
---|
445 | static dReal _heightCallback(void* data, dReal x, dReal z); |
---|
446 | static dReal _heightCallback(void* data, int x, int z); |
---|
447 | void setHeightListener(TerrainGeometryHeightListener* listener); |
---|
448 | |
---|
449 | inline Ogre::Real getHeightAt(const Ogre::Vector3& position) |
---|
450 | { |
---|
451 | _num_query++; |
---|
452 | const Ogre::Vector3 pos (position.x * _sample_width - (_centered?_halfWorldSizeX:0), |
---|
453 | position.y, |
---|
454 | position.z * _sample_height - (_centered?_halfWorldSizeZ:0)); |
---|
455 | _ray.setOrigin(pos); |
---|
456 | _ray_query->setRay(_ray); |
---|
457 | _distance_to_terrain = static_cast<Ogre::Real>(0.0); |
---|
458 | _ray_query->execute(this); |
---|
459 | return position.y - _distance_to_terrain; |
---|
460 | } |
---|
461 | |
---|
462 | bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance); |
---|
463 | bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance); |
---|
464 | |
---|
465 | size_t getNumQueries() const {return _num_query;}; |
---|
466 | void resetNumQueries(){_num_query = 0;}; |
---|
467 | |
---|
468 | /** Return a string identifying the type of user defined object. |
---|
469 | @remarks |
---|
470 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
471 | */ |
---|
472 | const Ogre::String& getTypeName(void) const |
---|
473 | {static Ogre::String sName("Geometry Terrain");return sName;}; |
---|
474 | |
---|
475 | protected: |
---|
476 | Ogre::Real _max_height; |
---|
477 | Ogre::Real _distance_to_terrain; |
---|
478 | Ogre::Real _sample_width, _sample_height; |
---|
479 | TerrainGeometryHeightListener* _listener; |
---|
480 | Ogre::Ray _ray; |
---|
481 | Ogre::RaySceneQuery* _ray_query; |
---|
482 | bool _centered; |
---|
483 | Ogre::Real _halfWorldSizeX; |
---|
484 | Ogre::Real _halfWorldSizeZ; |
---|
485 | size_t _num_query; |
---|
486 | }; |
---|
487 | //------------------------------------------------------------------------------------------------ |
---|
488 | class _OgreOdeExport PlaneBoundedRegionGeometryPlaneListener |
---|
489 | { |
---|
490 | public: |
---|
491 | PlaneBoundedRegionGeometryPlaneListener(){} |
---|
492 | virtual ~PlaneBoundedRegionGeometryPlaneListener(){} |
---|
493 | |
---|
494 | virtual std::list<Ogre::Plane>* planesAt(const Ogre::Vector3& position) = 0; |
---|
495 | }; |
---|
496 | |
---|
497 | //------------------------------------------------------------------------------------------------ |
---|
498 | class _OgreOdeExport PlaneBoundedRegionGeometry:public Geometry, public Ogre::RaySceneQueryListener |
---|
499 | { |
---|
500 | public: |
---|
501 | PlaneBoundedRegionGeometry(World *world, |
---|
502 | Space* space, |
---|
503 | const Ogre::AxisAlignedBox &scale); |
---|
504 | |
---|
505 | ~PlaneBoundedRegionGeometry(); |
---|
506 | |
---|
507 | Ogre::Real getPointDepth(const Ogre::Vector3& point); |
---|
508 | const Ogre::Vector3& getPosition(); |
---|
509 | const Ogre::Quaternion& getOrientation(); |
---|
510 | |
---|
511 | static std::list<Ogre::Plane> * _planeCallback(void* data, dReal x, dReal z); |
---|
512 | static std::list<Ogre::Plane> * _planeCallback(void* data, int x, int z); |
---|
513 | void setPlaneListener(PlaneBoundedRegionGeometryPlaneListener* listener); |
---|
514 | |
---|
515 | inline std::list<Ogre::Plane> *planesAt(const Ogre::Vector3& position) |
---|
516 | { |
---|
517 | _num_query++; |
---|
518 | // const Ogre::Vector3 pos (position.x * _sample_width - (_centered?_halfWorldSizeX:0), |
---|
519 | // position.y, |
---|
520 | // position.z * _sample_height - (_centered?_halfWorldSizeZ:0)); |
---|
521 | // _ray.setOrigin(pos); |
---|
522 | // _ray_query->setRay(_ray); |
---|
523 | // _distance_to_terrain = static_cast<Ogre::Real>(0.0); |
---|
524 | // _ray_query->execute(this); |
---|
525 | |
---|
526 | return _last_query_results; |
---|
527 | |
---|
528 | } |
---|
529 | |
---|
530 | bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance); |
---|
531 | bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance); |
---|
532 | |
---|
533 | size_t getNumQueries() const {return _num_query;}; |
---|
534 | void resetNumQueries(){_num_query = 0;}; |
---|
535 | |
---|
536 | /** Return a string identifying the type of user defined object. |
---|
537 | @remarks |
---|
538 | Used to differentiate between different Bodies, Geometries and prefab_object |
---|
539 | */ |
---|
540 | const Ogre::String& getTypeName(void) const |
---|
541 | {static Ogre::String sName("Geometry Plane Bounded Region");return sName;}; |
---|
542 | |
---|
543 | protected: |
---|
544 | Ogre::Real _max_height; |
---|
545 | Ogre::Real _distance_to_terrain; |
---|
546 | Ogre::Real _sample_width, _sample_height; |
---|
547 | PlaneBoundedRegionGeometryPlaneListener* _listener; |
---|
548 | Ogre::Ray _ray; |
---|
549 | Ogre::RaySceneQuery* _ray_query; |
---|
550 | bool _centered; |
---|
551 | Ogre::Real _halfWorldSizeX; |
---|
552 | Ogre::Real _halfWorldSizeZ; |
---|
553 | size_t _num_query; |
---|
554 | |
---|
555 | std::list<Ogre::Plane> *_last_query_results; |
---|
556 | }; |
---|
557 | } |
---|
558 | |
---|
559 | #endif |
---|