Project

General

Profile

SO3Engine
OgreNewt_CollisionPrimitives.h
Go to the documentation of this file.
1/*
2 OgreNewt Library
3
4 Ogre implementation of Newton Game Dynamics SDK
5
6 OgreNewt basically has no license, you may use any or all of the library however you desire... I hope it can help you in any way.
7
8 by Walaber
9 some changes by melven
10
11*/
12#ifndef _INCLUDE_OGRENEWT_COLLISIONPRIMITIVES
13#define _INCLUDE_OGRENEWT_COLLISIONPRIMITIVES
14
15
17#include "OgreNewt_Collision.h"
18#include "OgreNewt_MaterialID.h"
19
20
21// OgreNewt namespace. all functions and classes use this namespace.
22namespace OgreNewt
23{
24
26 namespace CollisionPrimitives
27 {
30
32 class _OgreNewtExport Null : public OgreNewt::Collision
33 {
34 public:
36 Null( const World* world );
37
39 ~Null() {}
40 };
41
42
44 class _OgreNewtExport Box : public OgreNewt::ConvexCollision
45 {
46 public:
48
52 Box(const World* world);
53
55
62 Box( const World* world, const Ogre::Vector3& size, int id,
63 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
64
66 ~Box() {}
67 };
68
70 class _OgreNewtExport Ellipsoid : public OgreNewt::ConvexCollision
71 {
72 public:
74
78 Ellipsoid(const World* world);
79
81
89 Ellipsoid(const World* world, const Ogre::Vector3& size, int id,
90 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
91
94 };
95
97 class _OgreNewtExport Cylinder : public OgreNewt::ConvexCollision
98 {
99 public:
101
105 Cylinder(const World* world);
106
108
117 Cylinder( const World* world, Ogre::Real radius, Ogre::Real height, int id,
118 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
119
122 };
123
125 class _OgreNewtExport Capsule : public OgreNewt::ConvexCollision
126 {
127 public:
129
133 Capsule(const World* world);
134
136
145 Capsule( const World* world, Ogre::Real radius, Ogre::Real height, int id,
146 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
147
150 };
151
153 class _OgreNewtExport Cone : public OgreNewt::ConvexCollision
154 {
155 public:
157
161 Cone(const World* world);
162
164
173 Cone( const World* world, Ogre::Real radius, Ogre::Real height, int id,
174 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
175
177 ~Cone() {}
178 };
179
181 class _OgreNewtExport ChamferCylinder : public OgreNewt::ConvexCollision
182 {
183 public:
185
189 ChamferCylinder(const World* world);
190
192
201 ChamferCylinder( const World* world, Ogre::Real radius, Ogre::Real height, int id,
202 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
203
206 };
207
209
212 class _OgreNewtExport ConvexHull : public OgreNewt::ConvexCollision
213 {
214 public:
216
220 ConvexHull(const World* world);
221
223
234 ConvexHull( const World* world, Ogre::Entity* ent, int id = 1,
235 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO, Ogre::Real tolerance = 0.001f, const Ogre::Vector3& scale = Ogre::Vector3::UNIT_SCALE);
236
247 ConvexHull( const World* world, const Ogre::Vector3* verts, int vertcount,int id = 1,
248 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO, Ogre::Real tolerance = 0.001f );
249
252 };
253
254
256
259 class _OgreNewtExport ConcaveHull : public OgreNewt::ConvexCollision
260 {
261 public:
263
267 ConcaveHull(const World* world);
268
270
281 ConcaveHull( const World* world, Ogre::Entity* ent, int id = 1, Ogre::Real tolerance = 0.001f, const Ogre::Vector3& scale = Ogre::Vector3::UNIT_SCALE);
282
293 ConcaveHull( const World* world, const Ogre::Vector3* verts, int vertcount,int id = 1, Ogre::Real tolerance = 0.001f);
294
297 };
298
299
301
304 class _OgreNewtExport TreeCollision : public OgreNewt::Collision
305 {
306 public:
308
312 TreeCollision( const World* world);
313
315
322 TreeCollision( const World* world, Ogre::Entity* ent, bool optimize, int id, FaceWinding fw = FW_DEFAULT, const Ogre::Vector3& scale = Ogre::Vector3::UNIT_SCALE);
323 TreeCollision( const World* world, const Ogre::SceneNode* node, bool optimize, int id, FaceWinding fw = FW_DEFAULT, const Ogre::Vector3& scale = Ogre::Vector3::UNIT_SCALE);
324 void AddEntities(const Ogre::SceneNode* node, const Ogre::SceneNode* mainNode, const Ogre::Vector3 scale, FaceWinding fw = FW_DEFAULT);
326
337 TreeCollision( const World* world, int numVertices, int numIndices, const float *vertices, const int *indices, bool optimize, int id, FaceWinding fw = FW_DEFAULT);
338
340
350 TreeCollision( const World* world, int numVertices, Ogre::Vector3* vertices, Ogre::IndexData* indexData, bool optimize, int id, FaceWinding fw = FW_DEFAULT);
351
354
356 void start(int id);
357
359
364 void addPoly( Ogre::Vector3* polys, unsigned int ID );
365
367 void finish( bool optimize );
368
370
373 void setRayCastCallbackactive(bool active = true)
374 {
375 setRayCastCallbackactive( active, m_col );
376 }
377
379 //Newton >= 2.30
380 static dFloat _CDECL newtonRayCastCallback(const NewtonBody* const body, const NewtonCollision* const treeCollision, dFloat distance, dFloat* normal, int faceId, void* userData);
381 //static float _CDECL newtonRayCastCallback(float distance, float* normal, int faceId, void* userData);
382
383 private:
384 static void setRayCastCallbackactive( bool active , const NewtonCollision *col );
385
386 };
387
390
397 class _OgreNewtExport TreeCollisionSceneParser : public TreeCollision
398 {
399 public:
401
403
405 void parseScene( Ogre::SceneNode* startNode, int id, bool optimize = true, FaceWinding fw = FW_DEFAULT );
406
407 protected:
408
410
414 virtual bool entityFilter( const Ogre::SceneNode* currentNode, const Ogre::Entity* currentEntity, FaceWinding& fw ) { return true; }
415
417 virtual unsigned int getID( const Ogre::SceneNode* currentNode, const Ogre::Entity* currentEntity, unsigned int currentSubMesh ) { return count++; }
418
419 private:
421 void _parseNode( Ogre::SceneNode* node, const Ogre::Quaternion& curOrient, const Ogre::Vector3& curPos, const Ogre::Vector3& curScale, FaceWinding fw );
422
423
424 static int count;
425 };
426
428 // COMPOUND COLLISION!
429
431 class _OgreNewtExport CompoundCollision : public OgreNewt::Collision
432 {
433 public:
435
439 CompoundCollision(const World* world);
440
442
449 CompoundCollision( const World* world, std::vector<OgreNewt::CollisionPtr> col_array, int id );
450
453 };
454
455
457 // supplemental primitives built from convex hulls
459
461
465 class _OgreNewtExport Pyramid : public OgreNewt::ConvexCollision
466 {
467 public:
469
473 Pyramid(const World* world);
474
476
484 Pyramid( const World* world, const Ogre::Vector3& size, int id,
485 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY, const Ogre::Vector3& pos = Ogre::Vector3::ZERO, Ogre::Real tolerance = 0.001f );
486
489 };
490
492
497 /* Waiting for Ogre 1.7
498 class _OgreNewtExport HeightField : public OgreNewt::Collision
499 {
500 public:
501 HeightField(const World* world): OgreNewt::Collision(world){}
502 HeightField(const World* world, int width, int height, int gridsDiagonals, unsigned short *elevationMap, char *attributeMap, Ogre::Real horizontalScale, Ogre::Real verticleScale, int shapeID);
503 HeightField(const World* world, Ogre::Terrain *terrain, int shapeID);
504
505 ~HeightField(){}
506
507 private:
509 void createHeightFieldCollision(const World *world,int width,int height,int gridsDiagonals,unsigned short *elevationMap,char *attributeMap,Ogre::Real horizontalScale,Ogre::Real verticleScale,int shapeID);
510 };
511 */
512 } // end namespace CollisionPrimitives
513
514}// end namespace OgreNewt
515
516#endif // _INCLUDE_OGRENEWT_COLLISIONPRIMITIVES
517
represents a shape for collision detection
create a compound from several collision pieces.
null collision (results in no collision)
TreeCollision - complex polygonal collision.
void setRayCastCallbackactive(bool active=true)
set RayCastCallback active/disabled
TreeCollision created by parsing a tree of SceneNodes, adding collision data of all meshes.
virtual bool entityFilter(const Ogre::SceneNode *currentNode, const Ogre::Entity *currentEntity, FaceWinding &fw)
this is a user-inherited function that lets you filter which Entities will be added to the treeCollis...
virtual unsigned int getID(const Ogre::SceneNode *currentNode, const Ogre::Entity *currentEntity, unsigned int currentSubMesh)
user inherit-able function, allows customization of the ID to be assigned to this group of polygons.
represents a collision shape that is explicitly convex.
represents a physics world.