Navigation, Input Devices, and Collision

Navigation, Input Devices, and Collision

Chi Chung Ko, Chang Dong Cheng
Copyright: © 2009 |Pages: 21
DOI: 10.4018/978-1-59904-789-8.ch010
OnDemand:
(Individual Chapters)
Available
$37.50
No Current Special Offers
TOTAL SAVINGS: $37.50

Abstract

One of the most useful and important advantages of 3D graphics rendering and applications is that there is the possibility for the user to navigate through the 3D virtual world in a seamless fashion. Complicated visual objects can be better appreciated from different angles and manipulation of these objects can be carried out in the most natural manner. To support this important function of navigation, the user will often need to use a variety of input devices such as the keyboard, mouse, and joystick in a fashion that befits a 3D scenario. Also, collision handling is important as it will be unnatural if the user can, say, walk through solid walls in the virtual world. The functionality of navigation therefore has a close relationship with input devices and collision detection, all of which can be handled in Java 3D through a variety of straightforward but not so flexible utility classes as well as more complicated but at the same time more flexible user defined methods. The main requirement of navigation is of course to handle or refresh changes in the rendered 3D view as the user moves around in the virtual universe (Wang, 2006). As illustrated in Figure 1, this will require a modification of the platform transform as the user changes his or her position in the universe. Essentially, as will be illustrated in them next section, we will first need to retrieve the ViewPlatformTransform object from the SimpleUniverse object.
Chapter Preview
Top

Introduction

One of the most useful and important advantages of 3D graphics rendering and applications is that there is the possibility for the user to navigate through the 3D virtual world in a seamless fashion. Complicated visual objects can be better appreciated from different angles and manipulation of these objects can be carried out in the most natural manner.

To support this important function of navigation, the user will often need to use a variety of input devices such as the keyboard, mouse, and joystick in a fashion that befits a 3D scenario. Also, collision handling is important as it will be unnatural if the user can, say, walk through solid walls in the virtual world.

The functionality of navigation therefore has a close relationship with input devices and collision detection, all of which can be handled in Java 3D through a variety of straightforward but not so flexible utility classes as well as more complicated but at the same time more flexible user defined methods.

The main requirement of navigation is of course to handle or refresh changes in the rendered 3D view as the user moves around in the virtual universe (Wang, 2006). As illustrated in Figure 1, this will require a modification of the platform transform as the user changes his or her position in the universe. Essentially, as will be illustrated in the next section, we will first need to retrieve the ViewPlatformTransform object from the SimpleUniverse object.

Figure 1.

Basic view branch graph showing view platform transform

978-1-59904-789-8.ch010.f01
Top

Keyboard Navigation Using Keyboardbehavior

The keyboard is perhaps still the simplest and the most comprehensive hardware available for navigation in a 3D virtual world. To use this hardware in Java 3D, two approaches can be adopted. The most straightforward but rather rigid approach is to make use of the existing KeyNavigatorBehavior utility class, which is summarized in Figure 2. On the other hand, for more flexible behavior and performance, more programming effort can be spent to define the behavior for each individual key to suit a specific application. The former approach will be dealt with in this section, while the latter will be discussed in the next section.

Figure 2.

Using KeyNavigatorBehavior

978-1-59904-789-8.ch010.f02

Essentially, the use of the KeyNavigatorBehaviour utility class requires the following steps to be carried out:

  • Create a KeyNavigatorBehavior object for the transform group of interest.

  • Add the KeyNavigatorBehavior object to the scene graph.

  • Define appropriate bounds for the KeyNavigatorBehavior object.

Figure 3 shows the code segment for a simple example in the use of the KeyNavigatorBehavior class for navigation. Note that the navigation functionalities of the various keys are provided in Figure 2.

Figure 3.

Code segment for KeyBoardUtil.java

978-1-59904-789-8.ch010.f03

As can be seen from Figure 3, the TransformGroup for the ViewPlatform needs to be retrieved before it can be appropriately changed as the user moves. Thus, we pass the relevant SimpleUniverse object to the createSceneGraph () method in the code segment, and use it to retrieve the TransformGroup containing the ViewPlatform in line 10. Line 12 creates a new KeyNavigatorBehavior object and line 13 defines bounds for that object.

It should be emphasized that the main advantage of using KeyNavigatorBehavior is that one can use some well-known pre-defined keystrokes for navigation. However, the main disadvantage is that it may not be flexible enough for specific applications. In particular, the rate of movement or the speed at which the user moves through the virtual world cannot be changed.

Complete Chapter List

Search this Book:
Reset