Chapter 23: Java and VRML

The exercises here are taken from my forthcoming book, The Java Developer's Resource.


  1. Why doesn't the Point class defined in this chapter conflict with the Point class in java.awt?


  1. Add an AsciiText class to the elharo.vrml package. Should this be a subclass of shape?
  2. Add a two-dimensional rectangle class to the elharo.vrml package. The class should enforce the restriction that all rectangles lie in a plane (that is not be bent).
  3. Read the VRML Language Specification to learn about TransformSeparator nodes. Use these nodes to provide more efficient draw methods for the Cube, Cylinder, Cone and Sphere classes.
  4. Hard: Add rotation to the VRML package of this chapter. You need to be aware that rotation is in general not a commutative operation. That is rotating an object by 90 degrees about the z axis followed by a ninety degree rotation about the y axis will not leave it in the same place as a ninety degree rotation about the y axis followed by a ninety degree rotation about the z axis. Hint: The easiest way to handle this to store all requested rotations in a Vector and output them one at a time. This is hardly the most efficient solution though. For an efficient solution you'll need a way to describe a shape's orientation in space.
  5. The implementation of points, lines and planes used here is very inefficient.Without changing any of the public signatures, modify the world class so that it uses no more than one Coordinate3 node, one IndexedLineSet Node and one IndexedFaceSet node. You may need to add additional methods to the Point, Line and Triangle classes as well. This is fine. Just don't make those methods public.
  6. Create a VRML package that more closely maps to the structure of VRML itself, that is do not embed translations into each shape. Instead provide separate commands to move the pen. It may be possible to take an intermediate approach between these two extremes, one where location is part of the pen but the pen is always moved in an absolute sense from (0, 0, 0) rather than from the last location.

[ Exercises | Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold
Last Modified August 30, 1996