< Zurück | Inhalt | Weiter >

From RotatingGeometryUpdater.java


/**


* Implementation of the GeometryUpdater interface


* that rotates the scene by changing the viewer position


* and the scale factor for the model.


*/


public class RotatingGeometryUpdater implements GeometryUpdater


{


long lastFrame = −1;

public RotatingGeometryUpdater ( )


{


}


public boolean update( Graphics graphics, RenderingEngine engine, GeometryArray geometry, int index, long frameNumber )

{


if ( lastFrame != frameNumber )


{


lastFrame = frameNumber;


Vector3d viewAngle = engine.getViewAngle( ); viewAngle.x += 1;

engine.setViewAngle( viewAngle );


}


return false;


}


}


image


The MyJava3D class pulls all of these elements together. It creates an AwtRenderingEngine instance, loads a GeometryArray from disk using a Java 3D ObjectFile object loader, adds the GeometryArray to the AwtRenderingEngine, constructs a RenderingSurface supplying a RotatingGeometryUpdater, starts the RenderingSurface, and then adds it to the content pane of the JFrame that hosts the application.