SO3Engine
OgreNewt_ContactJoint.cpp
Go to the documentation of this file.
4
5
6namespace OgreNewt
7{
8
9
10 ContactJoint::ContactJoint(const NewtonJoint* contactJoint)
11 {
12 m_contactjoint = contactJoint;
13 }
14
15
19
20
22 {
23 Contact contact(NewtonContactJointGetFirstContact(m_contactjoint), this);
24 return contact;
25 }
26
27
29 {
30 Body* body0 = getBody0();
31 Body* body1 = getBody1();
32 const World* world = body0->getWorld();
33
34 return (MaterialPair*)NewtonMaterialGetUserData(world->getNewtonWorld(), body0->getMaterialGroupID()->getID(), body1->getMaterialGroupID()->getID());
35 }
36
37
38
39 Contact::Contact(void* contact, ContactJoint* parent)
40 {
41 m_parent = parent;
42 m_contact = contact;
43 m_material = NULL;
44 if (contact)
45 {
46 m_material = NewtonContactGetMaterial(contact);
47 }
48 }
49
51 {
52 }
53
55 {
56 Contact contact(NewtonContactJointGetNextContact(m_parent->_getNewtonContactJoint(), m_contact), m_parent);
57 return contact;
58 }
59
60 Ogre::Vector3 Contact::getForce() const
61 {
62 dVector fVec;
63 NewtonMaterialGetContactForce(m_material, getBody0()->getNewtonBody(), &fVec.m_x);
64 return Ogre::Vector3(Ogre::Real(fVec.m_x), Ogre::Real(fVec.m_y), Ogre::Real(fVec.m_z));
65 }
66
68 {
69 NewtonContactJointRemoveContact(m_parent->_getNewtonContactJoint(), m_contact);
70 m_parent = NULL;
71 m_material = NULL;
72 m_contact = NULL;
73 }
74
75
76}
77
main class for all Rigid Bodies in the system.
OgreNewt::World *const getWorld() const
get a pointer to the OgreNewt::World this body belongs to.
const OgreNewt::MaterialID * getMaterialGroupID() const
get a pointer to the Material assigned to this body.
with the methods from this class you can set the behavior of each contac-point
void remove()
removes the contact from the parent contact-joint, this means newton doesn't process this contact
Ogre::Vector3 getForce() const
force of the collision
NewtonMaterial * m_material
Contact getNext() const
get the next contact from the parent contact-joint
OgreNewt::Body * getBody0() const
get the first body
OgreNewt::ContactJoint * m_parent
Contact(void *contact, ContactJoint *parent)
constructor
with this class you can iterate through all contacts
Contact getFirstContact()
get the first contact
MaterialPair * getMaterialPair()
get the MaterialPair with the basis material of this contact-joint
ContactJoint(const NewtonJoint *contactJoint)
constructor
OgreNewt::Body * getBody0()
get the first body
const NewtonJoint * _getNewtonContactJoint()
get the newton ContactJoint
OgreNewt::Body * getBody1()
get the second body
const NewtonJoint * m_contactjoint
int getID() const
get Newton-assigned material ID.
define interaction between materials
represents a physics world.
NewtonWorld * getNewtonWorld() const
retrieves a pointer to the NewtonWorld