Textures

Textures

Chi Chung Ko (National University of Singapore, Singapore) and Chang Dong Cheng (CCS Automation PTE LTD, Singapore)
Copyright: © 2009 |Pages: 17
DOI: 10.4018/978-1-59904-789-8.ch005
OnDemand PDF Download:
$37.50

Abstract

Although extensive use of basic attributes such as color and material will be able to make an object realistic to the human user, it will be time consuming to develop the code for objects that have complicated geometries or appearances. As an example, to create an object with many color patterns on, say, a curve surface, many zones or strips may need to be individually defined using the appropriate color or material properties. To save programming effort, Java 3D allows the use of what is known as texturing and image mapping, which will be the concern of this chapter. Specifically, there are four ways to apply colors to a visual object in Java 3D. The first one is to apply color by defining the color of each vertex in the associated geometry object introduced in Chapter III. Another two ways are to use the coloring attributes in an appearance object and use a material object explained in Chapter IV. Alternatively, as will be discussed in this chapter, we can also apply textures. Texturing is a simple method of giving a geometrical object a realistic appearance. While a desert landscape can be created by simply setting the coloring attribute to golden brown, the result will be dull and unrealistic. However, by using a file with a digital photo for a real desert and applying this on top of the desert geometry, a realistic desert can be constructed in the virtual 3D world (Seamless textures pack, 2006). With texturing, we have new means to add visual details without the need to have additional geometries. The image used for texturing is mapped on to the object at rendering time, and as for material and coloring attributes, the inclusion of texturing can be carried out through an appearance object (Meyer, 2006).
Chapter Preview
Top

Texture Loading

The following four steps are involved for applying textures to a geometry:

  • • Prepare texture image.

  • • Load texture.

  • • Set texture through an appearance object.

  • • Specify texture coordinates.

The preparation of the best texture image is best performed using a good imaging editing software. However, it should be noted that the sides of the image must be integer powers of two such as 128 by 256, failing which may result in a runtime exception. Java 3D accepts a variety of picture formats, including gif and jpg.

The loading of the texture image can be done from files or through URLs. Lines 1 and 2 in Figure 1 give an example on how this can be performed. Basically, the first line loads the file, picture1.gif, to create an ImageComponent2D object, which can then be used by an appearance object. Note that image loading in Java 3D requires an image observer, which can be any of the AWT components and is specified in the second argument in line 1. The image observer is for the purpose of monitoring the image load process and can be queried on details concerning this process.

Figure 1.

Loading texture

In addition to the previous method, the loading of images can also be performed by using the NewTextureLoader class, which is an extension of the TextureLoader class. This new class eliminates the need to specify an image observer component every time TextureLoader is instantiated. Rather, the image observer only needs to be specified once.

Having loaded the image, the created ImageComponent2D object must be added to the appropriate appearance bundle. The code segment from lines 4 to 7 in Figure 1 illustrates how this can be done.

Top

Texture Coordinates

After loading the texture image and adding the created texture object to an appearance, we will now need to specify the texture coordinates that will be applied to each of all the vertices of the geometry object. This serves to define the 2D mapping that maps the 2D texture image to each face of the geometry object.

Complete Chapter List

Search this Book:
Reset
Table of Contents
Preface
Chi Chung Ko
Chapter 1
Chi Chung Ko, Chang Dong Cheng
Web-based virtual reality is fast becoming an important application and technological tools in the next generation of games and simulation as well... Sample PDF
Virtual Reality and Java 3D
$37.50
Chapter 2
Java 3D Overview  (pages 18-31)
Chi Chung Ko, Chang Dong Cheng
In the last chapter, a brief introduction on the creation of 3D content through the use of Java 3D and other programming methodologies for virtual... Sample PDF
Java 3D Overview
$37.50
Chapter 3
Geometry Objects  (pages 32-74)
Chi Chung Ko, Chang Dong Cheng
To create 3D graphics, we have to build graphics or visual objects and position them appropriately in a virtual scene. In general, there are three... Sample PDF
Geometry Objects
$37.50
Chapter 4
Appearance Objects  (pages 75-96)
Chi Chung Ko, Chang Dong Cheng
In the last chapter, the creation of the skeletons or shapes of 3D objects has been discussed through the use of geometry objects in Java 3D. In... Sample PDF
Appearance Objects
$37.50
Chapter 5
Textures  (pages 97-113)
Chi Chung Ko, Chang Dong Cheng
Although extensive use of basic attributes such as color and material will be able to make an object realistic to the human user, it will be time... Sample PDF
Textures
$37.50
Chapter 6
Chi Chung Ko, Chang Dong Cheng
How the properties of virtual 3D objects can be specified and defined has been discussed in earlier chapters. However, how a certain virtual object... Sample PDF
Lighting, Fog, and Background
$37.50
Chapter 7
Animation Objects  (pages 132-158)
Chi Chung Ko, Chang Dong Cheng
We have discussed important Java 3D objects that are basically static in the last few chapters. Starting from this chapter, we will be looking at... Sample PDF
Animation Objects
$37.50
Chapter 8
Interaction  (pages 159-187)
Chi Chung Ko, Chang Dong Cheng
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... Sample PDF
Interaction
$37.50
Chapter 9
Picking  (pages 188-216)
Chi Chung Ko, Chang Dong Cheng
The last two chapters have discussed how animation and interaction can be created in Java 3D to increase visual impact, to show object dynamics and... Sample PDF
Picking
$37.50
Chapter 10
Chi Chung Ko, Chang Dong Cheng
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... Sample PDF
Navigation, Input Devices, and Collision
$37.50
Chapter 11
Multiple Views  (pages 238-263)
Chi Chung Ko, Chang Dong Cheng
Our discussions in previous chapters have centered on the creation and interaction of visual objects in a virtual 3D world. The objects and scenes... Sample PDF
Multiple Views
$37.50
Chapter 12
Audio  (pages 264-275)
Chi Chung Ko, Chang Dong Cheng
Of all the human perceptions, two of the most important ones are perhaps vision and sound, for which we have developed highly specialized sensors... Sample PDF
Audio
$37.50
Chapter 13
Chi Chung Ko, Chang Dong Cheng
In this final chapter, we will describe the use of Java 3D as a visualization technology in the development of a Web-based 3D real time oscilloscope... Sample PDF
A Web-Based 3D Real Time Oscilloscope Experiment
$37.50
Appendix A: Downloading Software
Appendix B: Running the Rotating Cube Program
Appendix C: ViewManager
Appendix D: Main Applet for Web-Based 3D Experiment
Appendix E: Scene Graph Implementation for Web-Based 3D Experiment
Appendix F: Knob Class for Web-Based 3D Experiment
Appendix G: Navigation and Collision Detection for Web-Based 3D Experiment
Appendix H: Picking for Web-Based 3D Experiment
Appendix I: Program Summary and Screen Capture
About the Authors