• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Hierarchies

When a TransformGroup contains another TransformGroup, the effects of their Transform3D objects are combined so that all the children of the "inner" TransformGroup are affected by both sets of transforms. For example, if a Transform-Group specifies a translation of (2, 17.5, 18) and also contains a TransformGroup that specifies a translation of (3, 4.2, 27), their combined effect would be a translation of (5, 21.7, 45). Another way of looking at this is to say that the innermost TransformGroup is used to transform the coordinates of any nodes that it contains. The resulting coordinates are then transformed by the next outer TransformGroup, and so on. Each TransformGroup defines a translation, rotation, and scaling relative to the next TransformGroup up in the hierarchy.

Imagine, for example, that you're writing a Java 3D application that will display and animate a human being. Each body part in the human will be attached to the one above it ...the shin bone is connected to the thigh bone, the thigh bone connected to the hip bone, and so on. In Java 3D the concept of being "attached to" another object is expressed by being a child of the corresponding grouping object. In other words, the hip joint would be a TransformGroup object, and its children would be a Shape3D node (for the geometry of the thigh) and another TransformGroup for the knee joint. The knee joint would also have two children—a Shape3D object for the calf, and another TransformGroup object for the ankle joint. If you change the rotation of the hip joint by modifying the rotation value of the Transform3D node and then writing it back into the TransformGroup for the hip joint, all the children of that TransformGroup will be rotated around that joint. This will not only change the orientation of the Shape3D object for the thigh, it will also move the knee, the calf, the ankle, the foot, the toes, and so on. The same principles are applied to other hierarchical structures. When you rotate your shoulder, for instance, you find that your upper arm, lower arm, hands, and fingers all "come along for the ride."


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint