multimedia graphics university of wollongong 2007 - lecture 1

5

Click here to load reader

Upload: eword

Post on 17-Jul-2016

218 views

Category:

Documents


3 download

DESCRIPTION

Multimedia Graphics University of Wollongong 2007 - Lecture 1

TRANSCRIPT

Page 1: Multimedia Graphics University of Wollongong 2007 - Lecture 1

ITCS941 Multimedia Graphics 2007

Creative - observational drawing- texture capture

Perspective on Multimedia GraphicsDraw an object (and photograph it) -> decompose into elementary solids -> if animated work out motions of solids and joints -> Write a program to create 3D image using solids -> if animated, write code to animate solids -> Use Photoshop to capture textures from images -> render textures on surfaces

Components

ProgrammingJOGL

Theory- spatial awareness- graphics engine design

http://www.uow.edu.au/~phillip/

Phillip McKerrow

Subject Handout

Quartz Compositor- graphical- data flow

Gears

Student Examples

Robot MobileRobot RockRobot

Commands

code drawingversusmanual drawing

http://www.genedavissoftware.com/books/jogl/

Examples

Page 2: Multimedia Graphics University of Wollongong 2007 - Lecture 1

Jogl - Java bindings for OpenGL Lecture 1

Fast, powerful 3D models (hardware accelerated)- games, medicine, architecture, videos

Text: Gene Davis, Learning Java Bindings for OpenGL(JOGL), Authorhouse

http://www.genedavissoftware.com/books/jogl/

Interesting Sites

http://www.genedavissoftware.com/

https://jogl.dev.java.net/

http://today.java.net/pub/a/today/2003/09/11/jogl2d.html

https://jogl-demos.dev.java.net/

Demo programs - click on image on web page to run JOGL applet (note must have JOGL installed on your computer)

Downloading and installing JOGL on Mac OSX

//Hello world test programimport net.java.games.jogl.*;public class HelloWorld {

public static void main (String args[]) { try { System.loadLibrary("jogl"); System.out.println("Hello World! (The native libraries are there.)"); GLCapabilities caps = new GLCapabilities(); System.out.println("Hello JOGL! (The jar appears to be available.)"); } catch (Exception e) { System.out.println(e); } }}

Go to downloads to find JavaDocs

http://www.uow.edu.au/~phillip/Phillip McKerrow

ITCS941 Multimedia Graphics 2007

NeHe Productions http://nehe.gamedev.net/

JavaDocs

JOGLInstallation HelloWorld

Page 3: Multimedia Graphics University of Wollongong 2007 - Lecture 1

public class Example { public static void main (String[] args) { float f1 = 0.999f; float f2 = 1.1f; double d1 = f1 + .001; double d2 = f2 - .1; //d1 != d2 as would be expected if (d1 == d2) System.out.println("d1 == d2"); else System.out.println(d1+" != "+d2); }}

Java Issues

What is the difference between:float f = 1.0;

andfloat f = 1.0f;

What is the output of the following code?

Event listener model(delegation model) used to respond to user interactions

component object - (Button) - thread triggers an event when user clicks button - sends event to registered listeners

event object - represents the action that has ocurred - e.g. user clicked mouse on button

listener object - implements a listener interface to listen for the event - has code for dealing with the event - any object can be a listener

1.

2.

3.

private Button left; //1. Component object private Display myDisplay; //2. Class that listens for eventpublic TestApplication() { ........ left.addActionListener(myDisplay); //1. Register myDisplay class with the button

public class Display extends Canvas implements ActionListener {//2. implements ActionListener interface

public void actionPerformed(ActionEvent e) { //3. event passed in////2. code to deal with event

Page 4: Multimedia Graphics University of Wollongong 2007 - Lecture 1

public class Display extends Canvas implements ActionListener {//2. implements ActionListener interface

public void actionPerformed(ActionEvent e) { //3. event passed in////2. code to deal with event

Java runtime - a thread that call methods - "magic"event loop looks at event list and whenevent occurs calls associated actionListenerpaint - calls the paint function to redraw the windowinit - initialisation of variables in applet - done by constructor in application

Simulation or Animationmodel - calculates new coordinate values - mathsrendering - draws object at new position - graphics

GLEventListener - must implement 4 methodsinit(GLDrawable drawable)

          Called by the drawable immediately after the OpenGL context is initialized for the first time.for the first time

display(GLDrawable drawable)           Called by the drawable to initiate OpenGL rendering by the client.

displayChanged() -reshape() -

Implements versus extendsPolymorphismHeavy versus light weight components

GLDrawable - an interface- all drawing happens in GLDrawables- GLCanvas and GLJPanel are GLDrawables

JNI - GlueGen

JOGL template

JOGL example

JFrame

SimpleJOGLApp

GLDrawable

GLCanvas

GLEventListener

SimpleGLEventListener

TestApplet TestApplication

Java Docs

SimpleJoglApp

SecondJoglApp

Page 5: Multimedia Graphics University of Wollongong 2007 - Lecture 1

Exam Questions1. What are the 3 objects in the event-listener model used for handling events in Java?2. What are the 4 methods that must be implemented by a GLEventListener?3. What is a model used for when drawing a moving object?4. What is the purpose of the display(Drawable) method of the GLEventlistener interface?

Additional Example

http://java.sun.com/developer/JDCTechTips/2005/tt0208.html

Introduction to JOGL

Sample