Download Prog4IntLecture3Graphics

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Hold-And-Modify wikipedia, lookup

Free and open-source graphics device driver wikipedia, lookup

General-purpose computing on graphics processing units wikipedia, lookup

Waveform graphics wikipedia, lookup

BSAVE (bitmap format) wikipedia, lookup

Video card wikipedia, lookup

Tektronix 4010 wikipedia, lookup

Apple II graphics wikipedia, lookup

2.5D wikipedia, lookup

Comparison of OpenGL and Direct3D wikipedia, lookup

Molecular graphics wikipedia, lookup

Mesa (computer graphics) wikipedia, lookup

OpenGL wikipedia, lookup

Graphics processing unit wikipedia, lookup

Framebuffer wikipedia, lookup

Programming for Interactivity
Professor Bill Tomlinson
Tuesday & Wednesday
Fall 2005
• Logins
• Resources for Assignment 1
– Do you have everything you need?
Answers to Last Week’s Questions
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 field list.
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.
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.
• Lynn Stein
• The rest of her online book is
recommended if you’re just getting up to
speed with Java and/or object-oriented
More Intro to Java
Java API Specification
• How to use it.
• Example: java.awt.Graphics.drawOval
• 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…
To change the size of the applet that appears in the browser, you may need
to change the index.html file.
Simple Applet Example
<APPLET code="BasicGraphicsSystem" width=501 height=511>
Your browser does not support Java, so nothing is displayed.
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?
• Writing test cases to make sure something
works correctly before moving on.
Vector vs. Pixel-Based
• Java does both
• “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
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
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
• Traditional animation principles still apply
to real-time computer animation (if you
want them to):
– Anticipation
– Follow Through
– Squash & Stretch
(with conservation
of mass)
Interactive animation
• Responsiveness vs. expressiveness
• Role of the participant
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
• “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 (
• RGBA – Red, Green, Blue, Alpha
Bill’s Mobile Device Sim…
3D Graphics
• OpenGL (and JOGL)
• DirectX
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.
• “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
JOGL Demos
• Run one or two…
Virtual Worlds
Autonomous characters
World characteristics
Virtual cinematography
Participant interaction
Sound system
3D Animation Programs
• Maya
• 3D Studio Max (site license)
• Useful for making source material for realtime 3D graphics.
Texture Mapping
• Technique for mapping an image onto an
object in a scene.
Rendering Styles
• Photorealistic
• Non-photorealistic
• Seeks to recreate real life
Stanford - Hanrahan
Debevec - Fiat Lux
• Video
• Meier, 96
Cartoon Shader
• Angle between normal and camera
provides index for sampling data from
texture map.
• Transparency
Good NPR Site
• Craig Reynolds
Techniques for maintaining frame
Low-polygon modeling
Level of detail
• Game levels/rooms
• Game design
Collision Detection Methods
Sphere/Sphere Overlap
Axis Aligned Bounding Boxes (x, y)
Object Bounding Boxes Pixel Based CD
Polygon/Hierarchical Subtrees
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
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)
camPos & lookAt
• Where the camera is and where it is
• Requires linear algebra (vectors, dot
products, etc.)
• Camera updates like a character
The Two Character Shot
• Draw it…
World coordinates vs. Character
• Which is better? (Draw example)
• Continuous
• Cuts
• Whip-pans
Real-time Lighting
• Few lights
• Limited capabilities
Interdevice Animation
Rendering style
Frame rate
Evolving Graphics
• Karl Sims Movie
Reminder about Dourish Reading
• For discussion tomorrow.