• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3
4<head>
5<title></title>
6<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7</head>
8<body>
9
10The <code>com.jme3.animation</code> package contains various classes
11for managing animation inside a jME3 application. Currently, the majority
12of classes are for handling skeletal animation. The primary control class is
13the {@link com.jme3.animation.AnimControl}, through which animations can be played,
14looped, combined, transitioned, etc.
15
16<h3>Usage</h3>
17
18<p>
19<code>
20// Create or load a model with skeletal animation:<br>
21Spatial model = assetManager.loadModel("...");<br>
22<br>
23// Retrieve the AnimControl.<br>
24AnimControl animCtrl = model.getControl(AnimControl.class);<br>
25<br>
26// Create an animation channel, by default assigned to all bones.<br>
27AnimChannel animChan = animCtrl.createChannel();<br>
28<br>
29// Play an animation<br>
30animChan.setAnim("MyAnim");<br>
31</code>
32<br>
33<h3>Skeletal Animation System</h3>
34<br>
35<p>
36jME3 uses a system of bone-weights: A vertex is assigned up to 4 bones by which
37it is influenced and 4 weights that describe how much the bone influences the
38vertex. The maximum weight value being 1.0, and the requirement that all 4 weights
39for a given vertex <em>must</em> sum to 1.0. This data is specified
40for each skin/mesh that is influenced by the animation control via the
41{link com.jme3.scene.VertexBuffer}s <code>BoneWeight</code> and <code>BoneIndex</code>.
42The BoneIndex buffer must be of the format <code>UnsignedByte</code>, thus
43placing the limit of up to 256 bones for a skeleton. The BoneWeight buffer
44should be of the format <code>Float</code>. Both buffers should reference 4
45bones, even if the maximum number of bones any vertex is influenced is less or more
46than 4.<br>
47If a vertex is influenced by less than 4 bones, the indices following the last
48valid bone should be 0 and the weights following the last valid bone should be 0.0.
49The buffers are designed in such a way so as to permit hardware skinning.<br>
50<p>
51The {@link com.jme3.animation.Skeleton} class describes a bone heirarchy with one
52or more root bones having children, thus containing all bones of the skeleton.
53In addition to accessing the bones in the skeleton via the tree heirarchy, it
54is also possible to access bones via index. The index for any given bone is
55arbitrary and does not depend on the bone's location in the tree hierarchy.
56It is this index that is specified in the BoneIndex VertexBuffer mentioned above
57, and is also used to apply transformations to the bones through the animations.<br>
58<p>
59Every bone has a local and model space transformation. The local space
60transformation is relative to its parent, if it has one, otherwise it is relative
61to the model. The model space transformation is relative to model space.
62The bones additionally have a bind pose transformation, which describes
63the transformations for bones when no animated pose is applied to the skeleton.
64All bones <em>must</em> have a bind pose transformation before they can be
65animated. To set the bind pose for the skeleton, set the local (relative
66to parent) transformations for all the bones using the call
67{@link com.jme3.animation.Bone#setBindTransforms(com.jme3.math.Vector3f, com.jme3.math.Quaternion) }.
68Then call {@link com.jme3.animation.Skeleton#updateWorldVectors() } followed by
69{@link com.jme3.animation.Skeleton#setBindingPose() }. <br>
70<p>
71Animations are stored in a HashMap object, accessed by name. An animation
72is simply a list of tracks, each track describes a timeline with each keyframe
73having a transformation. For bone animations, every track is assigned to a bone,
74while for morph animations, every track is assigned to a mesh.<br>
75<p>
76
77</body>
78</html>
79