addressing previously created bodies

yuriythebest

11-04-2009 21:25:03

right, I've dug a slight hole for myself. I've decided to create a function that will make creating newton bodies easier, looks like so:

void mainApp1App::createNewtonBody(string objSceneNode, float objMass, string colShape)
{
//get position of original body in scene
Vector3 objPos(mSceneMgr->getSceneNode(objSceneNode)->getPosition());
//get radius of that body
float objRadius=mSceneMgr->getEntity(objSceneNode)->getBoundingRadius();
//make a rough size estimate
Vector3 objSizeGet(objRadius,objRadius,objRadius);

//add collision to body
OgreNewt::Collision* objCol;
if(colShape=="Box")
objCol = new OgreNewt::CollisionPrimitives::Box(mWorld, objSizeGet);
else if(colShape=="Ellipsoid")
objCol = new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld,objSizeGet);

//create the body
OgreNewt::Body* objBody;
objBody= new OgreNewt::Body( mWorld,objCol);
objBody->attachToNode( mSceneMgr->getSceneNode(objSceneNode));
Ogre::Vector3 objInertia = OgreNewt::MomentOfInertia::CalcBoxSolid(objMass, objSizeGet);
objBody->setMassMatrix( objMass, objInertia );
objBody->setPositionOrientation(objPos,Ogre::Quaternion::IDENTITY );

}


and example usage:

createNewtonBody("GeoSphere02", 0.01, "Box");


now up until now everything works fine, however then I decided, that after using that function, I wanted to add torque, however how do I access it? there is no mWorld->getBody function

Zero23

11-04-2009 22:20:31

OgreNewt::Body *mainApp1App::createNewtonBody(string objSceneNode, float objMass, string colShape)
{
// At the end of you function you return the pointer
return objBody;
}


I hope you understand^^

Zero

yuriythebest

12-04-2009 14:53:05

OgreNewt::Body *mainApp1App::createNewtonBody(string objSceneNode, float objMass, string colShape)
{
// At the end of you function you return the pointer
return objBody;
}


I hope you understand^^

Zero



thank you good sir I understand!