Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 3 ■ advanCed 3d Content rendering: 3d asset ConCepts and prinCiples


The I hotkey on your keyboard is used to access this Insert Keyframe Menu, with the Cube object
selected. Most 3D software packages have what are generally termed track editors that allow you to add
keyframes and a motion curve to the tracks. Each track will relate to a 3D model, and if your 3D model
uses subcomponent grouping, then there will be tracks for groups and subgroups as well as individual
components inside of a group or subgroup.
Linear animation uses the least amount of processing power, so it is the most efficient. If you can use
linear animation to accomplish your animation objective, use the fewest number of tracks you can, and the
fewest number of keyframes, because this will use the least amount of system memory.
If the animation motion is repetitive, use a seamless loop instead of a long range. One seamless motion
loop can take up less memory than a long range containing multiple copies of the same motion. Using
looping is a great optimization principle where linear animation is concerned. Next, let’s take a look at some
of the more complex types of animation, including those that are not linear (in a straight line, with evenly
spaced keyframes) as well as character animation and procedural animation, which is used for things such
as rigid body or soft body physical (physics) simulations, cloth dynamics, hair and fur dynamics, particle
systems, and fluid dynamics, for instance.


Nonlinear Animation: Motion Paths and Motion Curves


A more complex type of nonlinear animation, which is less regular and often looks more realistic, especially
where human motion and simple physics simulation is concerned, will implement a motion path for the
animated 3D object or element (subobject in a hierarchy) to move along. JavaFX has a Path class that can
be utilized as a motion path for your own complex animation or game sprite movements. To add even more
complexity to the motion along that path, it is possible to use a motion curve so that the movement itself
can speed up or slow down, simulating things like gravity and friction. The mathematical algorithms that are
represented visually, using these motion curves, are called interpolators, and JavaFX has an Interpolator
class that contains a wide variety of the most standard (yet still quite powerful, if used effectively) motion
curve algorithms.
A good example of nonlinear irregular motion keyframing would be a rubber ball bouncing down a
curvy road. The curved path of the road would use your motion path to make sure the ball stays on the road
curvature and that the ball floor conforms to the slope (angle) of that road. The bouncing of the ball would
use a motion curve, also sometimes called a motion interpolator, to make each bounce look more realistic
regarding the timing of the acceleration and deceleration of its movement through space over time. In this
case, this would control how your ball reacts to the ground.
Figure 3-6 shows the Blender Timeline Editor at the bottom of the screen; you can see two rotation
keyframes as vertical yellow lines, with the current frame setting as a vertical green line.

Free download pdf