A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.
-
Upload
moses-stokes -
Category
Documents
-
view
214 -
download
0
Transcript of A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.
![Page 1: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/1.jpg)
A Simple Talk on Java A Simple Talk on Java 3D3D
A Simple Talk on Java A Simple Talk on Java 3D3D
Presented by C.H. Chen on Jul. 6, 2004Presented by C.H. Chen on Jul. 6, 2004
![Page 2: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/2.jpg)
Outlines• Introduction• Deployment of your Development Environment• Understanding Java 3D• Demo
![Page 3: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/3.jpg)
Introduction
![Page 4: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/4.jpg)
Introduction
![Page 5: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/5.jpg)
Introduction• Flight simulators and medical-imaging• Developments in high-performance hardware led to developments
in high-performance graphics APIs— beginning in the 1970s with Siggraph’s CORE API, continuing in the 1980s with SGI’s OpenGL and on through today with MS’s Direct3D and Java 3D.
• 3D Graphic• Java 3D: high-level graphic-programming API write once run anywhere simplifying the complex graphics
![Page 6: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/6.jpg)
Introduction• Four major goals of Java 3D APIs -application portability -hardware independence -performance scalibility -ability to produce 3D graphics over a network
![Page 7: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/7.jpg)
Introduction
![Page 8: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/8.jpg)
Introduction• Features of Java 3D for development - Behavior - Fog - Geometry - Light - Sound - Texture
![Page 9: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/9.jpg)
Deployment of your Development Environment
• Requirement: J2SE or J2EE, OpenGL or Direct X• Java 3D API 1.3.1 (current version)• http://java.sun.com/product/java-media/3D• other IDE : eg. Java 3D NetBeans Module 1.0 beta
![Page 10: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/10.jpg)
Deployment of your Development Environment
![Page 11: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/11.jpg)
Understanding Java 3D
![Page 12: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/12.jpg)
Understanding Java 3D
![Page 13: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/13.jpg)
Understanding Java 3D• Scene : Virtual Universe• VirtualUniverse• Scene Graph
![Page 14: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/14.jpg)
Understanding Java 3D
![Page 15: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/15.jpg)
Understanding Java 3D
![Page 16: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/16.jpg)
Understanding Java 3D
![Page 17: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/17.jpg)
Understanding Java 3D
![Page 18: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/18.jpg)
Understanding Java 3D
![Page 19: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/19.jpg)
Understanding Java 3D
![Page 20: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/20.jpg)
Understanding Java 3D
![Page 21: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/21.jpg)
Understanding Java 3D
![Page 22: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/22.jpg)
Understanding Java 3D
![Page 23: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/23.jpg)
Understanding Java 3D
![Page 24: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/24.jpg)
Understanding Java 3D
• Partial subclasses of - Group : BranchGroup, Switch TransformGroup … - Leaf : Behavior, Light, Shape3D ViewPlatform … - NodeComponent : Appearance, Material Texture …
![Page 25: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/25.jpg)
Understanding Java 3D
![Page 26: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/26.jpg)
Understanding Java 3D
![Page 27: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/27.jpg)
Understanding Java 3D
![Page 28: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/28.jpg)
Understanding Java 3D• SimpleUniverse class creates a scene graph including: VirtualUniverse, locale objects, complete view branch graph• View branch graph ViewingPlatform, viewer
![Page 29: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/29.jpg)
Understanding Java 3D
![Page 30: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/30.jpg)
Understanding Java 3D
![Page 31: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/31.jpg)
Understanding Java 3D
![Page 32: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/32.jpg)
Sample code tracing// Java extension packagesimport javax.swing.event.*;import javax.media.j3d.*;import javax.vecmath.*;
// Java3D utility packagesimport com.sun.j3d.utils.universe.*;import com.sun.j3d.utils.image.*;import com.sun.j3d.utils.geometry.*;import com.sun.j3d.utils.behaviors.mouse.*;
![Page 33: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/33.jpg)
public class Java3DWorld extends Canvas3D { private Appearance appearance; // 3D object's appearance private Light ambientLight; // ambient scene lighting private Box shape; // 3D object to manipulate private Color3f lightColor; // Light color private Light directionalLight; private Material material; // 3D objects color object private SimpleUniverse simpleUniverse; // 3D scene environment private TextureLoader textureLoader; // 3D object's texture // holds 3D transformation information private TransformGroup transformGroup; private String imageName; // texture image file name // Java3DWorld constructor public Java3DWorld( String imageFileName ) { super( SimpleUniverse.getPreferredConfiguration() ); imageName = imageFileName;
![Page 34: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/34.jpg)
Sample code tracing // create SimpleUniverse ( 3D Graphics environment ) simpleUniverse = new SimpleUniverse( this ); // set viewing distance for 3D scene ViewingPlatform viewPlatform = simpleUniverse.getViewingPlatform(); viewPlatform.setNominalViewingTransform(); // create 3D scene BranchGroup branchGroup = createScene(); // attach BranchGroup to SimpleUniverse simpleUniverse.addBranchGraph( branchGroup ); } // end Java3DWorld constructor
5
![Page 35: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/35.jpg)
// create 3D scene public BranchGroup createScene() { BranchGroup scene = new BranchGroup(); // initialize TransformGroup transformGroup = new TransformGroup(); // set TransformGroup's WRITE permission transformGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE ); transformGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_READ ); // add TransformGroup to BranchGroup scene.addChild( transformGroup ); // create BoundingSphere BoundingSphere bounds = new BoundingSphere( new Point3d( 0.0f, 0.0f, 0.0f ), 100.0 );
1
![Page 36: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/36.jpg)
appearance = new Appearance(); // create object appearance material = new Material(); // create texture matieral appearance.setMaterial( material ); String rgb = new String( "RGB" ); // load texture for scene object textureLoader = new TextureLoader( Java3DWorld.class.getResource( imageName ), rgb, this ); // set capability bits for enabling texture textureLoader.getTexture().setCapability( Texture.ALLOW_ENABLE_WRITE ); // initial texture will not show textureLoader.getTexture().setEnable( false ); // set object's texture appearance.setTexture( textureLoader.getTexture() ); Box.GENERATE_NORMALS | Box.GENERATE_TEXTURE_COORDS, appearance );
![Page 37: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/37.jpg)
// add geometry to TransformGroup transformGroup.addChild( shape ); // initialize Ambient lighting ambientLight = new AmbientLight(); ambientLight.setInfluencingBounds( bounds ); // initialize directionalLight directionalLight = new DirectionalLight(); lightColor = new Color3f(); // initialize light color // set initial DirectionalLight color directionalLight.setColor( lightColor ); // set capability bits to allow DirectionalLight's // Color and Direction to be changed directionalLight.setCapability( DirectionalLight.ALLOW_DIRECTION_WRITE ); directionalLight.setCapability( DirectionalLight.ALLOW_DIRECTION_READ );
2
![Page 38: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/38.jpg)
directionalLight.setCapability( DirectionalLight.ALLOW_COLOR_WRITE ); directionalLight.setCapability( DirectionalLight.ALLOW_COLOR_READ ); directionalLight.setInfluencingBounds( bounds ); // add light nodes to BranchGroup scene.addChild( ambientLight ); scene.addChild( directionalLight ); // initialize rotation behavior MouseRotate rotateBehavior = new MouseRotate(); rotateBehavior.setTransformGroup( transformGroup ); rotateBehavior.setSchedulingBounds( bounds ); // initialize translation behavior MouseTranslate translateBehavior = new MouseTranslate(); translateBehavior.setTransformGroup( transformGroup ); translateBehavior.setSchedulingBounds( new BoundingBox( new Point3d( -1.0f, -1.0f, -1.0f ), new Point3d( 1.0f, 1.0f, 1.0f ) ) );
3
![Page 39: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/39.jpg)
// initialize scaling behavior MouseZoom scaleBehavior = new MouseZoom(); scaleBehavior.setTransformGroup( transformGroup ); scaleBehavior.setSchedulingBounds( bounds ); // add behaviors to BranchGroup scene.addChild( scaleBehavior ); scene.addChild( rotateBehavior ); scene.addChild( translateBehavior ); scene.compile(); return scene; } // end method createScene
4
![Page 40: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/40.jpg)
Scene Graph of sample code
BG
TG
S
BL
Appearance Geometry
5
1
2
3 4
![Page 41: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/41.jpg)
Demo• Java 3D demo• Java 3D Fly Through v 1.0
![Page 42: A Simple Talk on Java 3D Presented by C.H. Chen on Jul. 6, 2004.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e915503460f94b968f9/html5/thumbnails/42.jpg)
References
• Sun Microsystem Java 3D http://java.sun.com/products/java-media/3D/• Java 3D Tutorial• Java 3D Scene Graph Editor http://java3d.netbeans.org/• http://java.sun.com/products/java-media/3D/coll
ateral/presentation/index.html• Sample code: Advanced Java how to program