provided by: 
Originally published at Internet.comJava Programming Notes #1544 * Preface * General * Acknowledgement * Viewing tip * Figures * Listings * Supplementary material * General background information * Preview * Discussion and sample code * Run the program * Summary * What's next? * Download * Resources * Complete program listing * Copyright * About the author -----------------------------------
Preface
General
Third in a series of lessons
This is the third lesson in a series of lessons designed to start with Java 3D basics and work up to the general complexity of the program that I explained in the earlier lesson titled "Understanding Lighting in the Java 3D API" (see Resources).
The first lesson in this series was titled "Back to Basics in the Java 3D API" (see Resources). The previous lesson was titled "Digging a Little Deeper into the Java 3D API." This lesson is titled "Simple Animation with the Java 3D API." My current plan is for future lessons to deal with the detailed behavior of an Alpha time-base object, user and object interaction as well as advanced animation and textures.
What you will learn
In this lesson, I will teach you how to use the RotationInterpolator and Alpha classes of the Java 3D API, along with other necessary classes, to write a simple animation program. I will also explain the rationale by which those classes are used to write animation programs.
Compiling and running Java 3D programs
In order to compile and run programs using the Java 3D API, you will need to download and install the Java 3D API software. As of the date of this writing, version 1.5.0 is available for download.
In addition, you will need to download and install either Microsoft DirectX or OpenGL. All of the sample programs in this series of tutorials were developed and tested using Microsoft DirectX. They were not tested using OpenGL.
Acknowledgement
Much of what I will be teaching you about the use of the Java 3D API was learned by studying the tutorial by Dennis J Bouvier (see Resources) along with other online material, some of which is also listed in Resources.
You can view the Bouvier tutorial online. You can also download the Bouvier tutorial as a set of PDF files along with the source code for the example programs in his tutorial.
Viewing tip
I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them.
Figures
* Figure 1. Bouvier's recipe for animation in Java 3D. * Figure 2. Four screen shots from the running animation program. * Figure 3. A screen shot from the original program. * Figure 4. New location for the white sphere. * Figure 5. Class/subclass hierarchy for the Interpolator class. * Figure 6. One of two RotationInterpolator constructors.
Listings
* Listing 1. The beginning of the program named Java3D005. * Listing 2. Create the small white sphere in a different location. * Listing 3. More code with no changes. * Listing 4. Code with an expanded purpose. * Listing 5. Some modified code. * Listing 6. Beginning of the code that implements the animation. * Listing 7. Create an Alpha object. * Listing 8. Create a RotationInterpolator object. * Listing 9. Specify the active animation region. * Listing 10. Construct the entire BranchGroup object. * Listing 11. Wrap it up. * Listing 12. Program listing for the program named Java3D005.
Supplementary material
I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find a consolidated index at www.DickBaldwin.com.
General background information
The need to understand animation
It seems that one of the first things that programming students want to do these days is to write game programs. Modern game programs almost always involve animation. Therefore, before a student can write a game program, that student must understand animation (in addition to many other important programming concepts). What is animation
According to Bouvier, "The distinction between animation and interaction is whether the behavior is activated in response to the passing of time or in response to user activities..." By this, he means that animation behavior is in response to the passage of time whereas interactive behavior is in response to user activities.
Animation versus interactive behavior
In reality, most modern game programs involve both animation and interaction (see the sidebar). This lesson will deal with animation. Interactive behavior using the Java 3D API will be reserved for a future lesson.
Simple versus advanced animation
Animation can involve some very complex programming concepts. Fortunately, simple animation is relatively easy to achieve using the Java 3D API once you understand the required structure. This lesson will concentrate on simple animation for the purpose of exposing the underlying capabilities of Java 3D in this regard. Advanced animation behavior will be reserved for a future lesson.
Bouvier's recipe for animation in Java 3D
Although it's not the only way to create animation, one way to create animation in Java 3D is through the use an Interpolator object.
Author: Richard G. Baldwin
Read article at Internet.com site