Using animations, exported from maya

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
ILY
Gnoblar
Posts: 10
Joined: Mon Aug 13, 2007 3:52 am
Location: Russia

Using animations, exported from maya

Post by ILY » Wed Aug 22, 2007 8:16 am

I am using maya exporter, and exporting node animation from Maya. It creates ".anim" file. But I do not see the way, how to load this file with OGRE. Seems like it does not have native parser for ".anim" files. Do I have to write my own parser, or I have missed something?
0 x

voxel
Gnome
Posts: 334
Joined: Wed Aug 02, 2006 9:27 am
Location: Toronto, Canada

Post by voxel » Fri Aug 24, 2007 3:17 am

You'll have to write your own .anim parser, etc..

http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

What you SHOULD do is generate an XML file like this (very similar to OGRE skeleton animation file format in XML) using MEL.

Code: Select all

<animation name="test" length="10.0">
	<tracks>
		<track>
		<keyframes>
	               <keyframe time="0">
	                    <translate x="0" y="0" z="0" />
	                    <rotate angle="0">
	                        <axis x="1" y="0" z="0" />
	                    </rotate>
	                </keyframe>
	                <keyframe time="2.5">
	                    <translate x="5.0" y="0.0" z="0" />
	                    <rotate angle="0">
	                        <axis x="1" y="0" z="0" />
	                    </rotate>
	                </keyframe>		
	                <keyframe time="5.0">
	                    <translate x="-5.0" y="0.0" z="0" />
	                    <rotate angle="0">
	                        <axis x="1" y="0" z="0" />
	                    </rotate>
	                </keyframe>		
	                <keyframe time="7.5">
	                    <translate x="0.0" y="4.0" z="0" />
	                    <rotate angle="0">
	                        <axis x="1" y="0" z="0" />
	                    </rotate>
	                </keyframe>		
	                <keyframe time="10.0">
	                    <translate x="0.0" y="0.0" z="0" />
	                    <rotate angle="0">
	                        <axis x="1" y="0" z="0" />
	                    </rotate>
	                </keyframe>		
		</keyframes>
		</track>
	</tracks>
</animation>
Then get XMLParser.cpp and AnimationParser.cpp from my Musicala engine (zlib license - do whatever you want with it):

http://sourceforge.net/projects/musicala
http://sourceforge.net/project/showfile ... _id=197381

Which parses the above XML. To use it:

Ogre::Animation* anim = NULL;
AnimationParser::parse("my_file_name", anim);
Ogre::NodeAnimationTrack* track = anim->getNodeTrack(0);
track->setAssociatedNode(node);

And in your update:

Ogre::TimeIndex t(mTime);
for(int i=0; i < anim->getNumNodeTracks(); i++)
{
Ogre::NodeAnimationTrack* track = anim->getNodeTrack(i);
track->getAssociatedNode()->setPosition(track->getAssociatedNode()->getInitialPosition());
track->apply(t);
}
mTime += seconds;
Last edited by voxel on Tue Sep 04, 2007 9:43 am, edited 1 time in total.
0 x

ILY
Gnoblar
Posts: 10
Joined: Mon Aug 13, 2007 3:52 am
Location: Russia

Post by ILY » Fri Aug 24, 2007 3:33 am

Thank you for this detailed response. I'll try it.
0 x

vladeck
Gnoblar
Posts: 9
Joined: Wed Sep 06, 2006 1:11 pm
Location: Belgrade
Contact:

Post by vladeck » Thu Oct 04, 2007 11:16 am

Code: Select all

track->getAssociatedNode()->setPosition(track->getAssociatedNode()->getInitialPosition()); 
My I ask why are you setting node to initial position before letting animation track apply position? Are translate commands in example xml relative to previous or to initial entity position?
0 x

Post Reply