1 / 20

CSC 308 – Graphics Programming

CSC 308 – Graphics Programming. Java 3D – New Geometry Content Information from online tutorial at http://java.sun.com/developer/onlineTraining/java3d/. Dr. Paige H. Meeker Computer Science Presbyterian College, Clinton, SC. Creating New Content in Java 3D.

lloyd
Download Presentation

CSC 308 – Graphics Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 308 – Graphics Programming Java 3D – New Geometry Content Information from online tutorial at http://java.sun.com/developer/onlineTraining/java3d/ Dr. Paige H. Meeker Computer Science Presbyterian College, Clinton, SC

  2. Creating New Content in Java 3D There are three major ways to create new geometric content using Java3D: • Use the Geometric Utility Classes • Specify Vertex Coordinates • Use a Geometry Loader

  3. Shape3D Objects • Defines a visual object • Can only be a leaf of the scene graph • Does not contain information about shape or color • Refers to node component objects to obtain geometry and appearance

  4. Node Components • Contain exact specifications of attributes of visual objects

  5. Geometry Utility Classes • Box • Cone • Cylinder • Sphere • Inside the com.sun.j3d.utils.geometry package

  6. Creating a Yoyo using two cones public ConeYoyo() { yoyoBG = new BranchGroup(); Transform3D rotate = new Transform3D(); Appearance yoyoAppear = new Appearance(); rotate.rotZ(Math.PI/2.0d); TransformGroup yoyoTGR1 = new TransformGroup(rotate); translate.set(new Vector3f(0.1f,0.0f,0.0f); TransformGroup yoyoTGT1 = new TransformGroup(translate); Cone cone1 = new Cone(0.6f, 0.2f); cone1.setAppearance(yoyoAppear); yoyoBG.addChild(yoyoTGT1); yoyoTGT1.addChild(yoyoTGR1); yoyoTGR1.addChild(cone1); translate.set(newVector3f(-0.1f, 0.0f, 0.0f); TransformGroup yoyoTGT2 = new TransformGroup(translate); rotate.rotZ(-Math.PI/2.0d); TransformGroup yoyoTGR2 = new TransformGroup(rotate); Cone cone2 = new Cone(0.6f, 0.2f); cone2.setAppearance(yoyoAppear); yoyoBG.addChild(yoyo.TGT2); yoyoTGT2.addChild(yoyoTGR2); yoyoTGR2.addChild(cone2); yoyoGB.compile(); } // end of ConeYoyo constructor

  7. Mathematical Classes • Found in javax.vecmath.* • Each vertex of a visual object made up of up to four javax.vecmath objects – commonly: • Point (for coordinates) • Color (for colors) • Vector (for surface normals) • TexCoord (for texture coordinates)

  8. Point* • Point classes represent • the coordinates of a vertex • Position of a raster image • Point light sources • Spatial location of a sound

  9. Color* • Color classes represent a color for • A vertex • A material property • Fog • Other visual object

  10. Vector* • Vector classes represent • A surface normal • Direction of light source • Direction of sound source

  11. TexCoord* • Two types – used to represent a set of texture coordinates at a vertex • TexCoord2f – maintains texture coordinates as an (s,t) coordinate pair • TexCoord3f – maintains texture coordinates as an (s,t,r) coordinate triple

  12. Geometry Classes

  13. GeometryArray subclasses

  14. Geometry Strip Array

  15. Appearance Bundle • Refers to several different NodeComponent subclasses called appearance attribute objects • PointAttributes • LineAttributes • PolygonAttributes • ColoringAttributes • TransparencyAttributes • RenderingAttributes • Material • TextureAttributes • Texture • TexCoordGeneration

  16. Appearance Bundle Example

  17. Sharing NodeComponent Objects Sharing NodeComponent Objects can enhance performance

  18. Back Face Culling • Polygons have two faces. For many visual objects, only one needs to be rendered, so the renderer can cull the unnecessary faces. • Front face is the face for which the vertices are defined in counter-clockwise order. • By default, back faces are culled

  19. Not Culling • Sometimes backface culling is a problem – you can turn it off.

  20. Turning off back face culling

More Related