Introduction to java 3d
This presentation is the property of its rightful owner.
Sponsored Links
1 / 27

INTRODUCTION TO JAVA 3D PowerPoint PPT Presentation


  • 32 Views
  • Uploaded on
  • Presentation posted in: General

INTRODUCTION TO JAVA 3D. Martin Č adík Czech Technical University in Prague, Czech Republic. Content. Overview Scene graph Java 3D classes Simple application Describing objects Groups, transforms Behaviors, interpolators, picking Lighting, Sound. What Is Java3D?. API

Download Presentation

INTRODUCTION TO JAVA 3D

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction to java 3d

INTRODUCTION TO JAVA 3D

Martin Čadík

Czech Technical University in Prague, Czech Republic


Content

Content

  • Overview

  • Scene graph

  • Java 3D classes

  • Simple application

  • Describing objects

  • Groups, transforms

  • Behaviors, interpolators, picking

  • Lighting, Sound


What is java3d

What Is Java3D?

  • API

    • Applications or Applets

    • “Write once, run anywhere”

      • platform independent (IBM AIX, HP-UX, Linux, SGI IRIX, Solaris/Sparc, Windows)

      • display environments

    • higher level API

      • objects instead of vertices

      • content instead of rendering process

    • scalable

    • scene graph - based


Java3d overview

Java

JRE

SDK

Java 3D

JRE

SDK

OpenGL

DirectX

Code examples in distribution

Applications

scientific visualization, animation, web design, simulations, virtual world construction (CAVE), training, games, design automation

Java3D - Overview


Java3d scene graph

Java3D Scene Graph

  • VirtualUniverse

    • to contain all 3D data

    • typically one per application

    • SimpleUniverse

    • Locale object

  • View

    • describes how to view 3D content

    • multiple views per universe

    • View Platform (movable)

  • Content Branch

    • describes 3D content


Java 3d renderer

Java 3D Renderer

  • Canvas 3D

    • surface onto which a View renders

    • one canvas per view

    • there can be multiple canvases per app

      while (true) {

      Process input

      if (exit request)break

      Check for collisions

      Perform behaviors

      Start playing sounds

      Traverse scene graph and render objects

      }

      Cleanup


Java 3d classes

Java 3D Classes

  • javax.media.j3d package

    javax.media.j3d.VirtualUniverse (java.lang.Object)

    Enumeration getAllLocales( )

    javax.media.j3d.Locale

    VirtualUniverse getVirtualUniverse( ) void addBranchGraph( Branchgroup branchGroup ) removeBranchGraph( Branchgroup branchGroup ) void Enumeration getAllBranchGraphs( )

    javax.media.j3d.SceneGraphObject

    Capabilities (read/write transforms, geometry coords...)

    javax.media.j3d.Node

    javax.media.j3d.NodeComponent


Java 3d classes1

Java 3D Classes

javax.media.j3d.Node

  • Shapes, Groups, Sounds, Lights, etc.

  • parent node

  • location (local, VWorld transform)

  • bounding volume (automatical computation)

    javax.media.j3d.NodeComponent

  • attributes

  • Shape geometry, Shape appearance, Shape texture, etc.

  • javax.vecmath package

    javax.vecmath.Tuple3d

    Vector3d

    Point3d, Color3d, etc.


  • Coordinate system elements

    Coordinate System, Elements

    • Coordinate system

      • Right-handed

        • +X is to the right

        • +Y is up

        • +Z is towards the viewer

      • Angles in radians

      • Distance in meters

    • Elements in a Geometry

      • Coordinates

      • Normals

      • Colors

      • TextureCoordinates


    Simple java3d application

    Simple Java3D Application

    • Construct view branch

      • Canvas3D

      • SimpleUniverse

        • VirtualUniverse, Locale, BranchGroup, TransformGroup, ViewPlatform, View

    • Construct content branch

      • BranchGroup

      • TransformGroup

      • Shape3D, Light, Sound...

      • Behavior

    • SimpleApp3D

      • code


    Shape 3d

    Shape3D

    • Fundamental mean of describing object

      javax.media.j3d.Shape3D (Leaf)

    • Geometry

      void setGeometry(Geometry geometry)

    • Appearance

      void setAppearance(Appearance appearance)


    Geometry

    Geometry

    javax.media.j3d.Geometry (NodeComponent)

    • GeometryArray

      • LineArray, PointArray, TriangleArray, QuadArray

      • Indexed~

      • Stripped versions

    • Text3D

      javax.media.j3d.Text3D

      • example

    • Raster

      • raster image


    Appearance

    Appearance

    javax.media.j3d.Appearance (NodeComponent)

    • Specifies how to render Geometry sibling

      • Color (intrinsic) and shading (flat, Gouraud)

        • ColoringAttributes

        • Material

      • Transparency

        • TransparencyAttributes

      • Line, point, polygon attributes

        • LineAttributes, PointAttributes, PolygonAttributes

      • Rendering control

      • Texture mapping

      • example


    Loading content

    Loader

    creates scene graph elements from a file

    com.sun.j3d.loaders

    only the interface included in Java 3D

    Usage

    import loader

    create loader object

    Scene variable

    load file

    insert Scene into the scene graph

    Available loaders

    3DS, COB, DEM, DXF, IOB, LWS, NFF, OBJ, PDB, PLAY, SLD, VRT, VTK, WRL

    Loading content


    Grouping

    Grouping

    • exactly one parent, arbitrary children

      javax.media.j3d.Group (Node)

      BranchGroup,OrderedGroup, SharedGroup (Link), Switch, TransformGroup

    • child rendering order determines Java 3D

      • can perform sorting for better rendering efficiency

    • BranchGroups

      • can be attached to Locale -->it makes it live --> constrains by capabilities

      • can be compiled


    Transforming

    Transforming

    • world coordinate system

      TransformGroup

      • new coordinate system relative to parent

    • transformation accumulate as graph is traversed

      Transform3D (Object)

      • 4 x 4 matrix of doubles - Matrix4d

      • translate, rotate, scale, shear

      • must be affine (no perspective)

      • helper methods

        • setIdentity, rotX.., setScale, setTranslation, setRotation, etc.


    Texture mapping

    Texture mapping

    • Appearance node

      Texture2D (abstract Texture (NodeComponent))- image textures, example

      Texture3D - volume textures

    • Texture format

      • Intensity

      • Luminance, Alpha

      • RGB, RGBA

    • TextureAttributes (NodeComponent)

      • Mode: Blend, Decal, Modulate, Replace

      • Transform

      • Perspective correction


    Behaviors

    Behaviors

    javax.media.j3d.Behavior

    • code to run (processStimulus)

    • wakeup conditions

      • frame or milliseconds have elapsed

      • AWT event

      • transform change

      • collision, view platform or sensor is close

    • scheduling bounds

      • activation radius intersects scheduling bounds

      • runs only when necessary

      • common error - forgetting scheduling bounds


    Interpolators

    Interpolators

    javax.media.j3d.Interpolator

    • simple behaviors

      • vary a parameter from starting to ending value

      • Time-to-Alpha mapping (Alpha (Object) <0,1>)

      • Alpha-to-Value mapping

        • transforms, colors, switches

      • Target (f.e. TransformGroup)

        PositionInterpolator,

        RotationInterpolator,

        ColorInterpolatorm, etc.


    Input devices

    Input devices

    • joysticks

    • 6DOF devices (Magellan, Ultrasonic tracker...)

    • buttons

    • real / virtual

      javax.media.j3d.InputDevice interface

    • implementation maps physical detectors onto Sensor object(process input, return Sensor)

      javax.media.j3d.Sensor (Object)

    • SensorRead object

      • time-stamp

      • 6DOF value, button state


    Picking features

    Picking features

    • selecting Shapes

    • interaction methods

    • designed for speed (Bounds)

  • Pick methods (Node)

    • take PickShape (PickPoint, PickRay, PickSegment)

    • return SceneGraph objects

    • f.e.: pickAll, pickAllSorted, pickClosest

    • example


  • Lighting the environment

    javax.media.j3d.Light

    Types of lights

    ambient - AmbientLight

    directional - DirectionalLight

    point - PointLight

    attenuation

    spot - SpotLight

    Light attributes

    on/off

    color

    bounding volume and scope

    by default universal scope

    again: common error - forgetting scheduling bounds

    Lighting the environment


    Sounds

    javax.media.j3d.Sound

    Sounds

    triggered

    continuous

    Sound types

    background - BackgroundSound

    point - PointSound

    attenuated

    cone - ConeSound

    attenuated

    Sound properties

    sound data (MediaContainer)

    AIF, AU, WAV

    looping parameters

    playback priority

    scheduling bounds

    Sounds


    Introduction to java 3d

    Misc

    • Background

      javax.media.j3d.Background

    • Fog

      • exponential, linear

        javax.media.j3d.Fog


    Acceleration

    Acceleration

    • Performance Guide

      • capability bits

      • compilation

      • bounds, activation radius

      • geometry by reference

      • unordered rendering


    Introduction to java 3d

    News

    • FastScript 3D

      • open source

      • web applets using Java3D via JavaScript and HTML

      • Java, Java3D required

      • fs.jar


    Java 3d

    Java 3D

    Thank you

    for your attention


  • Login