Walking Around the Models
This chapter looks at how to populate a scene with 3D models,
and 2D images 'pretending' to be 3D. It's also about how to
make the scene's background more realistic.
The ObjView3D application is shown in the screenshots on the right.
The key techniques developed in this chapter are:
- 3D Model Loading
Java 3D has built-in support for loading 3D models converted using the
Wavefront OBJ format. I develop a ModelLoader class that simplifies the
process, and explain how the loaded model can then be translated,
rotated, and/or scaled.
- 2D Ground Cover
The scene is decorated with 2D images which rest on the floor
(e.g. the trees in the first screenshot) and always stay oriented towards the
viewer, giving the impression that they're 3D. This is a cheap alternative
to employing real 3D models.
- Keyboard-based Movement
I've been using the Java 3D OrbitBehavior class to change the camera's
viewpoint up to now, but ObjView3D uses a KeyBehavior class instead.
Key presses move the camera forwards, backwards, left or right, rotate
it left or right, and make it float up or down. However, the camera is
prevented from descending through the floor.
- A Better Background
I look at three ways of creating a background that contains interesting
detail, and looks different when viewed from different places in
the scene. The approaches are:
- A textured-wrapped sphere (used in the first screenshot).
- A skybox (a Java 3D Box with textures pasted onto each face).
- A skybox covered with Terragen-generated textures (shown in the
second screenshot). This version is
built from quads, which gives the programmer more control over how it's positioned.
Terragen is a freeware
photorealistic landscape renderer.
Dr. Andrew Davison
Back to my home page