java3d

23
Java3D Overview Scene graph Java 3D classes Describing objects Groups, transforms Behaviors, interpolators Lighting

Upload: cassandra-murphy

Post on 30-Dec-2015

24 views

Category:

Documents


3 download

DESCRIPTION

Java3D. Overview Scene graph Java 3D classes Describing objects Groups, transforms Behaviors, interpolators Lighting. What is Java3D. API Applications or Applets “Write once, run anywhere” platform independent (IBM AIX, HP-UX, Linux, SGI IRIX, Solaris/Sparc, Windows) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Java3D

Java3D

OverviewScene graphJava 3D classesDescribing objectsGroups, transformsBehaviors, interpolatorsLighting

Page 2: 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 scalable scene graph-based

Page 3: Java3D

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

Page 4: Java3D

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

Page 5: Java3D

Java3D 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

Page 6: Java3D

Java3D classes

javax.media.j3d package javax.media.j3d.VirtualUniverse

Enumeration getAllLocales( ) javax.media.j3d.Locale

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

Enumeration getAllBranchGraphs( ) javax.media.j3d.SceneGraphObject

Page 7: Java3D

Java3D classes

javax.media.j3d.Node Shapes, Groups, Sounds, Lights, etc. parent node location bounding volume

javax.media.j3d.NodeComponent attributes Shape geometry, Shape appearance,

Shape texture, etc.

Page 8: Java3D

Java3D classes

javax.vecmath package javax.vecmath.Tuple3d Vector3d Point3d, Color3d, etc.

Page 9: Java3D

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

Page 10: Java3D

Simple Java3D application

Construct view branch Canvas3D SimpleUniverse

VirtualUniverse, Locale, BranchGroup, TransformGroup, ViewPlatform, View

Construct content branch

BranchGroup TransformGroup Shape3D, Light,

Sound... Behavior

Page 11: Java3D

Shape3D

Fundamental mean of describing object

javax.media.j3d.Shape3D (Leaf)

Geometry void setGeometry(Geometry geometry)

Appearance void setAppearance(Appearance appearance)

Page 12: Java3D

Geometry

javax.media.j3d.Geometry (NodeComponent)

GeometryArray LineArray, PointArray, TriangleArray, QuadArray Indexed~

Text3DRaster

raster image

Page 13: Java3D

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

Page 14: Java3D

Loading content

Loader creates scene graph

elements from a filecom.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

Page 15: Java3D

Grouping

exactly one parent, arbitrary childrenjavax.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

Page 16: Java3D

Transforming

TransformGroup new coordinate system relative to parentTransform3D (Object)

Transform3D describes translation, rotation, and scaling A transform may be built from and represented by a

4x4 matrix, or by helper utility methods TransformGroup creates a new coordinate system for its

children, transformed by a Transform3D object All children are rendered. Rendering is done in any

order to allow for optimal rendering paths and parallelism in the rendering process.

Page 17: Java3D

Behaviors

javax.media.j3d.Behavior code to run (processStimulus) wakeup conditions

frame or milliseconds have elapsed AWT event transform change collision

scheduling bounds activation radius intersects scheduling bounds runs only when necessary common error - forgetting scheduling bounds

Page 18: Java3D

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 Target (TransformGroup)

PositionInterpolator,

PositionPathInterpolator,

ColorInterpolator, etc.

Page 19: Java3D

Lighting the environment

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

Page 20: Java3D

Misc

Much more Fog Sound FastScript3D etc

Page 21: Java3D

Summary – Building blocks

1. Reading data from input files2. Creation of a Java3D scene3. Simple geometry4. Interaction5. Animation6. Lights and textures7. Advanced modelling

Page 22: Java3D

References

1998 SUN presentation: http://java.sun.com/products/java-media/3D/collateral/presentation/Java3D 1.3 API documentation: http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dapi/index.htmlJava3D latest release page: http://java.sun.com/products/java-media/3D/index.jspA Java3D tutorial: http://www.j3d.org/tutorials/raw_j3d/Yet another tutorial: http://www.acm.org/crossroads/xrds5-2/ovp52.html

Thanks to Martin Cadik from CTU in Prague.

Page 23: Java3D

Questions?