Movement

persoontje

04-06-2006 14:12:09

Hey,

I've just started to make some test with ogre with newton for boomwar.
(http://www.sf.net/projects/boomwar It's really easier to use then irrlicht, because the integration of 3d engine and newton are much better then with irrlicht. :o :lol: :o

So I have now a Ninja model falling on the ground using a custom force callback. But how can I move him? I could check for the keys in my framehandler (i've added a custom one to the list for the character movement), and then when the A key is pressed add a force of y=1 to it. Then the callback should find it and add this, and it should work fine :P

But not. I think that it is because the callback is only called when newton thinks that there is movement of the object needed. (for example when the model is falling to the ground)

How should I do the movement?

persoontje

04-06-2006 14:55:15

Hey,

I've just started to make some test with ogre with newton for boomwar.
(http://www.sf.net/projects/boomwar It's really easier to use then irrlicht, because the integration of 3d engine and newton are much better then with irrlicht. :o :lol: :o

So I have now a Ninja model falling on the ground using a custom force callback. But how can I move him? I could check for the keys in my framehandler (i've added a custom one to the list for the character movement), and then when the A key is pressed add a force of y=1 to it. Then the callback should find it and add this, and it should work fine :P

But not. I think that it is because the callback is only called when newton thinks that there is movement of the object needed. (for example when the model is falling to the ground)

How should I do the movement?


If I set the autofreeze to zero it works. But not fine. It is like the Ninja is on ice, and after the movement he slides for while and rotate. My code is this (in my framelistener)

if ( pInputDevice->isKeyDown( KC_G))
{
movementvector.z-= (100 * movespeed);
movementvector.y+= 1;
}
pCPlayer->movement = movementvector;

The pCPlayer is stored as user object, so in the callback I just add this force: (including the standard gravity force)

void CPlayer::playerForceandTorqueCallback(OgreNewt::Body *me)
{

CPlayer* player = (CPlayer*)me->getUserData();
//apply a simple gravity force.
Ogre::Real mass;
Ogre::Vector3 inertia;

me->getMassMatrix(mass, inertia);
Ogre::Vector3 force(0,-9.8,0);
force += player->getMovement();
force *= mass;
me->addForce( force );

}


How should I do the movement? (I've also read about Ragdolls, but what are those, i'm a noob in physics :P :P )