cxxD
01-05-2010 14:46:52
hi guys i cant figure out what is done in this tutorial:
http://www.ogre3d.org/wiki/index.php/Og ... n_Handling
i think i could figure out this part:
which i turned to:
and i figured out that the next thing coming is something like contact data for the colliding objects (but i dont think this is so heavily used, i just want to test collision detection first, the right behaviour is coming afterwards) but what the heck is this??:
what does it do? it makes no sense to me...
i didnt get further than that because of my bad c knowledge (its not c knowledge its vb knowledge so......)
could someone translate it entirely?
http://www.ogre3d.org/wiki/index.php/Og ... n_Handling
i think i could figure out this part:
bool MyClass::collision(OgreOde::Contact *Contact)
{
// Check for collisions between things that are connected and ignore them
OgreOde::Geometry * const g1 = Contact->getFirstGeometry();
OgreOde::Geometry * const g2 = Contact->getSecondGeometry();
if (g1 && g2)
{
const OgreOde::Body * const b1 = g2->getBody();
const OgreOde::Body * const b2 = g1->getBody();
if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2))
return false;
}
//set contact parameters:
Contact->setBouncyness(1.0);
Contact->setCoulombFriction(OgreOde::Utility::Infinity);
Contact->setForceDependentSlip(1.0);
Contact->setAdditionalFDS(1.0);
/*we have 2 collidable objects from our object system, if one of the Collide function returns false, we return false in this method, too,
else we return true, so ode computes a normal collision.
true means ode will treat this like a normal collison => rigid body behavior
false means ode will not treat this collision at all => objects ignore each other*/
bool Return = true;
if (g1->getUserAny().isEmpty() == false))
if (!any_cast<CollisionTestedObject*>(g1->getUserAny())->Collide(true, Contact))
Return = false;
if (g2->getUserAny().isEmpty() == false)
if (!any_cast<CollisionTestedObject*>(g2->getUserAny())->Collide(false, Contact))
Return = false;
return Return;
}
which i turned to:
def Collision(contact):
g1 = contact.getFirstGeometry()
g2 = contact.getSecondGeometry()
if g1 and g2:
b1 = g2.getBody()
b2 = g1.getBody()
if b1 and b2 and ode.Joint.areConnected(b1, b2):
return False
contact.setBouncyness(1)
contact.setCoulombFriction(ode.Utility.Infinity)
contact.setForceDependantSlip(1)
contact.setAdditionalFDS(1)
if g1.getUserAny().isEmpty() == false:
if g1.getUser.Any().Collide(true, contact):
return false
if g2.getUserAny().isEmpty() == false:
if g2.getUser.Any().Collide(true, contact):
return false
and i figured out that the next thing coming is something like contact data for the colliding objects (but i dont think this is so heavily used, i just want to test collision detection first, the right behaviour is coming afterwards) but what the heck is this??:
class CollisionTestedObject
{
public:
CollisionTestedObject(void);
virtual ~CollisionTestedObject(void);
/*!
\brief
This function will be called, if a geometry collides that has a user object that points to this object.
*/
bool virtual Collide(bool MineIsFirst, OgreOde::Contact *Contact) = 0;
};
what does it do? it makes no sense to me...

i didnt get further than that because of my bad c knowledge (its not c knowledge its vb knowledge so......)
could someone translate it entirely?