35
Graphical Programming Eduard Gröller , Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

Graphical Programming

Eduard Gröller, Johanna Schmidt

Institute of Computer Graphics and Algorithms

Vienna University of Technology

Page 2: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 1 / 12

Terms

Image Processing

Pattern Recognition

Computer Graphics

Page 3: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 2 / 12

Graphical Data Processing

Modeler

Transformations

Clipping

Shading

Visibility

Konversion

Driver

3D Data

Image Data

Modeling Rendering Display

Page 4: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 3 / 12

Graphical Data Processing

Modeler

Transformations

Clipping

Shading

Visibility

Konversion

Driver

3D Data

Image Data

Modeling Rendering Display

Page 5: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 4 / 12

Graphical Data Processing

Modeler

Transformations

Clipping

Shading

Visibility

Konversion

Driver

3D Data

Image Data

Modeling Rendering Display

Page 6: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 5 / 12

Graphical Data Processing

Modeler

Transformations

Clipping

Shading

Visibility

Konversion

Driver

3D Data

Image Data

Modeling Rendering Display

Page 7: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 6 / 12

Graphical Programming

Programs to process and manipulate

graphical objects and data

Several approaches already exists

Standards

Libraries

Page 8: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt

Standards

Early standards: GKS, PHIGS

X-Windows

X-protocol, Xlib, window manager

OSF/Motif

GUI programing for X-Windows

Microsoft Windows

Operating system / GUI interface

7 / 12

Page 9: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 8 / 12

Graphic Libraries

2D, 3D graphics libraries

Support for several modern programming

languages

Level of abstraction

Low-level APIs (e.g., OpenGL)

High-level (scene-graph) APIs

(e.g., Java3D)

Page 10: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 9 / 12

Graphic Libraries

OpenGL

API for 2D/3D graphics,

platform-independent

Direct3D

API for 2D/3D graphics, part

of DirectX

Page 11: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 10 / 12

Graphic Libraries

RenderMan

Page 12: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 11 / 12

Graphic Libraries

OpenInventor

System to create interactive 3D

graphics, based on C++ and OpenGL

VRML, X3D

3D graphics in web-browser

OpenGL Performer

Based on OpenGL, SGI-hardware

Page 13: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 12 / 12

Graphic Libraries

Java 3D

Java-based library to create interactive

3D graphics

Based on scene graph, structure

similar to VRML

Supports OpenGL and DirectX

Page 14: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

Java 3D

Eduard Gröller, Johanna Schmidt

Institute of Computer Graphics and Algorithms

Vienna University of Technology

Page 15: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 1 / 21

Java 3D

Graphics Hardware

OpenGL DirectX

Java 3D

Java Applet/Application

Page 16: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 2 / 21

Scene Graph

Hierarchical structure

Describes structure of the scene

Easy design and manipulation of

complex scenes

Page 17: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 3 / 21

Scene Graph in Java 3D

content viewing

Page 18: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 4 / 21

Viewing Model

Supports multiple Canvas3D -> stereo

rendering, CAVE

Support for tracking

Detailed description of

viewer’s eyes/ears

configuration

Page 19: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 5 / 21

Java 3D Node Types

Group nodes

BranchGroup (BG): groups child

nodes, only node that is detachable

TransformGroup (TG): describes

transformation

Page 20: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 6 / 21

Java 3D Node Types

Shape3D

Defines object in the scene, contains:

Geometry (polygon-related

information)

Attributes (material-related information,

render mode)

Page 21: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 7 / 21

Geometry

Page 22: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 8 / 21

Geometry

Geometry definition

Coordinates

Normals (optional)

RGB(A) color (optional)

Texture coordinates (optional)

For indexed types: indices

Page 23: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 9 / 21

Appearance

Defines attributes for rendering

Polygon attributes: culling, …

Rendering attrib.: z-buff., -blend., …

Transp./color (if not per vertex)

Material (reflection coefficients)

Textures

Page 24: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 10 / 21

Java 3D Node Types

Light

Defines light source

Types:

- AmbientLight

- DirectionalLight

- PointLight

- SpotLight

Page 25: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 11 / 21

Java 3D Node Types

Behaviour

“Events” for the scene graph

Examples:

- Mouse-controlled navigation

- Picking

- Collision reaction

Page 26: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 12 / 21

Behaviour

Action executed if criteria met: (-) time

triggered, (-) mouse events, (-) picking,

(-) collision, (-) frames elapsed

Boolean combination of criteria

Bounded area of relevance

processStimulus()

Page 27: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 13 / 21

Node States & Capabilities

Detached: node created

Live: nodes inserted into scene

Capabilities specify permitted

operations (r / w / modify)setCapability(ALLOW_TRANSFORM_WRITE);

Compiled (optional): nodes optimized by

renderer

modifications restricted

Page 28: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 14 / 21

Java 3D Helper Classes

javax.vecmath.*

Tuple/Point/Vector 2/3/4D d/float

Matrix 3/4D d/float

Quaternion classes

javax.media.j3d.Transform3D

orth/persp. Projection

scale, rotate, translate

Page 29: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 15 / 21

Java 3D Helper Classes

com.sun.j3d.utils.*

SimpleUniverse (fast setup of viewing

branch with default values)

Mouse -> Transform mapping

Simple geometrical objects

Page 30: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 16 / 21

Java 3D Renderer

Traverse scene graph

Double buffering, RGB(A)

Take care of transparency

Regions of influence of fog, lights, sound

Optimized for rendering (display list)

Page 31: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 17 / 21

Hello3D! / Scenegraph

Page 32: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 18 / 21

Hello3D! / Constructor

...

Canvas3D c=new Canvas3D(null);

aWindow.add(c);

BranchGroup content=createSceneGraph();

SimpleUniverse u=new SimpleUniverse(c);

u.addBranchGraph(content);//now “live”

...

Page 33: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 19 / 21

Hello3D! / Content

Public BranchGroup createSceneGraph(){

BranchGroup objRoot=new BranchGroup();

Transform3D spin=new Transform3D();

Transform3D tmpspin=new Transform3D();

spin.rotX(Math.PI/4.0d);

tmpspin.rotY(Math.PI/5.0d);

spin.mul(tmpspin);

TransformGroup objTrans=new

TransformGroup(spin);

objRoot.addChild(objTrans);

objTrans.addChild(new ColorCube());

return objRoot();}

Page 34: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 20 / 21

Hello3D!

Page 35: Graphical Programming - TU Wien · Graphical Programming Eduard Gröller, Johanna Schmidt Institute of Computer Graphics and Algorithms Vienna University of Technology

E.Gröller, J.Schmidt 21 / 21

Further Material

CG Reader

http://www.cg.tuwien.ac.at/courses/CG/VO.html

API & Documentation:

https://java3d.java.net/