180 likes | 331 Views
159.235 Graphics & Graphical Programming - Where next?. Java 3D. Sun Microsystems solution for a high level 3d graphics system Builds on lower level technologies such as OpenGL and Direct X Java3D is a (free) package library On lab image: c:j2sdk1.4.0_02demojava3d.
E N D
159.235 Graphics & Graphical Programming - Where next? Graphics
Java 3D • Sun Microsystems solution for a high level 3d graphics system • Builds on lower level technologies such as OpenGL and Direct X • Java3D is a (free) package library • On lab image: c:\j2sdk1.4.0_02\demo\java3d Graphics
The basic idea - Scenegraphs • Some conventions to help the renderer do a fast and efficient job • Rather than DIY 3d structures like we have developed ourselves in the example programs (based on 2d pieces) define a scenegraph and support only what needs to be adjusted - otherwise let the rendering engine do its own optimisation Graphics
A Scenegraph • See the Java 3D Tutorial and Manual • In brief: • We organise the world objects in a graph structure (almost a tree) • Let the renderer optimise what to display and when • Use the Object-oriented structure and concepts Graphics
Java3D Scenegraph Graphics
Java 3D Hello Universe Example public static void main( String[] args ){ new MainFrame( new HelloUniverse( ), 640, 480 ); } • See the HelloUniverse example code and the Java3D Tutorial material Graphics
Constructor public HelloUniverse( ) { Canvas3D c = new Canvas3D( null ); add( "Center", c ); // Create View Branch SimpleUniverse u = new SimpleUniverse( c ); // Create Content Branch BranchGroup scene = createSceneGraph( ); u.addBranchGraph( scene ); } Graphics
Scene Content public BranchGroup createSceneGraph( ) { BranchGroup objRoot = new BranchGroup( ); // Create the transform group node and // enable transform write by behavior TransformGroup objTrans = new TransformGroup( ); objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE ); objRoot.addChild( objTrans ); // Create a cube shape and add to scene objTrans.addChild( new ColorCube( 0.4 ) ); . . . Graphics
Rotator… // Create Behavior to rotate shape Transform3D yAxis = new Transform3D( ); Alpha rotationAlpha = new Alpha( -1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0 ); RotationInterpolator rotator = new RotationInterpolator( rotationAlpha, objTrans, yAxis, 0.0f, (float)Math.PI*2.0f ); BoundingSphere bounds = new BoundingSphere( new Point3d( 0.0, 0.0, 0.0 ), 100.0 ); rotator.setSchedulingBounds( bounds ); objTrans.addChild( rotator ); . . . Graphics
“Compile” it // Optimize scene objRoot.compile( ); return objRoot; } Graphics
You typically need to import… import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.behaviors.*; Graphics
Output like… Graphics
Java 3D Summary • VirtualUniverse - Root of all Java 3D scenes • Locale - Basic Placement • SceneGraphObject - Capabilities, User data, Liveness • Node - Bounds, LocalToVworld • NodeComponent Graphics
Java 3D - Where to Look • See the San Diego Tutorial and links • The demos are worth experimenting with • Morphing and GearBox are particularly insightful Graphics
Java 3D is latest (?) of A series of generational developments in 3D graphics 1970s - SIGGraph CORE (on terminals) 1980s - PHIGS, 3D GKS, PEX APIs Late 80’s early 90s OpenGL Late 90’s and today Java3D and competitors Other Graphics Systems Graphics
Lots of packages that use some sort of “graphics” Visual this that and the other Flash stuff Animation packages like Maya What level do you want to understand the details? Horses for Courses - what are you trying to achieve/develop? Other “Graphics Stuff” Graphics
Hopefully from this paper you know enough of the graphics jargon to be able to decide/judge what system/package to use yourselves… • You may even go on to develop new algorithms for rendering special effects that no one has even thought of yet… Graphics