101
Java 3D Introduction http://www.hta-bi.bfh.ch/~rfs/ pwf/java3/ Stefan Rufer Assistant Computer Science Departement [email protected]

Java 3D Introduction

  • Upload
    baris

  • View
    31

  • Download
    0

Embed Size (px)

DESCRIPTION

Java 3D Introduction. http://www.hta-bi.bfh.ch/~rfs/pwf/java3/ Stefan Rufer Assistant Computer Science Departement [email protected]. Todays Contents. Start Introduction to Computer Graphics Java 3D Tutorial Chapters – Layout: Technical Introduction Application in Java 3D - PowerPoint PPT Presentation

Citation preview

Page 1: Java 3D Introduction

Java 3D Introduction

http://www.hta-bi.bfh.ch/~rfs/pwf/java3/

Stefan RuferAssistant Computer Science Departement

[email protected]

Page 2: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Todays Contents Start Introduction to Computer Graphics Java 3D Tutorial Chapters – Layout:

Technical Introduction Application in Java 3D Example Programs

Page 3: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Start Foreword Installing Java 3D Running Java 3D Programs Warm-up Course overview References & Sources

Page 4: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

StartObjectives Appetizer for the Course. Know how to compile and run Java

3D programs. Know where to search in case of

troubles or further interest.

Page 5: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

StartForeword Determine the correct color for

every pixel. This course is programming

oriented. Why to learn Java 3D?

It is object oriented. It is 3D. It is fun.

Page 6: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Start Installing Java 3D School PCs have Java 3D installed

Make sure that JDK 1.2.2 or later has been initialized (NAL -> Java -> Initialize ...).

The SUN environment does not include Java 3D per default

Check web-page for details and troubleshooting

# Add some directories to your PATH#original: PATH ${HOME}/bin:${PATH}:PATH /tools/java/JDK-1.2-AND-Java3D-1.1/bin:${HOME}/bin:${PATH}:

Page 7: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Start Running Java 3D Programs Copy source from intranet

It is so simple – but IF... have a look on the web page for troubleshooting (all JARs at the right place, also in the JRE?).

>javac Program.java>java Program

Page 8: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

StartWarm-up Simply let us try some examples...!

http://www.hta-bi.bfh.ch/~rfs/pwf/java3/Chapter Start, paragraph Warm-up.

Page 9: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Start Course Overview

Date Subject Remark23.10.00 Start / Introduction to Computer Graphics

30.10.00 Hello World! / The Virtual Universe Tutorial Chapter 1, 2

6.11.00 Transformations / SceneBuilder

13.11.00 Creating Geometry / Easier Content Creation

Tutorial Chapter 2, 3

20.11.00 Interaction Tutorial Chapter 4

27.11.00 Animation Tutorial Chapter 5

4.12.00 Lights Tutorial Chapter 6

11.12.00 Textures Tutorial Chapter 7

18.12.00 Spline, Ray-Tracing, Future

8.1.01 Project Work Kick-off Project work by one, two or three people. Proposals for projects will be accepted.

15.1.01 Project Work

22.1.01 Project Work

29.1.01 Project Work

5.2.01 Project Work

12.2.01 Project Work

19.2.01 Project Work

26.2.01 Presentations of the Project Works

5.3.01 Holiday

Page 10: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Start References & Sources SUN and intranet web pages, links

found in documentation. Use the glossary, it makes live

easier if you know about what exactly you are talking.

Page 11: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Intro to Computer Graphics Why Java 3D 2D versus 3D Color Models Hardware Java 3D Tutorial

Page 12: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsObjectives Understand some essential basics

of computer graphics like color models.

Get an idea of what hardware is involved if doing computer graphics.

Page 13: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsWhy Java 3D 3D-modelers like Art*lantis

Easy content creation Pre-programmed „static“ behaviour Many pre-defined shapes, extrusions, textures...

3D-languages like Java 3D or OpenGL High degree of user interaction Start on the „green field“ Create new 3D applications (CAD, Simulator, ...)

3D-renderers like PovRay No interaction, only one picture

Page 14: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer Graphics2D versus 3D 2D

R2 => R2

Simply two dimensional picture on 2D-Screen.

3D R3 => R2

Match three dimensional mathematical model to two dimensional Screen.

A new approach are Holography techniques R3 => R3 but that‘s maybe beyond the scope of this course...

Page 15: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsColor Models RGB is the most most important

color model for computer graphics. Additive system Red, Green, Blue, 8bit each Java 3D: each color has values 0..1 Application example: ColorSpace

Other systems: CMYK, HSB...

Page 16: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsHardware (1) Graphic Cards minimize processor load by

executing graphic commands in hardware. DirectX OpenGL

Raster Screen have an x-y pixel array (=raster) to display our graphics CRT LCD Counterpart: Vector graphic devices such as

analog cathode-ray oscilloscopes.

Page 17: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsHardware (2)

Page 18: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Introduction to Computer GraphicsJava 3D Tutorial Tutorial by SUN Great (as usual, it is SUN...) Use this and the API as your

reference!

Page 19: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual Universe Basics Scene Graph Locales Content Branch View Branch Understanding MyUniverse Recipe for a simple Program

Page 20: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseObjectives Know what a virtual universe and a

scene graph is. Understand the basic parts and

elements of a scene graph. Know the basic recipe for a Java 3D

program.

Page 21: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseBasics A virtual universe can be seen as a 1:1

representation of our own universe. Represent structures from astronomical

to subatomic. Floating point 3D space: 2^256 (!!) for each

x,y,z. Decimal point for 1 meter at 2^128 ->

incredible precision at incredible extend. There is one VU-instance only (Singleton).

Page 22: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseScene Graph (1) Scene Graph is the

graphical representation of the objects in our VU.

Directed Acyclic Graph (Tree) Nodes, arcs, parents,

childs, leaves, references and other objects.

VirtualUniverse

Locale

Group

Leaf

NodeComponent Other objects

Reference

Link

Page 23: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseScene Graph (2) A Java 3D program may have more

objects than those in the scene graph.

A scene graph drawing is the correct documentation for the 3D part of a Java 3D program.

Page 24: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseScene Graph (3) Basic parts of a

scene graph

myVirtualUniverse

myLocale

BranchGroup

BranchGroup

a3Dobject myViewPlatform

ViewBranch

Content Branch

Locale(s)

Page 25: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseLocales (1) How to handle the huge extend of

a virtual universe efficiently? Our virtual universe contains at

least one Locale. The locale is a 3D-reference point

inside the virtual universe.

Page 26: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseLocales (2) Standard Locale resides at (0,0,0) in the

VU. We can have several Locales, eg:

One as reference point of the swiss coordinate system (located in Bordeaux, France).

A second as the architects reference point of a building plan.

The both are related, but depending on the point of view it is more convenient (and precise) to work with one or the other.

Page 27: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseContent Branch (1) Contains all „visible“ objects of our

scene. Contains all transformations for

those objects (displacement, animation, ...).

We distinguish between group nodes and leaf nodes (see following slide).

Page 28: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseContent Branch (2) The most

common object types

BranchGroup

Shape3DAppearance

TransformGroup

...

...

Page 29: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseView Branch

The Canvas3D will be inserted in our application or applet -> most important!

Page 30: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseRecipe for a simple Program

1. Create a Frame & a Canvas3D object.

2. Create a SimpleUniverse object which gets a reference to the Canvas3D.

3. Construct the content branch.4. Insert the content branch into

the Locale of the SimpleUniverse.

Page 31: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

The Virtual UniverseExercises Check Web-Page, chapter

„Virtual Universe“

http://www.hta-bi.bfh.ch/~rfs/pwf/java3/

Page 32: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello World The Java 3D API Finally: Hello World! Source Code Class Diagram of HelloJava3D What happens when running? Exercises

Page 33: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldObjectives Understand the high-level

structure of the APIs involved in a Java 3D program.

Understand the code of the HelloJava3Da example line by line.

Page 34: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldThe Java 3D API Packages related to the Java 3D

API: Core classes: javax.media.j3d Utility classes: com.sun.j3d.utils Math classes: javax.vecmath AWT classes: javax.swing

Page 35: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldFinally: Hello World! Probably the most

simple Scene Graph

Page 36: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldSource Codepublic class HelloJava3Da extends Applet { public HelloJava3Da() { setLayout(new BorderLayout()); Canvas3D canvas3D = new Canvas3D(null); add("Center", canvas3D);

SimpleUniverse simpleU = new SimpleUniverse(canvas3D); simpleU.getViewingPlatform().setNominalViewingTransform();

BranchGroup scene = createSceneGraph(); simpleU.addBranchGraph(scene); }

public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); objRoot.addChild(new ColorCube(0.4));

return objRoot; }

public static void main(String[] args) { Frame frame = new MainFrame(new HelloJava3Da(), 256, 256); }}

Page 37: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldClass Diagram of HelloJava3D

Page 38: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldWhat happens when running?while (true) {

Process input

Perform Behaviours //none at the moment

Traverse scene graph and render visual objects

if (request to exit) break

}

Cleanup and exit

Page 39: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Hello WorldExercises Check Web-Page, chapter „Hello

World“

http://www.hta-bi.bfh.ch/~rfs/pwf/java3/

Page 40: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating Content Geometic Utility Classes Mathematical Classes Geometry Classes GeometryArray Classes GeometryStrip Array Classes Indexed Geometry Appearance and Attributes Point- + LineAttributes PolygonAttributes

Page 41: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentObjectives Get an overview on how to handle

polygones in Java 3D. Know the most important

attributes that determine the look of a polygone.

Page 42: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentGeometric Utility Classes

Box (2x2x2 m)

Cone (Ø2m, height 2m)

Cylinder (Ø2m, height 2m)

Sphere (Ø2m)

Default color white

Tutorial Page 2-6

Page 43: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentMathematical Classes (1) Tuples are simply pairs or triples of

numbers. For each vertex there can be up to

four javax.vecmath objects: Points for coordinates Colors Vectors for normals TexCoords for texture coordinates

Tutorial Page 2-15

Page 44: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentMathematical Classes (2) Vectors: mostly used for normals

and position information in 3D-space.

Normals: determined using the right hand (remember: we have a right-handed system).

P0

P1

P2n

Page 45: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentGeometry Classes What to do if our shape is not a

box or a cylinder? Create Shape3D-object, use

setGeometry() method! For a triangle:

Three-element array One point per element

Tutorial Page 2-20

Page 46: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentGeometryArray Classes Most primitive form to create

shapes:

Points or lines are one pixel wide per default.

Colors are interpolated from vertex to vertex if specified.(see code page 2-24, line 9+10)

Tutorial Page 2-21

2-26

P0 P1

Page 47: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentGeometryStripArray Classes More convenient: share some

vertices:

Example Yoyo: Ever tried to model a Jumbo-Jet by hand? Often geometry is generated by mathematical calculations.

Tutorial Page 2-27

Page 48: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentIndexed Geometry Best re-use of vertices but we lose

performance using the index array.

Tutorial Page 2-27

Page 49: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentAppearance and Attributes Appearance class does not specify

the appearance directrly but contains many links to appearance objects:

Tutorial Page 2-34

Page 50: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentPoint- + LineAttributes Points and Lines are 1 pixel wide

by default. Zooming does not affect this.

Let‘s try to change: Thikness of the line Antialiasing

Tutorial Page 2-37

Page 51: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Creating ContentPolygonAttributes We can set the PolygonMode:

Fill: fill the interior of the polygones Line: connect vertices with lines

(„Drahtigttermodell“) Point: draw only points at the vertices

Face culling: Hide front, back or none of the faces of a polygon.

Tutorial Page 2-38

2-42

Page 52: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content Creation Class Loaders Handle a bunch of objects Text in 2D and 3D Background Bounding Leaf

Page 53: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationObjectives Be able to load and display non-

Java 3D objects in a scene. Understand background and

bounding leaf and why one of the two is not enough.

Page 54: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationClass Loaders Load 3D scene files and create Java 3D

representations (branch graph). Read and parse file Create Java 3D objects Return branch group object with all the scene

contents Insert branch group in the scene

-> J3D API Demos: ..\ObjLoad\java ObjLoad ..\geometry\

galleon.obj

Tutorial Page 3-2

Page 55: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationHandle a bunch of points First create a GeometryInfo object. Now many operations can be

performed on this object (and on our data): Generate Normals „Stripifying“ „Compacting“

Example: GeometryInfoApp.java

Tutorial Page 3-7

Page 56: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationText in 2D and 3D Text2D creates a rectangular

polygone and a texture on it. Text3D creates geometry objects

for the text that have an extrusion.

Tutorial Page 3-13

3-16

Page 57: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationBackground Background can be a solid color,

an image and/or a geometry. Background is infinitely far away,

you can not go or see what‘s behind.

Tutorial Page 3-22

Page 58: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Easier Content CreationBounding Leaf Used for different classes: Light,

Fog, Behaviour or Background. Only an intersection with the

bounding leaf of such an object makes it visible.

Page 59: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Animation Interpolators Alpha Object Billboard Level of Detail (LOD) Morphing

Page 60: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationObjectives Get an impression of the different

forms of animation. Be able to animate objects using

an Interpolator and Alpha object.

Page 61: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationInterpolators Change all important

3D-object data easily. Interpolators do not

change the corresponding value automatically -> Alpha object needed.

Tutorial Page 5-11

Page 62: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationAlpha Object (1)

Tutorial Page 5-7

Alpha objects generate events distributed over time.

They are used as trigger events for the interpolators.

Some of the possible wave-forms f(t):

Page 63: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationAlpha Object (2)

Tutorial Page 5-7

AlphaAtOneDuration

PhaseDelayDuration AlphaAtZeroDurationTriggerTime

Page 64: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationPut it together

TransformGroup objRotate = new TransformGroup();objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

Alpha alpha = new Alpha ();

RotationInterpolator rotInt = new RotationInterpolator (alpha, objRotate);rotInt.setSchedulingBounds(bounds);

objRotate

rotIntalpha

Trigger events

Change

Transform3D

Page 65: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationBillboard Show complex (background)

geometry, e.g. trees. Troubles with different views. These objects are flat:

Tutorial Page 5-26

Page 66: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationLevel of Detail (LOD) As closer you are as more details

you want to see -> LOD. Several childs of a Switch node,

choose the right one. Long developement time for

creating the objects with different detail levels.

Tutorial Page 5-30

5-31

Page 67: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationMorphing „Interpolator for geometry“. You have to define the key frames. The Morph class will interpolate

between the key frames. -> Try the Java 3D example \jdk1.3\

demo\java3d\Morphing\Morphing.java

Tutorial Page 5-36

Page 68: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

AnimationExercises Find description on the web page

(chapter animation):www.hta-bi.bfh.ch/~rfs/pwf/java3/

Tutorial Page 5-36

Page 69: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Lights Java 3D Lighting Model Influence Different Light Types Mixing Lights Material Objects Other Coloring Possibilities Shadows

Page 70: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsObjectives Understand the Java 3D lighting

system. Know about the different ways to

give a color to an object. Recall the theory about additive

light mixing.

Tutorial Page 6-2

Page 71: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsJava 3D Lighting Model There are three different reflections:

Ambient (caused by ambient light) Diffuse („normal“ reflection) Specular (highlight reflections of

polished material) No inter-object reflections in Java 3D. Light sources are not visible itself.

Tutorial Page 6-2

Page 72: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsInfluence There is no warning for leaving

light out of a scene. There is no warning for not setting

a light source its influencing bounds.

Some light types have a attenuation setting.

Tutorial Page 6-8 6-9

Page 73: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsDifferent Light Types Ambient light

As if the sky was cloudy. Directional light

For the virtual „sun“. Point light

For virtual lamps. Spot light

Virtual spot lamps.

Tutorial Page 6-11 ff

Page 74: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsMixing Light Why does an object appear in a

certain color? White sphere, red and blue light ->

result?

Tutorial Page 6-17

Page 75: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsMaterial Object Color settings of the material

object represent „reflection coefficients“.

Shininess is an interesting value.

Tutorial Page 6-21

Page 76: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsOther Coloring Possibilities No lights needed, but no „shiny“

effects: ColoringAttributes Per-vertex color (KickCan example:

class Floor).

Tutorial Page 6-23

Page 77: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

LightsShadows There are no built-in shadows in

Java 3D. Shadows in the tutorial are created

using hand-made classes and polygones.

Page 78: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Textures Basic Principles Create a Simple Texture

Page 79: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

TexturesObjectives Know what a texture is and why

we need it. Be able to program simple

textures.

Page 80: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

TexturesBasic Principles Detailed surface structures are

hard and expensive to build in 3D -> Texture!

„Texel“ is „texture element“ -> one pixel of a texture.

Texture mapping: Fit image to a given geometry.

Page 81: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

TexturesCreate a Simple Texture Load an image

Create a texture

Create 3D-object with appearance

String filename = "earth.jpg"; TextureLoader loader = new TextureLoader(filename, this);ImageComponent2D image = loader.getImage();

Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());texture.setImage(0, image);

Appearance appear = new Appearance(); appear.setTexture(texture);

Sphere earth = new Sphere(1.0f, Primitive.GENERATE_TEXTURE_COORDS, appear));

Page 82: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project Information Gathering Set-up Deliverables

Page 83: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

ProjectObjectives Apply all what you have learned. Learn more of the Java 3D API and

3D computer graphics. Know what you want to do ->

concept, system design, ...

Page 84: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

ProjectInformation Gathering Search the web, get ideas. Do a brain storming or something

similar -> write down your ideas. Form project groups. Discuss your ideas so that you get

ready to start with a concept.

Page 85: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

ProjectSet-up Participants of the project. Discussed your idea with the

teacher.

Page 86: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

ProjectDeliverables The deliverables are: source and

documentation of the project. Documentation as HTML page or

paper. Turn in source and documentation:

ZIP file by mail (or link for download if size > 1MB)

or CD-ROM

Page 87: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More... Spline Functions 3D-modelling Professional Rendering POVRay Example

Page 88: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More…Objectives Get a little outlook on what

happens outside of Java 3D. Have an idea of professional tools

used in computer graphics. Hands-on experience with POVRay.

Page 89: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More…Spline Functions Base: Spline Functions Applications of Spline Functions in:

Spline Curves, Spline Surfaces Advantages: Smooth surfaces (!) Application in Java 3D:

com.sun.j3d.utils.behaviors.interpolators.TCBSplineInterpolator

Page 90: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More…3D-modelling LightWave (www.newtek.com) ZOOM

Page 91: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More…Professional Rendering Rendering for films like Toy Story or

Titanic is done with rendering products. Performance is far from real time but

the experience pretty close to real world.

Examples of Products: PRMan (www.pixar.com) BMRT (www.bmrt.org) POVRay (www.povray.org)

Page 92: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

A Bit More…POVRay Example Download POVRay from

ftp.hta-bi.bfh.ch (Windows Version) Install locally Create a ready-made scene Play around

Page 93: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

ProjectWhat to do? A Paper describing a 3D computer

graphics related aspect. A Java 3D program (little demo,

game, a start for a bigger project…). A demo with an other 3D software

(PRMan, BRMT, PovRay). A picture of a 3D-contest (e.g.

PovRay).

Page 94: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project Presentations Deliverables Presentations!

Page 95: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project PresentationsDeliverables Turn in source and documentation:

ZIP file by mail (or link for download)or CD-ROM

Due Date: 2nd March [email protected]

Page 96: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project PresentationsPresentations!

1 Daniel Glauser 3D-Bomberman

2 Ramon Keller 3D-Schach

3 Nicolas Leuba Fisch-Aquarium

4 Roger MathysPascal Moser

Murmelbahn

5 Philippe SchnyderPhilippe SchochMarkus Trachsel

3D-Würfel

6 Stefan Rufer RenderMan / BMRT

Page 97: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project RenderMan / BMRT What is RenderMan? What is BMRT? What is Radiosity?

Page 98: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project RenderMan / BMRTWhat is RenderMan? Open interface by Pixar. Interface for 3D-model rendering. Provides extension possibilities for

custom shading and gadgets. This is NOT an implementation.

Page 99: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project RenderMan / BMRTWhat is BMRT? BMRT is a free 3D-renderer by

BlueMountain Corp. BMRT is partly RenderMan compatible. Contains various tools. Most important:

rgl: Simple, fast renderer for previews. rendrib: High-end renderer providing ray-

tracing, radiosity, programmable shading…

Page 100: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project RenderMan / BMRTWhat is Radiosity? Imagine: Blue room with white chair

chair appears a bit blue! Compute diffuse, inter-object

reflections RayTracing uses AmbientLight to

simulate this not too good. Radiosity approximates diffuse,

inter-object reflections.

Page 101: Java 3D Introduction

Stefan Rufer, HTA Biel, 2000 Java 3D – an Introduction

Project RenderMan / BMRTRadiosity examples

rendribquality

rglpreview