Problems Exporting Animation from 3dMax using Ofusion

elieajaltouni

29-05-2009 19:42:46

I am trying to export animation from 3dMax using Ofusion into ogre.
The .osm file that I got has the xml tags for the animations:

<entity name="Cylinder01" hidden="false" filename="Cylinder01.mesh" CastShadows="yes" ReceiveShadows="yes">
<position x="341.24374" y="167.05254" z="-70.647644" />
<rotation x="-0.70710677" y="0" z="-0" w="-0.70710677" />
<scale x="1" y="1" z="1" />
<animations>
<animation name="Test" loop="true" length="3.33333">
<keyframe time="0">
<position x="341.244" y="167.053" z="-70.6476" />
<rotation w="-0.707107" x="-0.707107" y="-0" z="0" />
<scale x="1" y="1" z="1" />
</keyframe>
<keyframe time="0.0333333">
<position x="341.026" y="167.053" z="-70.6476" />
<rotation w="-0.707107" x="-0.707107" y="-0" z="0" />
<scale x="1" y="1" z="1" />
</keyframe>
......


but the problem is when I am loading the scene the mesh with the animation is not moving.
Below is the code I am using to get the scene:

OSMScene oScene;
oScene.initialise("pyramidAni1.osm", NULL);
oScene.createScene();
mSceneMgr = oScene.getSceneManager();
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(0,0,500));
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
mCamera->setAspectRatio(Real(vp->getActualWidth())


Are there any extra configurations I need to do? what may be the problem?

Evak

30-05-2009 16:54:26

I'm not a coder. but I don't think node animation is a Ogre native feature but an Ofusion one. That's why it's handled inside the OSM file. Using it in code is slightly different in Ogre and has to be updated a certain way each frame. There have been a couple of threads in the forum that cover using node animation. I don't recall which off the top of my head.

Lioric

03-06-2009 23:04:38

Use the search feature, there are several threads with sample code that shows how to animate your scene, or see the oScene Loader demo application code, it contains the animation code you need, in the frame listener part

psenough

05-06-2009 09:39:51

better check the examples yourself, especially since there is a difference between different type of animations,
but this code should do what you're after:

on load scene

if (mSceneMgr->hasAnimationState("Test")) {
Ogre::AnimationState *sceneAnimState = mSceneMgr->getAnimationState("Test");
sceneAnimState->setEnable(true);
}


on frame update

float speed = 1.0f;
if (mSceneMgr->hasAnimationState("Test")) {
Ogre::AnimationState *sceneAnimState = mSceneMgr->getAnimationState("Test");
sceneAnimState->addTime( evt.timeSinceLastFrame * speed );
}

elieajaltouni

05-06-2009 15:31:52

Thanks guys!!!! It works!!