Java Reference
In-Depth Information
Chapter VIII
Interaction
IntroductIon
In Chapter VII, we discussed how animation can be applied in Java 3D to increase the
visual impact of a virtual 3D world and illustrate the dynamic of the various 3D objects to
the user (Tate, Moreland, & Bourne, 2001). In this chapter, we will continue this process
to make the virtual 3D universe even more interesting and appealing by adding the ability
for the user to interact with the 3D objects being rendered.
In Java 3D, both animation and interaction can be accomplished through the use of
the behavior class. Having discussed how this class helps to carry out animation in the
last chapter, we will now concentrate on the mechanism of using behavior class to achieve
interaction.
Technically, the behavior class is an abstract class with mechanisms for the scene graph
to be changed. Being an extension of the leaf class, it can also be a part of a normal scene.
In particular, it may be a leaf node in the scene graph and can be placed in the same way
as geometry is placed.
For instance, in an application where it is necessary to render and control a rotating
cube, the rotation behavior for the animation and interaction can be placed under the same
transform group as the geometry object for rendering the cube. The main objective of add-
ing a behavior object in a scene graph is of course to change the scene graph in response
to a stimulus in the form of, say, pressing a key, moving a mouse, colliding objects, or a
combination of these and other events. The change in the virtual 3D world may consist of
Search WWH ::




Custom Search