Introduction to Java 3D - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Introduction to Java 3D

Description:

http://java.sun.com/developer/onlineTraining ... archives.java.sun.com/archives/java3d ... com.sun.j3d.utils package, it is convenient and powerful ... – PowerPoint PPT presentation

Number of Views:532
Avg rating:3.0/5.0
Slides: 28
Provided by: wang6
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Java 3D


1
Introduction to Java 3D
  • Winter 2007
  • Tao Wang
  • Adapted from the Java 3D tutorial and some course
    material

2
Outline
  • Java 3D Overview
  • Introduction to Java 3D API
  • Lab

3
  • Java 3D Overview

4
What is Java 3D?
  • Java 3D is
  • Standard extension to the Java 2 JDK
  • An interface for writing programs to display and
    interact with 3D graphics
  • Provides a collection of high-level constructs
    for creating and manipulating 3D geometry and
    structures for rendering that geometry
  • It is now a community source project developed on
    java.net (https//java3d.dev.java.net/)

5
What can Java 3D do?
  • Java 3D includes a rich and extensible feature
    set for
  • Building shapes
  • Composing behaviors
  • Interacting with the environment and the user
  • Controlling rendering details
  • Java 3D enables
  • Quick development of complex 3D applications
  • Fast and efficient implementation on a variety of
    platforms, from embedded systems to PCs to
    high-end workstations

6
Advantage and Disadvantage
  • Advantage
  • It enables fast Development, so developers do not
    need to manipulate rendering details, they can
    focus on visual contents
  • Disadvantage
  • It has lower speed than C/OpenGL

7
Java 3D Books
  • Computer Graphics Using Java 2D and 3D, Y. Daniel
    Liang and Hong Zhang, October 2005
  • Java 3D Programming, Daniel Selman, Manning
    Publications, Feb 2002
  • Java 3D API Jump-Start, Aaron E. Walsh and Doug
    Gehringer, Prentice Hall, Aug 2001
  • Essential Java 3d Fast Developing 3d Graphics
    Applications in Java, Ian Palmer,
    Springer-Verlag, June 2001
  • Java 3D (TM) API Specification (2nd Edition),
    Henry Sowizral, Kevin Rushforth, Michael Deering,
    May 2000
  • 3D User Interfaces with Java 3D, Jon Barrilleaux,
    Manning Publications, September 2000
  • Ready to Run Java 3D, Kirk Brown and Daniel
    Petersen, Wiley Sons, May 1999

8
Online Java 3D Resources
  • Homepage of Java 3D
  • https//java3d.dev.java.net/
  • Java 3D API Documentation, Examples and Downloads
  • https//java3d.dev.java.net/binary-builds.html
  • Java 3D Tutorial (Chapter 0-7, highly
    recommended)
  • http//java.sun.com/developer/onlineTraining/java3
    d/index.html
  • Java 3D interest group mail archive (searchable)
  • http//archives.java.sun.com/archives/java3d-inter
    est.html
  • The Java 3D Community Site
  • http//www.j3d.org/

9
Where to download
  • Java 2 SE Downloads
  • http//java.sun.com/javase/downloads/index.jsp
  • Java 3D
  • https//java3d.dev.java.net/binary-builds.html

10
Compiling the Examples
  • To compile the Java examples, you will need
  • 1. The Java 2 SE
  • 2. The Java 3D API
  • The command
  • javac FILENAME.java
  • It will compile java source files (.java) to java
    class files (.class)

11
Running the Examples
  • The command
  • java FILENAME
  • The Java interpreter looks for the file
    FILENAME.class in the current directory and loads
    it, and any additional files needed by that class

12
  • Introduction to Java 3D API

13
Some basic packages
  • Core classes
  • javax.media.j3d package, it includes the
    lowest-level classes necessary in Java 3D
    programming
  • Utility classes
  • com.sun.j3d.utils package, it is convenient and
    powerful additions to the core
  • It has 4 major categories content loaders, scene
    graph construction aids, geometry classes, and
    convenience utilities
  • Abstract Windowing Toolkit (AWT)
  • java.awt package, it creates a window to display
    the rendering
  • Vector math classes
  • javax.vecmath package, it defines vector math
    classes for points, vectors, matrices, and other
    mathematical objects

14
Virtual Universe and Scene Graph
  • A Java 3D program describes a virtual universe,
    which is to be rendered
  • A virtual universe is created from a scene graph
  • The scene graph is assembled from objects to
    define the geometry, sound, lights, location,
    orientation, and appearance of visual and audio
    objects

15
How to Build a Scene Graph
  • A scene graph is composed of nodes and arcs. A
    node is a data element, and arc is a relationship
    between data elements
  • The nodes in the scene graph are the instances of
    Java 3D classes. The arcs represent the two kinds
    of relationship between the Java 3D instances

16
Two relationships
  • Parent-child relationship
  • A parent node can have any number of children but
    only one parent
  • A child node can have one parent and no children
  • Reference relationship
  • A reference associates a NodeComponent object
    with a scene graph Node. NodeComponent objects
    define the Geometry, Appearance, Material and
    Texture attributes used to render the visual
    objects
  • For a single node, it can have many references

17
A Scene Graph Example
18
Concepts
  • Each scene graph has a single Virtual Universe
  • The Virtual Universe object has a Locale object
    (landmark used to determine the location of
    visual objects). It is the root of multiple
    sub-graphs
  • A BranchGroup object is the root of a sub-graph
    (branch graph)
  • Two kinds of sub-graph
  • view branch graph
  • viewing parameters (viewing location and
    direction)
  • content branch graph
  • Geometry, Appearance, Material, Texture,

19
SceneGraphObject class
  • SceneGraphObject is the superclass for nearly
    every Core and Utility Java 3D class. It has two
    subclasses
  • Node
  • Group
  • BranchGroup, TransformGroup
  • Leaf
  • Shape3D, Light, Behavior, and Sound (have no
    children but may reference NodeComponents)
  • NodeComponent
  • Geometry, Appearance, Material, Texture, (may
    be referenced by A Leaf)

20
Some Key Classes
  • Node and NodeComponent
  • superclasses for all the items that are added to
    a scene graph
  • BranchGroup
  • A Container for other objects in the scene
  • Every item in the scene graph is either a
    BranchGroup, or is a child of a BranchGroup
  • A BrachGroup can be a child of another
    BranchGroup
  • Shape3D
  • Contains information about an object in the scene
  • Contains references to Geometry, Appearance,
    Material, Texture,
  • Appearance
  • Defines the way a shape appears in the scene,
    including texture, and attributes for many other
    settings
  • TransformGroup
  • Allows translations, scales and rotations to be
    preformed
  • Geometry
  • Superclass for all classes that allow you to add
    form to a shape
  • Subclasses LineArray, TriangleArray, ....

21
A Recipe for Writing Java 3D Programs
  • 1. Create a Canvas3D object
  • 2. Create a VirtualUniverse object
  • 3. Create a Locale object, attaching it to the
    VirtualUniverse object
  • 4. Construct a view branch graph
  • a. Create a View object
  • b. Create a ViewPlatform object
  • c. Create a PhysicalBody object
  • d. Create a PhysicalEnvironment object
  • e. Attach ViewPlatform, PhysicalBody,
    PhysicalEnvironment, and Canvas3D objects to View
    object
  • 5. Construct content branch graph(s)
  • 6. Compile branch graph(s)
  • 7. Insert subgraphs into the Locale

22
A Simple Recipe for Writing Java 3D Programs
  • 1. Create a Canvas3D Object
  • 2. Create a SimpleUniverse object which
    references the Canvas3D object
  • a. Customize the SimpleUniverse object
  • 3. Construct content branch
  • 4. Compile content branch graph (to let Java 3D
    perform optimizations on this scene graph)
  • 5. Insert content branch graph into the Locale of
    the SimpleUniverse

23
The SimpleUniverse Class
  • The SimpleUniverse object constructor creates a
    scene graph including VirtualUniverse and Locale
    objects, and a complete view branch graph
  • The view branch graph created by SimpleUniverse
    uses instances of ViewingPlatform and Viewer
    convenience classes in place of the core classes
    used to create the view branch graph
  • It significantly reduces the time and effort
    needed to create the view branch graph

24
Examples
  • http//www.cs.ualberta.ca/anup/Courses/604/demos/
    nav.html

25
Programming Assignment 1
  • http//www-csfy.cs.ualberta.ca/c414/W07/assignmen
    ts/as1/C414_W07_AS1.html
  • Due date Feb 7
  • Submission Send E-mail to taowang_at_cs.ualberta.ca
    and CC to anup_at_cs.ualberta.ca
  • You are allowed to use any other
    languages/packages. However, you have to
    demonstrate your program to your TA AND submit
    the source code BEFORE the deadline. Your TA may
    or may not install/compile/run your program. If
    you use Java 3D, you do not have to show demos.
    The source code is enough.

26
Labs
  • There will be NO lab work in this course. Lab
    time may be used for working on assignments, or
    discussions with TA
  • Lab begins from next week, Jan 16th
  • H01 500PM-650PM Tue
  • H02 300PM-450PM Wed

27
Q A
Write a Comment
User Comments (0)
About PowerShow.com