Programming for Interactivity

54
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005

description

Programming for Interactivity. Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005. Logistics. Logins Resources for Assignment 1 Do you have everything you need?. Answers to Last Week’s Questions. Argument ADDITIONS SERIES 1997 argument , n. - PowerPoint PPT Presentation

Transcript of Programming for Interactivity

Page 1: Programming for Interactivity

Programming for Interactivity

Professor Bill TomlinsonTuesday & Wednesday

6:00-7:50pmFall 2005

Page 2: Programming for Interactivity

Logistics

• Logins

• Resources for Assignment 1– Do you have everything you need?

Page 3: Programming for Interactivity

Answers to Last Week’s Questions

ArgumentADDITIONS SERIES 1997 argument, n.Add:    [2.] b. Math. and Computing. An independent variable of a function (e.g.

x and y in z = f(x, y)). 1865 BRANDE & COX Dict. Sci., Lit., & Art I. 768 Any trigonometrical function of phi is termed an elliptic function, having the argument u and modulus k. 1879 Encycl. Brit. IX. 818/1 In each case u is the independent variable or argument of the function. 1946 Nature 12 Oct. 503/2 The ENIAC has three function tables.., each of which comprises an array of switches on which 6-figure values of two functions, with signs, or a 12-figure value of one function, can be set up for each of 104 values of an argument. 1974 A. V. AHO et al. Design & Anal. Computer Algorithms i. 37 After a function procedure has been defined, it can be invoked in an expression by using its name with the desired arguments. 1984 Computerworld 5 Mar. 54 Use of Boolean commands to connect a segment search argument with the next argument list in the..search field list.

Page 4: Programming for Interactivity

Answers to Last Week’s Questions

• JOGL book – Asked my students. Answer: Didn’t use a book. It’s very similar to OpenGL. They used online resources, esp. those for OpenGL.

Page 5: Programming for Interactivity

Answers to Last Week’s Questions

• System.err.println - Typically this stream corresponds to display output or another output destination specified by the host environment or user. By convention, this output stream is used to display error messages or other information that should come to the immediate attention of a user even if the principal output stream, the value of the variable out, has been redirected to a file or other destination that is typically not continuously monitored.

– http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html#err

Page 6: Programming for Interactivity

Reading

• Lynn Stein

• The rest of her online book is recommended if you’re just getting up to speed with Java and/or object-oriented programming.

Page 7: Programming for Interactivity

More Intro to Java

Page 8: Programming for Interactivity

Java API Specification

• How to use it.

• http://java.sun.com/j2se/1.5.0/docs/api/index.html

• Example: java.awt.Graphics.drawOval

Page 9: Programming for Interactivity

Exceptions

• Null Pointer Exception– Objects and pointers– Happen when code tries to act on the object that a

pointer is pointing to, but the pointer is not pointing to an object.

• ArrayOutOfBoundsException– Happens when code asks for data from an array that

is at a higher index than the size of the array.

• And many more…

Page 10: Programming for Interactivity

index.html• To change the size of the applet that appears in the browser, you may need

to change the index.html file.

<HTML><HEAD><TITLE>Simple Applet Example</TITLE></HEAD><BODY><APPLET code="BasicGraphicsSystem" width=501 height=511>Your browser does not support Java, so nothing is displayed.</APPLET></BODY></HTML>

Page 11: Programming for Interactivity

Writing Robust and Extensible Code

• I may ask you to change something subtly and recompile it tomorrow. Will your code respond well and “do the right thing,” or is it brittle?

Page 12: Programming for Interactivity

Testing

• Writing test cases to make sure something works correctly before moving on.

Page 13: Programming for Interactivity

Graphics

Page 14: Programming for Interactivity

Vector vs. Pixel-Based

• Java does both

Page 15: Programming for Interactivity

Framebuffers

• “The framebuffer is a part of RAM in a computer allocated to hold the graphics information for one frame or picture. This information typically consists of color values for every pixel (point that can be displayed) on the screen.”

– Wikipedia

• Assignment 1 is a simple simulated framebuffer.

Page 16: Programming for Interactivity

Update loops

• To move from static graphics to animated graphics, it is necessary for the code to take action repeatedly.

• Assignment 1 introduces you to a simple update loop.

• (Also called the main loop or main event loop.)

Page 17: Programming for Interactivity

Time Keeping

• 2 models– Real world time – based on world time such

as System.currentTimeMillis();– Virtual world time – based on virtual time such

as timeCounter++;

• Which model does the Assignment 1 code use?

Page 18: Programming for Interactivity

Animation

• Traditional animation principles still apply to real-time computer animation (if you want them to):– Anticipation– Follow Through– Squash & Stretch

(with conservation

of mass)

Page 19: Programming for Interactivity

Interactive animation

• Responsiveness vs. expressiveness

• Role of the participant

Page 20: Programming for Interactivity

2D graphics – GUIs, etc.

• AWT vs. Swing

• “"Swing" refers to the new library of GUI controls (buttons, sliders, checkboxes, etc.) that replaces the somewhat weak and inflexible AWT controls.”

– From http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/

Page 21: Programming for Interactivity

Java2D

• “In Java 1.2, the paintComponent method is supplied with a Graphics2D object (a subclass of Graphics), which contains a much richer set of drawing operations. It includes pen widths, dashed lines, image and gradient color fill patterns, the use of arbitrary local fonts, a floating point coordinate system, and a number of coordinate transformation operations.”

– From (http://www.apl.jhu.edu/~hall/java/Java2D-Tutorial.html)

Page 22: Programming for Interactivity

Color

• RGBA – Red, Green, Blue, Alpha

Page 23: Programming for Interactivity

Bill’s Mobile Device Sim…

Page 24: Programming for Interactivity

3D Graphics

• OpenGL (and JOGL)

• DirectX

Page 25: Programming for Interactivity

OpenGL (or JOGL) vs. DirectX

• Both vertex based graphics APIs

• A range of different capabilities.

• My group uses JOGL because it works on multiple operating systems.

Page 26: Programming for Interactivity

JOGL

• https://jogl.dev.java.net/• “The JOGL Project hosts a reference

implementation of the Java bindings for OpenGL API, and is designed to provide hardware-supported 3D graphics to applications written in Java. It is part of a suite of open-source technologies initiated by the Game Technology Group at Sun Microsystems.”

Page 27: Programming for Interactivity

JOGL Demos

• Run one or two…

Page 28: Programming for Interactivity

Virtual Worlds

• Autonomous characters

• World characteristics

• Virtual cinematography

• Participant interaction

• Sound system

Page 29: Programming for Interactivity

3D Animation Programs

• Maya

• 3D Studio Max (site license)

• Useful for making source material for real-time 3D graphics.

Page 30: Programming for Interactivity

Meshes

Page 31: Programming for Interactivity

Texture Mapping

• Technique for mapping an image onto an object in a scene.

Page 32: Programming for Interactivity

Rendering Styles

• Photorealistic

• Non-photorealistic

Page 33: Programming for Interactivity

Photorealistic

• Seeks to recreate real life

Page 34: Programming for Interactivity

Stanford - Hanrahan

Page 35: Programming for Interactivity

Debevec - Fiat Lux

• Video

Page 36: Programming for Interactivity

Skin, ATI, SIGGRAPH 04

Page 37: Programming for Interactivity

Non-Photorealistic

• Meier, 96

Page 38: Programming for Interactivity

Rutgers

Page 39: Programming for Interactivity

AlphaWolf

Page 40: Programming for Interactivity

Cartoon Shader

• Angle between normal and camera provides index for sampling data from texture map.

• Transparency

Page 41: Programming for Interactivity

Good NPR Site

• Craig Reynolds

• http://www.red3d.com/cwr/npr

Page 42: Programming for Interactivity

Techniques for maintaining frame rate

• Low-polygon modeling

• Level of detail

• Culling

• Procedural generation

• Game levels/rooms

• Game design

Page 43: Programming for Interactivity

Collision Detection Methods

• Sphere/Sphere Overlap

• Axis Aligned Bounding Boxes (x, y)

• Object Bounding Boxes Pixel Based CD

• Polygon/Hierarchical Subtrees

Page 44: Programming for Interactivity

Static vs. Dynamic Intersection

• Collision checks can be performed at discrete time steps, simple & efficient but can cause problems if steps are not much smaller than velocities (penetration, innacurate collision directions, and completely missing collisons, etc.)

• Dynamic checks take into current trajectory of objects. More complex to check but can solve above problems

Page 45: Programming for Interactivity

Autonomous Cinematography

• In a virtual world, who decides where the camera goes?

• Some of the same problems as film cinematography – expressiveness, appearance of continuity, etc.

• Some additional problems – interactivity, continuity of time (esp. when networked)

Page 46: Programming for Interactivity

camPos & lookAt

• Where the camera is and where it is looking

• Requires linear algebra (vectors, dot products, etc.)

• Camera updates like a character

Page 47: Programming for Interactivity

The Two Character Shot

• Draw it…

Page 48: Programming for Interactivity

World coordinates vs. Character coordinates

• Which is better? (Draw example)

Page 49: Programming for Interactivity

Transitions

• Continuous

• Cuts

• Whip-pans

Page 50: Programming for Interactivity

Lighting

Page 51: Programming for Interactivity

Real-time Lighting

• Few lights

• Limited capabilities

Page 52: Programming for Interactivity

Interdevice Animation

• Position

• Direction

• Size

• Rendering style

• Frame rate

• Resolution

Page 53: Programming for Interactivity

Evolving Graphics

• Karl Sims Movie

Page 54: Programming for Interactivity

Reminder about Dourish Reading

• For discussion tomorrow.