Presentation is loading. Please wait.

Presentation is loading. Please wait.

Department of computer science and engineering INTRODUCTION TO JAVA 3D Martin Čadík Czech Technical University in Prague, Czech Republic.

Similar presentations


Presentation on theme: "Department of computer science and engineering INTRODUCTION TO JAVA 3D Martin Čadík Czech Technical University in Prague, Czech Republic."— Presentation transcript:

1 department of computer science and engineering INTRODUCTION TO JAVA 3D Martin Čadík Czech Technical University in Prague, Czech Republic

2 November 27, 2002 (2) department of computer science and engineering Content Overview Overview Scene graph Scene graph Java 3D classes Java 3D classes Simple application Simple application Describing objects Describing objects Groups, transforms Groups, transforms Behaviors, interpolators, picking Behaviors, interpolators, picking Lighting, Sound Lighting, Sound

3 November 27, 2002 (3) department of computer science and engineering What Is Java3D? API API –Applications or Applets –“Write once, run anywhere” platform independent (IBM AIX, HP-UX, Linux, SGI IRIX, Solaris/Sparc, Windows)platform independent (IBM AIX, HP-UX, Linux, SGI IRIX, Solaris/Sparc, Windows) display environmentsdisplay environments –higher level API objects instead of verticesobjects instead of vertices content instead of rendering processcontent instead of rendering process –scalable –scene graph - based

4 November 27, 2002 (4) department of computer science and engineering Java3D - Overview Java Java –JRE –SDK Java 3D Java 3D –JRE –SDK –OpenGL –DirectX Code examples in distribution Code examples in distribution Code examples in distribution Code examples in distribution Applications Applications –scientific visualization, animation, web design, simulations, virtual world construction (CAVE), training, games, design automation

5 November 27, 2002 (5) department of computer science and engineering Java3D Scene Graph VirtualUniverse VirtualUniverse –to contain all 3D data –typically one per application –SimpleUniverse –Locale object View View –describes how to view 3D content –multiple views per universe –View Platform (movable) Content Branch Content Branch –describes 3D content

6 November 27, 2002 (6) department of computer science and engineering Java 3D Renderer Canvas 3D 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

7 November 27, 2002 (7) department of computer science and engineering Java 3D Classes javax.media.j3d package 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

8 November 27, 2002 (8) department of computer science and engineering 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 package javax.vecmath.Tuple3d Vector3d Point3d, Color3d, etc.

9 November 27, 2002 (9) department of computer science and engineering Coordinate System, Elements Coordinate system Coordinate system –Right-handed +X is to the right+X is to the right +Y is up+Y is up +Z is towards the viewer+Z is towards the viewer –Angles in radians –Distance in meters Elements in a Geometry Elements in a Geometry –Coordinates –Normals –Colors –TextureCoordinates

10 November 27, 2002 (10) department of computer science and engineering Simple Java3D Application Construct view branch Construct view branch –Canvas3D –SimpleUniverse VirtualUniverse, Locale, BranchGroup, TransformGroup, ViewPlatform, ViewVirtualUniverse, Locale, BranchGroup, TransformGroup, ViewPlatform, View Construct content branch Construct content branch –BranchGroup –TransformGroup –Shape3D, Light, Sound... –Behavior SimpleApp3D SimpleApp3D SimpleApp3D –code code

11 November 27, 2002 (11) department of computer science and engineering Shape3D Fundamental mean of describing object Fundamental mean of describing object javax.media.j3d.Shape3D (Leaf) Geometry Geometry void setGeometry(Geometry geometry) Appearance Appearance void setAppearance(Appearance appearance)

12 November 27, 2002 (12) department of computer science and engineering Geometry javax.media.j3d.Geometry (NodeComponent) GeometryArray GeometryArray –LineArray, PointArray, TriangleArray, QuadArray –Indexed~ –Stripped versions Text3D Text3D javax.media.j3d.Text3D –example example Raster Raster –raster image

13 November 27, 2002 (13) department of computer science and engineering Appearance javax.media.j3d.Appearance (NodeComponent) Specifies how to render Geometry sibling 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 example

14 November 27, 2002 (14) department of computer science and engineering Loading content Loader Loader –creates scene graph elements from a file com.sun.j3d.loaders –only the interface included in Java 3D Usage Usage –import loader –create loader object –Scene variable –load file –insert Scene into the scene graph Available loaders Available loaders –3DS, COB, DEM, DXF, IOB, LWS, NFF, OBJ, PDB, PLAY, SLD, VRT, VTK, WRL

15 November 27, 2002 (15) department of computer science and engineering Grouping exactly one parent, arbitrary children exactly one parent, arbitrary children javax.media.j3d.Group (Node) BranchGroup,OrderedGroup, SharedGroup (Link), Switch, TransformGroup child rendering order determines Java 3D child rendering order determines Java 3D –can perform sorting for better rendering efficiency BranchGroups BranchGroups –can be attached to Locale --> it makes it live --> constrains by capabilities –can be compiled

16 November 27, 2002 (16) department of computer science and engineering Transforming world coordinate system world coordinate system TransformGroup –new coordinate system relative to parent transformation accumulate as graph is traversed transformation accumulate as graph is traversed Transform3D (Object) –4 x 4 matrix of doubles - –4 x 4 matrix of doubles - Matrix4d –translate, rotate, scale, shear –must be affine (no perspective) –helper methods setIdentity, rotX.., setScale, setTranslation, setRotation, etc.

17 November 27, 2002 (17) department of computer science and engineering Texture mapping Appearance node Appearance node - image textures, example Texture2D (abstract Texture (NodeComponent)) - image textures, exampleexample - volume textures Texture3D - volume textures Texture format Texture format –Intensity –Luminance, Alpha –RGB, RGBA TextureAttributes (NodeComponent) –Mode: Blend, Decal, Modulate, Replace –Transform –Perspective correction

18 November 27, 2002 (18) department of computer science and engineering Behaviors javax.media.j3d.Behavior code to run () code to run ( processStimulus ) wakeup conditions wakeup conditions –frame or milliseconds have elapsed –AWT event –transform change –collision, view platform or sensor is close scheduling bounds scheduling bounds –activation radius intersects scheduling bounds –runs only when necessary –common error - forgetting scheduling bounds

19 November 27, 2002 (19) department of computer science and engineering Interpolators javax.media.j3d.Interpolator simple behaviors simple behaviors –vary a parameter from starting to ending value –Time-to-Alpha mapping –Time-to-Alpha mapping (Alpha (Object) ) –Alpha-to-Value mapping transforms, colors, switchestransforms, colors, switches –Target (f.e. TransformGroup) PositionInterpolator, RotationInterpolator, ColorInterpolatorm, etc.

20 November 27, 2002 (20) department of computer science and engineering Input devices –joysticks –6DOF devices (Magellan, Ultrasonic tracker...) –buttons –real / virtual javax.media.j3d.InputDevice interface –implementation maps physical detectors onto object (process input, return Sensor) –implementation maps physical detectors onto Sensor object (process input, return Sensor) javax.media.j3d.Sensor (Object) – object –SensorRead object time-stamptime-stamp 6DOF value, button state6DOF value, button state

21 November 27, 2002 (21) department of computer science and engineering Picking features –selecting Shapes –interaction methods –designed for speed (Bounds) Pick methods (Node) Pick methods (Node) –take –take PickShape (PickPoint, PickRay, PickSegment) –return objects –return SceneGraph objects –f.e.: –f.e.: pickAll, pickAllSorted, pickClosest – –exampleexample

22 November 27, 2002 (22) department of computer science and engineering Lighting the environment javax.media.j3d.Light Types of lights Types of lights –ambient - –ambient - AmbientLight –directional - –directional - DirectionalLight –point - –point - PointLight attenuationattenuation –spot - –spot - SpotLight Light attributes Light attributes –on/off –color –bounding volume and scope by default universal scopeby default universal scope –again: common error - forgetting scheduling bounds

23 November 27, 2002 (23) department of computer science and engineering Sounds javax.media.j3d.Sound Sounds Sounds –triggered –continuous Sound types Sound types –background - –background - BackgroundSound –point - –point - PointSound attenuatedattenuated –cone - –cone - ConeSound attenuatedattenuated Sound properties Sound properties –sound data –sound data (MediaContainer) AIF, AU, WAVAIF, AU, WAV –looping parameters –playback priority –scheduling bounds

24 November 27, 2002 (24) department of computer science and engineering Misc Background Background javax.media.j3d.Background Fog Fog –exponential, linear javax.media.j3d.Fog

25 November 27, 2002 (25) department of computer science and engineering Acceleration Performance Guide Performance Guide –capability bits –compilation –bounds, activation radius –geometry by reference –unordered rendering

26 November 27, 2002 (26) department of computer science and engineering News FastScript 3D FastScript 3D –open source –web applets using Java3D via JavaScript and HTML –Java, Java3D required –fs.jar

27 November 27, 2002 (27) department of computer science and engineering Java 3D Java 3D Thank you for your attention


Download ppt "Department of computer science and engineering INTRODUCTION TO JAVA 3D Martin Čadík Czech Technical University in Prague, Czech Republic."

Similar presentations


Ads by Google