Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

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


The javafx.scene.paint package contains the Material and PhongMaterial objects (classes) that allow you
to texture your 3D objects in JavaFX using different shader algorithms. Next, let’s take a closer look at what
the JavaFX API offers us to support the fourth dimension of time so that we can add 3D animation features to
your Pro Java 9 games (or IoT applications or 3D simulations).


JavaFX API 3D Animation Support: Timeline, KeyFrame, KeyValue, Interpolator


As you might imagine, most of the key (no pun intended) classes for implementing both 2D and 3D vector
animation in JavaFX are stored inside the javafx.animation package, as shown in Figure 3-8. The exception
to this is the Camera superclass and its two subclasses, PerspectiveCamera (Perspective Projection) and
ParallelCamera (Orthographic Projection). The Timeline object (class) holds the animation definition,
which is made up of KeyFrame objects (class), which are in turn made up of KeyValue objects that contain
the actual transformation instruction data. A KeyFrame object can hold an array of KeyValue objects, so a
KeyFrame can hold several different KeyValue transformation data objects. There is also an Interpolator
class that holds a number of advanced algorithms for applying motion curves to the KeyFrame objects
inside of the Timeline object. Currently supported Interpolator algorithms include DISCRETE, or discrete
time interpolation, EASE_IN and EASE_OUT as well as EASE_BOTH (easing in and also out), and LINEAR
straight line (evenly spaced) interpolation, which is obviously the least processing intensive.


Now that you have a solid (3D) overview of 2D vector illustration and 3D vector rendering and
animation concepts, we’ll take a little break before we get into game theory, concepts, optimizations, and the
like in Chapter 4.


Figure 3-8. High-level diagram of JavaFX 3D animation support, showing javafx.animation and javafx.scene
packages

Free download pdf