Animated platform using OgreNewt

KennyUK

20-02-2008 14:19:44

I am creating a 3d platform game using Ogre, OgreNewt and Maya as my 3D tool. As my game is made up of lots of small levels, I have made it so level construction is done completely in Maya. Currently I use the LFA scene manager to export the level to a .scene XML file and then when I load it I look for special flags in this file to set up the physics bodies for nodes that need them. This means I don't need any level-specific loading code.

This method is working well, but now I would like to have solid platforms in my levels that move on a predefined path, that my character can stand on. Again, I want to define this behaviour completely from within Maya.

I have discovered one method whereby I create a simple motion path animation in Maya and then use the native Ogre exporter to create a .anim file based on node positions at certain times.Then I will be able to parse this file and create Ogre Animation classes based on the contents.

However, am I right in saying that I can not animate objects like this if they have physics bodies attached to them? I guess this is the case because if the Ogre SceneNode is moved then the OgreNewt body will not know about this. Therefore do I need to apply forces to the bodies to animate them instead?

If that is the case then it's surely going to be a real pain to have any sort of complex path that the platform moves along!

Any suggestions will be much appreciated!

Cheers

albino

20-02-2008 16:15:12

my first thought is if you could transfrom the animation from maya

to a xml file or something where it tells coordinates where the platform is

like a path, then in ogrenewt set velocity to body like

(targetPos - currentPos) / time to move there

and when currentPos = targetPos -> new targetPos read from file and so on

KennyUK

04-03-2008 12:15:43

Managed to get my moving platforms up and running using the set velocity technique, but whenever my character moved onto the platform the platform would fall away.

From some research I found that I would need to use a UpVector joint to stop the platform rotating and a Slider joint to restrict movement to one direction. My problem is that my platforms will be moving between nodes on a path, and so each time a new node is reached the direction of the Slider joint has to be changed, so that the platform can move in a different direction. I could not find a method to change a Slider joint's direction, so I thought the only way was to destroy the current joint and create a new one, when the platform was to change direction.

e.g.

if (movement_joint != NULL)
delete movement_joint;
movement_joint = new OgreNewt::BasicJoints::Slider(body->getWorld(), body, NULL, pos, new_direction);


However, the platform does not move after this, probably because the original slider joint's contraints are still acting on it.

I notice Newton has a NewtonDestroyJoint function. Is the method I am using the correct way to destroy the joint using OgreNewt? Or is there a way to modify a slider joint's direction without destroying it?

Many thanks