Thursday, May 31, 2012

Getting into Blender

Next up in the tutorials was 3D animations.  This is one aspect of game making that I have no experience with, so I was very interested in seeing how it was done.  I have worked a little in Blender in the past so I was not completely overwhelmed, though I was a little surprised at what I found for animations.

The jMonkeyEngine tutorials encourage (requires?) people to use the Ogre xml format, which can be output from blender using a free plugin, for 3D modeling and animation.  Looking inside one of the files generated, the skeleton.xml file, it's very interesting to see how animation works!  Basically, they have the concept of "bones" which they attach to each other in a tree, and each bone represents a different mesh in the object.  Next, the xml file will have many animations defined (walking, standing, etc), with each animation further divided into different tracks.  These tracks are used to control each bone in that animation.  In a bone's track, there are many keyframes that are locked to a specific time (in my xml file it's to the 6th decimal place of a second) which will translate, rotate, and scale that bone at that time.  Here is a small sample of a track in my xml file:

<track bone="spine">
                    <keyframes>
                        <keyframe time="0.000000">
                            <translate x="0.000000" y="-0.161123" z="0.000001"/>
                            <rotate angle="0.000000">
                                <axis x="0.000001" y="0.000005" z="1.000000"/>
                            </rotate>
                            <scale x="1.000000" y="1.000000" z="1.000000"/>
                        </keyframe>
                        <keyframe time="0.040000">
                            <translate x="0.000000" y="-0.310063" z="-0.000007"/>
                            <rotate angle="0.044933">
                                <axis x="0.000000" y="-0.000000" z="1.000000"/>
                            </rotate>
                            <scale x="1.000000" y="1.000000" z="1.000000"/>
                        </keyframe>
                        ...

This very simple animation file itself is 8801 lines long, so it's easy to see why assets in video games are what take up the vast majority of the disk space used.

Next up, picking in jMonkeyEngine!

Picture:

No comments:

Post a Comment