Pros and Cons of Keyframe Animation
The advantage of using multiple models is they can be designed and created outside of Java 3D with software specific to the task (I used Poser). Model creation can be carried out independently of game development, perhaps assigned to someone skilled in 3D modeling. An animation sequence is a combination of poses, which you can mix and match. For example, the poses needed in a fighting game will be different from those in a sports game.
Several Java 3D loaders support keyframe animation. For example, the NWN loader (http://nwn-j3d.
A major drawback is the potential
Chapter 20. An
Chapter 19 was
Another issue is the increased complexity of the control code, which requires some mechanism for coordinating the movement of
There are several ways of extending the basic articulation technique, including the use of mesh deformation, morphing, and skinning, which I
Aside from commands that influence individual limbs, several affect the entire figure, moving it over the floor and rotating it around the y-axis. These commands can
be typed into the text field or entered by pressing arrow keys on the keyboard. Figure 20-3 displays the outcome of the text field commands:
f, f, c, c, f, f
This sequence causes the figure to move from its starting position at (0,0) on the floor, forward 0.6 units (2 x 0.3), 45 degrees to its right (two 22.5 degree turns), and forward another 0.6 units.
The move increment and rotation angle are hardwired into the code. An advantage of 22.5 degrees is that four turns total 90 degrees, and 16 turns bring the figure back to its original orientation.
Figure 20-4 is a view of the scene after repeating the f , f , c , c , f , f commands three times.
The figure can move up and down (i.e., it can float), but it can't be
As with the limb operations, all figure commands entered into the text field update the figure at once after Enter is pressed. The operations are carried out in the order specified by reading the input sequence from left to right. Figures 20-3 and 20-4 show that the entire figure moves and rotates as a single unit.
Figure 20-5 illustrates the result of pressing the
button in the GUI: the figure's limbs are
The figure is created by connecting together instances of the Limb class. The shape of a limb is specified using a LatheShape3D object (introduced in Chapter 17), and its appearance is derived from a texture.
As the limbs are connected, they form a parent/child hierarchy. Each limb can be given an initial orientation relative to its parent limb, and it can be rotated around its x-, y-, and z-axes at runtime. A limb may be invisible, which enables it to be used as a connector between other limbs without being rendered. For example, invisible limbs are used to connect the arms to the torso.
Though the aim is to make a limbed, human figure, the
class is sufficiently general to be used to build most kinds of articulated