Setup body properly

majc

01-09-2008 01:29:40

I have this body setup:

Body *cWeaponCollisionHandler::createPhysicalBody(Body *body, SceneNode *node, Ogre::Vector3 position, Quaternion orientation)
{
mBody = body;
Ogre::Vector3 inertia = createInertia(mWeapon->getMass(), Ogre::Vector3(50,50,50));
setMassMatrix(body,mWeapon->getMass(),inertia);
body->setCustomForceAndTorqueCallback <cWeaponCollisionHandler>(&cWeaponCollisionHandler::setCustomForceCallback,this);
setAutoFreeze(body,false);
assignBodyToNode(body,node);
setAngularDamping(body,Ogre::Vector3(0.01f, 0.01f, 0.01f ));
setType(body,WEAPON_TYPE);
setUserData(body,this);
const MaterialID *mMatDefault = createMaterialDefault();
const MaterialID *mMatDefault2 = createMaterialDefault2();
MaterialPair *mMatPairDefault = createMaterialPair(mMatDefault,mMatDefault2);
setDefaultFriction(mMatPairDefault,1,1);
setDefaultSoftness(mMatPairDefault,1);
setDefaultElasticity(mMatPairDefault,0.0);
setContinuousCollisionMode(mMatPairDefault,1);
setMaterialGroupID(body,mMatDefault2);
body->setPositionOrientation(position,orientation);
return body;
}


im not defining any up vector but it seems the weapon is always up even if i colide with it it returns to the same position (Y axis) why?
And how i setup a body to behave like a human body? By the way the body mass is 80. and gravity (0,-70,0) i tryed 9.8 but it seems i was walking on moon.
Thanks in advance!

majc

05-09-2008 17:09:02

Anyone?

walaber

12-09-2008 19:53:57

it's hard to tell without seeing your force callback, and the calculateInertia function...

majc

15-09-2008 20:04:07

This is my custom force calback:

void cWeaponCollisionHandler::setCustomForceCallback(Body *body)
{
body->addForce(gravity * mWeapon->getMass());
}


Ogre::Vector3 cPhysicsInterface::createInertia(Real m, Ogre::Vector3 &size)
{
return Vector3::ZERO;
}


can you teel me what is wrong?

BardockSSJ

16-09-2008 13:22:50

First, use *body to get Weapon:

void cWeaponCollisionHandler::setCustomForceCallback(Body *body)
{
cWeaponCollisionHandler *mThis = (cWeaponCollisionHandler *)body->getUserData();
body->addForce(mThis->gravity * mThis->mWeapon->getMass());
}


Stop using this function!! Interia should be calculated and OGrenewt CAN

Ogre::Vector3 cPhysicsInterface::createInertia(Real m, Ogre::Vector3 &size)
{
return Vector3::ZERO;
}