Graphical Programming (1) Graphical Programming (2) Graphical ...

4 downloads 1025 Views 281KB Size Report
OpenGL / Windows System. What is OpenGL? ▫ OpenGL is a hardware. OpenGL is a hardware-independent interface independent interface to the graphics ...
Graphical Programming (2)

Graphical Programming (1)

X-Windows  X-protocol, Xlib, window manager  OSF/Motif  widgets, widgets gadgets, gadgets window manager  MS MS--Windows  RenderMan  OpenGL  Direct3D 

programs to process and manipulate graphical objects and data  early standards: PHIGS PHIGS, GKS  2D, 3D graphics libraries  level of abstraction  low low--level API: OpenGL  scene graph API: Java3D 

1 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

OpenInventor, VRML, X3D  scene graph oriented  engines, sensors, manipulators



IRIS Performer



Java3D

What is OpenGL?  OpenGL is a hardware hardware--independent interface to the graphics hardware OpenGL does not provide rendering context management functions or means to manage user input → Interface between OS and OpenGL needed:  WGL / Microsoft Windows  GLX / UNIX's X X--Windows (direct and indirect rendering)  GLUT / OS independent 3 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

Java Applet/Application



Hierarchical structure



Corresponds to logical structure of the scene



Easy design and manipulation of complex scenes

Java 3D DirectX

Graphics Hardware E.Gröller, H. Doleisch, L. Mroz, S. Grimm

4 / 24

Scenegraph

Java3D

OpenGL

2 / 24

OpenGL / Windows System

Graphical Programming (3) 

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

5 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

6 / 24

1

J3D--Scenegraph J3D content

The Renderer viewing

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

7 / 24



Double buffering, RGB(A)



Infinite loop: Traverse Graph



Take care of transparency



Regions of influence of fog, lights, sound



Optimized for rendering (display list)

Node States - Capabilities  

Java3D Node Types

Node created: all operations legal Live:: Node inserted into scene Live - capabilities specify permitted operations p ((r / w / modify) y)



Group nodes - addChild(...) 

BranchGroup - only detachable/relocable node - grouping of Shapes



TransformGroup - transform applied to all children

setCapability(ALLOW_TRANSFORM_WRITE); setCapability( ALLOW_TRANSFORM_WRITE);





Compiled (optional): Optimized by renderer - modifications restricted Capabilities fixed if live or compiled

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

8 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

9 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

Hello3D! / Scenegraph

10 / 24

Hello3D! / Constructor ... Canvas3D c=new Canvas3D(null); aWindow.add(c); BranchGroup content=createSceneGraph(); SimpleUniverse u=new SimpleUniverse(c); u.addBranchGraph(content);//now “live” ...

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

11 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

12 / 24

2

Hello3D! Content

Java3D Node Types

Public BranchGroup createSceneGraph(){ BranchGroup objRoot=new BranchGroup(); Transform3D spin=new Transform3D(); Transform3D tmpspin=new Transform3D(); spin.rotX(Math.PI/4.0d); t tmpspin.rotY(Math.PI/5.0d); i tY(M th PI/5 0d) spin.mul(tmpspin); TransformGroup objTrans=new TransformGroup(spin); objRoot.addChild(objTrans); objTrans.addChild(new ColorCube()); return objRoot();} E.Gröller, H. Doleisch, L. Mroz, S. Grimm



Shape3D - defines object within the scene Contains: Geometry - polygon related information  Attributes - material definition - rendering mode (wireframe, …) 

13 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

Geometry Nodes

14 / 24

Geometry Nodes Geometry definition:

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

15 / 24

Helper Classes



coordinates



optional: normals



optional: RGB(A) color



optional: texture coord. (u/v[/w])



for indexed types: indices

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

16 / 24

Helper Classes  javax.vecmath javax.vecmath.* .*

- Tuple/Point/Vector Tuple/Point/Vector 2/3/4D d/float with corresponding operations - Matrix 3/4D d/float - Quaternion classes  javax.media.j3d.Transform3D - 4D matrix + helper func. func. for CG: orth//persp orth persp.. Projection, scale, rotate, translate, …

 com.sun.j3d.utils.*

- SimpleUniverse SimpleUniverse:: fast viewing model setup - Mouse Mouse--> Transform mapping for interactions - Simple geometrical Objects (cube, …)

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

17 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

18 / 24

3

Appearance

Lighting

Defines attributes for rendering geometry of an object - polygon attributes: pts/wirefr./fill - culling - rendering attrib.: zz-buff., -blend. - transp./color (if not per vertex) - material (reflection coefficients) - texture images E.Gröller, H. Doleisch, L. Mroz, S. Grimm

19 / 24

Behaviors

Ambient be t



Directional (infinitely distant)



PointLight (spot light)

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

20 / 24

 Influence

transform. / geometry  Examples: - Mouse controlled navigation - Interpolator: timetime->value - ProximitySensor - Collision reaction - Picking: Click -> list of Shape3Ds below mouse 21 / 24

Viewing Model 



Behaviors

“Events” for the scenegraph  Action executed if criteria met: - time triggered, kbd & mouse events, picking of objects, collision, frames elapsed  Boolean combination of criteria  Bounded area of relevance  processStimulus() E.Gröller, H. Doleisch, L. Mroz, S. Grimm

Light source nodes require Bounds delimiting the area of influence

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

22 / 24

Java3D - Further Material

Supports multiple Canvas3D -> stereo rendering, (Cave!)



Support for tracking tracking.



Detailed description of viewer’s

Java 3D API specification documentation & tutorial: https://java3d.dev.java.net/

eyes/ears configuration

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

23 / 24

E.Gröller, H. Doleisch, L. Mroz, S. Grimm

24 / 24

4