SO3Engine
OgreNewt_Collision.cpp
Go to the documentation of this file.
5
6
7
8namespace OgreNewt
9{
10
11
12Collision::Collision( const World* world ) : m_world(world), m_col(NULL)
13{
14}
15
16Collision::Collision( const Collision& shape) : m_world(shape.m_world), m_col(shape.m_col ? NewtonCollisionCreateInstance(shape.m_col) : NULL)
17{
18}
19
20Collision::Collision(const NewtonCollision* collision, const World* world) : m_world(world), m_col(NewtonCollisionCreateInstance(collision))
21{
22}
23
25{
27 {
28 NewtonDestroyCollision(m_col);
29 }
30}
31
32Ogre::AxisAlignedBox Collision::getAABB( const Ogre::Quaternion& orient, const Ogre::Vector3& pos ) const
33{
34 Ogre::AxisAlignedBox box;
35
36 if( m_col )
37 {
38// float matrix[16];
39// Ogre::Vector3 min, max;
40// OgreNewt::Converters::QuatPosToMatrix( orient, pos, matrix );
41// NewtonCollisionCalculateAABB( m_col, matrix, &min.x, &max.x );
42// box = Ogre::AxisAlignedBox(min, max);
43
45 box = CollisionTools::CollisionCalculateFittingAABB (ptr, orient, pos );
46 }
47 return box;
48}
49
51{
52 NewtonCollisionInfoRecord *info = new NewtonCollisionInfoRecord();
53
54 NewtonCollisionGetInfo( col, info );
55
56 return static_cast<CollisionPrimitiveType>(info->m_collisionType);
57}
58
59NewtonCollisionInfoRecord* Collision::getInfo(const NewtonCollision *col)
60{
61 NewtonCollisionInfoRecord *info = new NewtonCollisionInfoRecord();
62
63 NewtonCollisionGetInfo( col, info );
64
65 return info;
66}
67
71
72ConvexCollision::ConvexCollision(const Collision& convexShape) : Collision (convexShape)
73{
74}
75
77{
78}
79
83
84} // end NAMESPACE OgreNewt
85
represents a shape for collision detection
Ogre::AxisAlignedBox getAABB(const Ogre::Quaternion &orient=Ogre::Quaternion::IDENTITY, const Ogre::Vector3 &pos=Ogre::Vector3::ZERO) const
NewtonCollision * m_col
CollisionPrimitiveType getCollisionPrimitiveType() const
Returns the Collisiontype for this Collision.
NewtonCollisionInfoRecord * getInfo()
Returns collision info record for this collision.
virtual ~Collision()
destructor
Collision(const World *world)
constructor
represents a collision shape that is explicitly convex.
ConvexCollision(const World *world)
constructor
represents a physics world.
NewtonWorld * getNewtonWorld() const
retrieves a pointer to the NewtonWorld
_OgreNewtExport Ogre::AxisAlignedBox CollisionCalculateFittingAABB(const OgreNewt::CollisionPtr &col, const Ogre::Quaternion &orient=Ogre::Quaternion::IDENTITY, const Ogre::Vector3 &pos=Ogre::Vector3::ZERO)
calculate the AABB of a collision primitive in an arbitrary orientation