- Forward


Java 3D Basics
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Writing "Simple" Java3D Applications
Back SMYC Forward
  1. Create a Canvas3D object
  2. Create a SimpleUniverse object (which includes a view branch)
  3. Construct the content branch of the scene graph
  4. Compile the content branch
  5. Insert the content branch into the SimpleUniverse
Initialization
Back SMYC Forward
javaexamples/java3d/ApplicationWindow3D.java (Fragment: setup)
 
Windows
Back SMYC Forward
  • In Java:
    • Need to choose an appropriate Window
    • Need to choose an appropriate LayoutManager
  • In this course:
    • Use an ApplicationWindow3D
Windows (cont.)
Back SMYC Forward

Using the ApplicationWindow3D Class

javaexamples/java3d/basics/CubeDriver.java (Fragment: setup)
 
The Content Branch
Back SMYC Forward
  • Contains:
    • Children of SceneGraphObject
  • The Two Children:
    • Node - The abstract parent of all Group and LeafNodes
    • NodeComponent - The abstract parent for ColoringAttributes, Geometry, Material, and Texture
The Content Branch (cont.)
Back SMYC Forward

Descendants of the Node Class

java3d_Node
The Content Branch (cont.)
Back SMYC Forward

Descendants of the Node Class

javaexamples/java3d/basics/CubeDriver.java (Fragment: scene)
 
The Content Branch (cont.)
Back SMYC Forward

Descendants of the NodeComponent Class

java3d_NodeComponent
Vertices
Back SMYC Forward
  • Two Dimensional:
    • Point2f and Point2d
  • Three Dimensional:
    • Point3f and Point3d
  • Three Dimensional Homogenous:
    • Point4f and Point4d
Shapes - Descendants of Geometry
Back SMYC Forward
  • Ordered Lists:
    • PointArray
    • LineArray
    • TriangleArray
    • QuadArray
  • Strips and Fans:
    • LineStripArray
    • TriangleStripArray
    • TriangleFanArray
  • Indexed:
    • There are indexed versions of all of the above
Shapes (cont.)
Back SMYC Forward
java3d_scenegraph_CubeFactory
Shapes(cont.)
Back SMYC Forward

An Example

javaexamples/java3d/basics/CubeFactory.java (Fragment: data)
 
javaexamples/java3d/basics/CubeFactory.java (Fragment: createCube)
 
Shapes - com.sun.j3d.utils.geometry
Back SMYC Forward
  • Without Color:
    • Box, Cone, Cylinder, Sphere
  • With Color:
    • ColorCube
Transforms
Back SMYC Forward
  • The Matrix Classes:
    • In javax.vecmath
  • The Transform3D Class:
    • In javax.media.j3d
    • Include methods for setting, concatenating, and inverting transforms
  • The TransformGroup Class:
    • A descendant of Node that can be added to the scene graph
Transformations (cont.)
Back SMYC Forward

An Example

javaexamples/java3d/basics/RotationDriver.java
 
Shapes (cont.)
Back SMYC Forward

The Scene Graph in RotationDriver

java3d_scenegraph_RotationDriver
User Interaction
Back SMYC Forward
  • The WakeupOnAWTEvent Class:
    • A WakeupCondition that is triggered by either a KeyEvent or a MouseEvent
  • Parts of the Process:
    • Implement a Behavior class
    • Create a Behavior object
    • Set the bounds for the Behavior object
    • Add the Behavior to the scene graph
User Interaction (cont.)
Back SMYC Forward

A Behavior

javaexamples/java3d/basics/KeyboardBehavior.java
 
User Interaction (cont.)
Back SMYC Forward

Using a Behavior

javaexamples/java3d/basics/KeyboardDriver.java
 
Shapes (cont.)
Back SMYC Forward

The Scene Graph in KeyboardDriver

java3d_scenegraph_KeyboardDriver
Loaders
Back SMYC Forward
  • Purpose:
    • Reads scene graphs from files
  • Available Loaders:
    • 3D Studio (.3ds)
    • AutoCAD (.dxf)
    • Lightwave (.lws)
    • Wavefront (.obj)
    • VRML (.wrl)
    • Others
Loaders (cont.)
Back SMYC Forward

Loading Wavefront Files

javaexamples/java3d/basics/LoaderDriver.java
 
There's Always More to Learn
Back -