And multiply the desired model transformation
Figure 4.19 Output from the MixedTest.java example. The grid of points (a PointArray) has been rendered into the Canvas3D in immediate mode while the ColorCube in the center was added to the scenegraph and rendered in retained mode. Also note that a background Node was used to color the background of the Canvas3D, also rendered in retained mode
RotationInterpolator rotator = new RotationInterpolator( rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI*2.0f); rotator.setSchedulingBounds(bounds);
//add the RotationInterpolator to its parent TransformGroup objTrans.addChild(rotator);
is that the immediate mode PointArray has been translated backward twice relative to the viewer—once by the transformation on the View (retained) side of the scenegraph, and once explicitly in the immediate mode code. To render the immediate mode points irrespective of any transformation already applied by virtue of the view side of the scenegraph, one would have to calculate the view transformation, invert it, and multiply it by the desired Model transformation, all before applying it to the GraphicsContext3D. By inverting the view transformation, the effect of the transformation will be canceled.
4.7.3 Summary of modes
Mix and match from the pros and cons listed above. Decide acceptable application trade−offs between performance and ease of development and extensibility.
66
5.1 Scenegraph compilation
The Java 3D system supports the concept of a “compiled” scenegraph. Compilation is typically carried out after the scenegraph structure has been built, but before it is displayed. During compilation Java 3D analyzes the elements in the scenegraph, as well as the scenegraph structure, and attempts to perform optimizations to improve rendering time and scenegraph traversal.Java 3D uses the capability bits that have been set on the scenegraph elements to identify which optimizations can be applied to the scenegraph. The capability bits that have been set for an object defines a contract between you (the application developer) and the Java 3D system. If, for example, you have not set the ALLOW_TRANSFORM_WRITE capability on a TransformGroup, the Java 3D system could use the fact that the 4 × 4 transformation matrix within the TransformGroup remains constant to optimize rendering.
5.1.1 Appearance merging and sorting
The Appearances assigned to Shape3D objects in the scenegraph are
computationally quite expensive for the scenegraph renderer. They take
up memory, and when the renderer hits an Appearance, it must make a long
and complex series of OpenGL or DirectX calls to the rendering subsystem
to add the information within the Appearance to the rendering pipeline.
Two optimizations can take place: duplicate Appearance objects can be
removed and replaced with a reference to a unique Appearance object, and
Shape3D objects can be rendered in an order such that changes in
Appearance state are minimized. These
optimizations reduce memory consumption and save on calls to the
rendering subsystem. Obviously, only Appearance objects that do not have
any WRITE capability bits set can be optimized using scenegraph
compilation.
5.2 Node
java.lang.Object
Node is an abstract base class for Group and Leaf Nodes. It defines methods to control bounding volumes (through the Bounds class), automatic computation of Bounds, collision detection and picking (mouse selection). Most important, it allows each Node to have a single parent Node. The parent Node allows arbitrarily complex scenegraph structures to be defined.
Group−derived Nodes have the ability to manage a Collection of Node−derived child objects, while Leaf−derived Nodes define the leaves of the scenegraph tree. In other words, Leaf Nodes cannot have child Nodes.