CSC 308 Graphics Programming - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

CSC 308 Graphics Programming

Description:

A material property. Fog. Other visual object. Vector* Vector classes represent. A surface normal ... For many visual objects, only one needs to be rendered, so ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 21
Provided by: acade124
Category:

less

Transcript and Presenter's Notes

Title: CSC 308 Graphics Programming


1
CSC 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
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(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
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
Write a Comment
User Comments (0)
About PowerShow.com