Chapter 16.   Loading and Manipulating External Models


[Robot PIC] It is possible to build complex geometries in Java 3D by using a subclass of GeometryArray (e.g. a QuadArray, TriangleStripArray), but there is little help available except for the "try it and see" approach. It makes much better sense to create the object using 3D modeling software, and then load it into your Java 3D application at run time.

This chapter describes two Java 3D programs which load models, placing them in the checkboard scene described in Chapter 15.

[Castle PIC] shows how a loaded object can be examined and its component shapes manipulated to change their colour, transparency, texture, and other attributes. The image at the top of this page shows a close-up of a robot that has been turned blue. shows how a loaded model's position, orientation, and size can be adjusted, and the details remembered when the model is next loaded. The second image on this page shows a castle that has been moved, rotated, and scaled.

This chapter will discuss the following Java 3D techniques:

The first three points relate to, the last two to

The main class in Loader3D, PropManager, will be used in many of the later chapters for loading external models as scenery.




Getting the Code to Work with Linux

On Linux, there are case-insensitivity problems when loading some files. For example, the code refers to "Coolrobo.3ds". but the file is actually called "COOLROBO.3DS". The case difference doesn't matter on Windows. On Linux, it triggers an error message about the file not being found.

The fix is to change the name of the file so its case matches that used in the code (e.g. rename "COOLROBO.3DS" to "Coolrobo.3ds"). There's no need to modify the Java code.


Dr. Andrew Davison
Back to my home page