Latest version:
Tramway SDK 0.0.9
Github
Quick links
Home
Get Started

Adding Animations

First, make sure that you have installed the Blender animation exporter plugin. Next up, create a 3D model of something, create an armature for it and rig it.

Note


Tramway SDK only allows 4 bones to influence a single vertex. Take this into account when vertex weight painting. If the exporter sees that a single vertex has weights for more than 4 bones, it will pick only 4 of the vertex groups that have the greatest weight for export.

For the animations, you will need to open the Blender's Action Editor. Each exported animation will be a single action.

When creating an animation, make sure that each bone that will be animated has a keyframe at frame zero and another keyframe at the end of the animation, on whichever frame you decide to put it.

Note


Use only LocRotScale keyframes, otherwise the exporter will explode and your computer will catch on fire. This might be fixed sometime in the future.

Note


Tramway SDK only uses linear interpolation, so make sure to set it in your keyframes, so that you see the animation in Blender just like it will look like when rendered by the framework.

Note


Since animations are resources with names, do not use a name with any spaces for your action name.

After the animation or animations are finished, select File » Export » Tram Animation Exporter option. In the file dialog, navigate to /data/animations/ directory and click the Export Tram Animation button.

Each Blender action will get saved into its own animation file.

If you want an example of a rigged 3D model and an animation, take a look at the /assets/toilet.blend/ file.

Playing the animation


First, set up the 3D model.

toilet = tram.components.Render()
toilet:SetModel("toilet")
toilet:Init()

Then, let's load the Animation which we created.

animation = tram.render.animation.Find(
                    "toilet-lid-open-close")
animation:Load()

Next, let's set up the AnimationComponent, which will be playing our animation.

armature = tram.components.Animation()
armature:SetModel("toilet")
armature:Init()

After both the Render and the Animation components have been initialized, we can link them together.

toilet:SetArmature(armature)

Finally, we can play back the Animation on the AnimationComponent, which will be visible on the RenderComponent, to which we linked it to.

armature:Play("toilet-lid-open-close")


Animation being played on a 3D model.

Exercise


The example above shows only the most basic animation playback option. Try changing the animation playback parameters. Try pausing, continuing and stopping animations. Fade them in and fade them out.