Problem with animation - entity

yoda

28-07-2006 09:03:49

Hi,
i have a problem with the animations. I have created an animation in the 3DSmax program (a box wich falls on a plane). But, when i load it on my program with the oScene plugin, the entity seems to have any animation. However, the animation exists and works fine if i use:

Ogre::SceneManager::AnimationIterator animationIt = m_pSceneMgr->getAnimationIterator();
while(animationIt.hasMoreElements()) {
Ogre::Animation* animation = animationIt.getNext();

const Ogre::Animation::NodeTrackList& trackList = animation->_getNodeTrackList();

Ogre::Animation::NodeTrackList::const_iterator it = trackList.begin();
Ogre::Animation::NodeTrackList::const_iterator iend = trackList.end();
for(; it != iend; ++it) {
const Ogre::NodeAnimationTrack* track = it->second;
track->getAssociatedNode()->resetToInitialState();
}

currentTime = timeElapse;
animation->apply(currentTime);
}

This a part of the oScene main file, generated with the oFusion plugin:

<oe_scene>
<sceneManager type="0" />
<bkgcolor r="0" g="0" b="0" />
<lightColor r="0.5" g="0.5" b="0.5" />
<shadowTechnique type="0" tex_size="512" tex_count="1">
<color r="0" g="0" b="0" />
</shadowTechnique>
<entities>
<entity name="Plane01" hidden="false" filename="Plane01.mesh" CastShadows="yes" ReceiveShadows="yes">
<position x="18.0916" y="0" z="-0.848602" />
<rotation x="0" y="0" z="0" w="-1" />
<scale x="1" y="1" z="1" />
</entity>
<entity name="Box01" hidden="false" filename="Box01.mesh" CastShadows="yes" ReceiveShadows="yes">
<position x="-50.7779" y="92.1474" z="4.02789e-06" />
<rotation x="-0.707107" y="0" z="0" w="-0.707107" />
<scale x="1" y="1" z="1" />
<animations>
<animation name="boxWalk" loop="false" length="2.03333">
<keyframe time="0">
<position x="-50.7779" y="92.1474" z="4.02789e-06" />
<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="-50.7779" y="91.993" z="-1.17332e-06" />
<rotation w="-0.707107" x="-0.707107" y="0" z="0" />
<scale x="1" y="1" z="1" />
</keyframe>
.....

The results of m_pSceneMgr->getEntity( "Box01" )->getMesh()->getNumAnimations() is 0. What i want is to activate/desactive animation with : m_pSceneMgr->getEntity( "Box01" )->getAnimationState(animationName)->setEnabled( start );.
Where is the mistake? ^^

Lioric

28-07-2006 16:48:46

You can get the animation using the scene manager


Ogre::Animation* anim = mSceneMgr->getAnimation(animName);


In your example, the name of the animation you need is "boxWalk"

This animation will control all entities that are in the "boxWalk" rigid animation group