Adjusting a Model's Shape Attributes
After reporting on the model's scene graph, WrapLoaderInfo3D
's last task is to modify the model's appearance according to the user's supplied adaptation number. Many aspects of a model can be easily changed once its individual Shape3D
nodes are accessible. This
Figure 16-9. The dolphins modeldD
can be done with a variant of the examineNode()
pseudocode, concentrating only on Leaf
nodes that are Shape3D
s:
visitNode(node) { if the node is a Group { for each child of the node visitNode(child); // recursive call } else if the node is a Shape3D adjust the node's attributes; }
This pseudocode is the basis of visitNode()
in WrapLoaderInfo3D
.
The manipulation of the shape's attributes is initiated in adjustShape3D()
, which uses the adaptation number entered by the user to choose between six possibilities:
0 Makes the shape blue with makeBlue()
1 Draws the shape in outline with drawOutline()
2 Renders the shape almost transparent with makeAlmostTransparent()
3 Lays a texture over the shape with addTexture()
4 Makes the shape blue and adds a texture by calling makeBlue()
and addTexture()
- Anything else
Makes no changes at all
Turning the Shape Blue
Figure 16-10 shows the rendering of the dolphins model after being turned blue.
Figure 16-10. Blue dolphins
The Material ...
Get Killer Game Programming in Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.