How to control a body outside the simulating world?

anileci

22-03-2007 11:21:59

Hello all!

In my game, I want to attach a SceneNode to a Player, so the SceneNode will follow the player. The SceneNode is created by nxOgre createBody(), I want to know, how to remove the body from the nxOgre world? After that I will add the node to nxOgre world again.

I have tried freezeAll, putToSleep, setKinematic, but they seem don't work for me.

thanks

betajaen

22-03-2007 11:23:55

Well if you destroy the body it'll destroy the SceneNode. Can't you just create the SceneNode by hand?

anileci

22-03-2007 14:15:40

Well if you destroy the body it'll destroy the SceneNode. Can't you just create the SceneNode by hand?

Yes, I can. But it's not what's I want.

The body is a box. My player will pick it up, running around the world. Then the player may put it down some where or throw it away. In this case, I create a body of the box at app initializing. Then in game my player will do dome non-physical move to the box. I change the box's mNode->setWorldPosition() by my code. After that, I want to throw it away by body->addForce(). But the result is the box moved to it's origin position where I picked it up. why?

I want to tell the nxOgre::world or nxOgre::scene not update() or simulate() the body. I will move it by my code.

Sorry for my poor English.

luis

22-03-2007 15:54:25

Maybe this helps....

Forget to set anything in the Ogre::SceneNode. Create a NxOgre's body for the box and when the player picks the box, for each frame just set angular/linear speed to zero and update body's position with setGlobalPosition/setGlobalOrientation.
When the player leaves the box, stop setting the speed and orientation/positions.

Ageia says that is better to avoid the use of setGlobalPosition and use moveTo (dont know about that function, but sure it is in NxOgre).
Also you could read Ageia's doc and see if there is a way to exclude the Ageia body/actor from the simulation using a flag.
EDIT: But in any of the cases i said, you have to set body's position instead of Ogre::SceneNode's position.

betajaen

22-03-2007 16:07:31

"moveTo" is my implementation. You could get away with setting the body to kinematic but it doesn't work very well with static bodies.

But setting the position by hand should be fine, but if it accidentally clips something its going to respond to that collision and may start act a little weird when forcing to move it around.

luis

22-03-2007 20:18:54

but if it accidentally clips something its going to respond to that collision and may start act a little weird when forcing to move it around.
you're right, i didn't think about it ! sure there is a flag to disable collisions....