Chapter 23: Java and VRML
The exercises here are taken from my forthcoming book,
The Java Developer's Resource.
- Why doesn't the Point class defined in this chapter conflict with the Point class in java.awt?
- Add an AsciiText class to the elharo.vrml package. Should this be a subclass of shape?
- 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).
- 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.
- 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.
- 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.
- 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 |
Trade Shows |
Links | FAQ |
User Groups ]
Copyright 1996 Elliotte Rusty Harold
Last Modified August 30, 1996