Creating a subanimation

In this recipe, we're going to use SceneComposer to create subanimations. As the name implies, they're derived from an animation. Subanimations can be a good way to squeeze some extra out of stock models that don't have the exact animations you want, or if the modeler has gone home for the day. In this particular application, we'll prepare for the next recipe, which is about lip syncing. The Extract sub animation window in SDK looks, as shown in the following screenshot:

Creating a subanimation

Getting ready

The biggest caveat when creating subanimations is that the jMonkeyEngine API uses relative time when interacting with models, while subanimations are created on a frame basis. So, the easiest way to find out which frames to extract is to open the model in an external editor and look at it in parallel.

How to do it...

Extracting a subanimation can be done by performing the following steps:

  1. With the model opened in the Scene Composer, we expand AnimControl.
  2. Now, we can see all the animations that are currently available. We right-click on an animation we would like to create a subanimation out of and choose the option, Extract Sub-animation.
  3. Enter a start and end frame and it's done. The new animation is now available in the AnimControl option.

How it works...

An animation in jMonkeyEngine consists of a number of BoneTracks. Each of these has an array of floats with the times for the animations, an array of Vector3f with the positions of the bones, array of Quaternions with rotations, and another array of Vector3f's with scales. Each instance of the arrays contains information about a frame.

A subanimation is a copy of an excerpt from all the BoneTracks in the parent animation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.239.44