Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

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


Therefore, simulating living beings using character animation gets about as complex as animation can
get without using straight coding, which as you now know is called procedural animation.
At the lowest level of character animation you have the bone; the bone uses an inverse kinematics
algorithm that tells the bone its range of movement (rotation) so you don’t have elbows that bend the wrong
way or a head that spins around like in The Exorcist! Bones are connected in a hierarchy into, you guessed
it, a skeleton. This skeleton is what you animate (keyframe) later to animate your character. You can also
simulate muscles and skin by attaching these to the bones and defining how the bone movement will flex
the muscles and stretch the skin for your character. As you might imagine, setting all of this up is a complex
process; it’s an area of character animation called rigging. If you need to add clothing, there is a new area of
3D called cloth dynamics that defines how clothing will move, wrinkle, and blow in the wind, and there are
similar procedural animation algorithms targeted at increasing realism. Let’s take a look at this next, along
with some other similarly advanced procedural animation and simulation FX algorithms.


Procedural Animation: Physics, Fluid or Cloth Dynamics, Particle Systems, Hair


The most complex type of animation is procedural animation, because it needs to be done using code, and
writing code that computes 3D vectors and matrices, along with physics and fluid dynamics equations, is
just as complex, if not more so, than game programming code (depending on the complexity of the game).
In 3D packages, this coding is usually done using C++, Python, or Java, and procedural 3D animation in your
Pro Java 9 Games Development would be accomplished by using a combination of Java 9 APIs and JavaFX 8
APIs. Procedural is the most complex but also the most powerful type of 3D animation and is the reason why
procedural animation programmers are another one of the more popular 3D job openings in the 3D film,
gaming, IoT, and interactive television (iTV) industries currently.
There are a lot of “features” in 3D modeling and animation packages such as Blender or 3D Studio
Max that are actually procedural animation algorithm plug-ins, which expose a user interface to the user
to specify parameters that will control the result of a procedural animation once it is applied to 3D models
or a complex 3D model hierarchy (created by using the 3D software or JavaFX Scene Graph, such as the
Scene Graph shown on the right in Figure 3-4). We just discussed a complex bones-rigging-muscles-skin
character model hierarchy to which cloth dynamics can be applied to make clothing move realistically with
3D characters as they run, fight, drive, dance, and so forth.
Examples of procedural animation algorithm–controlled features, many of which include real-world
physics simulation support, that are often added to advanced 3D animation software packages include 3D
particle systems, fluid dynamics, cloth dynamics, rope dynamics, hair and fur dynamics, soft body dynamics,
and rigid body dynamics.


JavaFX 3D Support: Geometry, Animation, and Scene Packages


There are three top-level packages in JavaFX that contain all of the support for both 2D and 3D new media
asset types. The javafx.geometry package supports the low-level 3D geometric constructs such as vertices,
with the Point2D and Point3D classes, and areas, using the Bounds and BoundingBox classes. The javafx.
animation package supports the low-level animation constructs such as timelines, keyframes, and motion
curves using the Timeline, KeyFrame, KeyValue, and Interpolator classes. The javafx.scene package
contains a number of nested packages, which I like to call subpackages, including javafx.scene.shape for
2D or 3D shape constructs, such as the Mesh, TriangleMesh, and MeshView classes; the javafx.scene.
transform package supporting 2D and 3D transformations, including Rotate, Scale, Shear, and Transform
classes; the javafx.scene.paint package containing shading classes like the Material and PhongMaterial
classes; and the javafx.scene.media package (MediaPlayer and MediaView classes).

Free download pdf