Title: CSC 308 Graphics Programming
1CSC 308 Graphics Programming
- Java 3D New Geometry Content
- Information from online tutorial at
- http//java.sun.com/developer/onlineTraining/java
3d/ -
Dr. Paige H. Meeker Computer Science Presbyterian
College, Clinton, SC
2Creating 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
3Shape3D 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
4Node Components
- Contain exact specifications of attributes of
visual objects
5Geometry Utility Classes
- Box
- Cone
- Cylinder
- Sphere
- Inside the com.sun.j3d.utils.geometry package
6Creating 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(trans
late) rotate.rotZ(-Math.PI/2.0d)
TransformGroup yoyoTGR2 new TransformGroup(rotat
e) 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
7Mathematical 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)
8Point
- Point classes represent
- the coordinates of a vertex
- Position of a raster image
- Point light sources
- Spatial location of a sound
9Color
- Color classes represent a color for
- A vertex
- A material property
- Fog
- Other visual object
10Vector
- Vector classes represent
- A surface normal
- Direction of light source
- Direction of sound source
11TexCoord
- 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
12Geometry Classes
13GeometryArray subclasses
14Geometry Strip Array
15Appearance Bundle
- Refers to several different NodeComponent
subclasses called appearance attribute objects - PointAttributes
- LineAttributes
- PolygonAttributes
- ColoringAttributes
- TransparencyAttributes
- RenderingAttributes
- Material
- TextureAttributes
- Texture
- TexCoordGeneration
16Appearance Bundle Example
17Sharing NodeComponent Objects
Sharing NodeComponent Objects can enhance
performance
18Back 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
19Not Culling
- Sometimes backface culling is a problem you can
turn it off.
20Turning off back face culling