getting started with OgreNewt

steve7946

23-03-2006 10:59:08

hi all,

i know this has been gone over so many times but i am having trouble getting a character to move around in the newton wrold.

the following is my code i am using to setup my character:



mEntity = mSceneMgr->createEntity(name + "_entity",mesh);

mSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(name + "_scenenode");
mSceneNode->attachObject(mEntity);
mSceneNode->setFixedYawAxis(true,Vector3::UNIT_Y);

mAnimState = mEntity->getAnimationState("Walk");
mAnimState->setEnabled(true);
mAnimState->setTimePosition(0.3);
mAnimationSpeed = 1;//Math::RangeRandom(0.5, 1.5);

Quaternion q = Quaternion(Degree(90),Vector3::UNIT_Z);

//OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Cylinder(mWorld,35,100,q,Vector3(0,100,0));
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld,mSceneNode);
mBody = new OgreNewt::Body( mWorld, col );
delete col;

//Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid(10, 35,100);
Vector3 inertia(10,10,10);
mBody->setMassMatrix( 10, inertia );
mBody->setPositionOrientation(Ogre::Vector3(0,0,0), Ogre::Quaternion::IDENTITY );
mBody->attachToNode( mSceneNode );
mBody->setStandardForceCallback();
mBody->setCustomForceAndTorqueCallback(fastdelegate::MakeDelegate(this,&Character::characterForceCallback));
mBody->setAutoFreeze(0);
mBody->unFreeze();

OgreNewt::BasicJoints::UpVector* uv = new OgreNewt::BasicJoints::UpVector( mWorld, mBody, Ogre::Vector3( Ogre::Vector3::UNIT_Y) );



then for the callback i was trying to use the code from this post:

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=647&highlight=inverse+dynamics

my problem is i dont see how that code works to move the character when a key is pressed.

if anyone would be willing to send me an example of code where they have set this up or point me to somewhere that has it. at the moment i only wanted to setup the physics to improve my demo, therefore i dont have that much time to spend on it. And i am not that great with physics anyway :( , guess i should have listened more in school.

anything would be a great help, sorry to re-post something like this again. i think it would help a lot of people like me if there were a simple demo in ogrenewt like the character control in newton.