Download Class 4

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

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

Document related concepts

Spatial anti-aliasing wikipedia , lookup

Free and open-source graphics device driver wikipedia , lookup

Hold-And-Modify wikipedia , lookup

Computer vision wikipedia , lookup

Video card wikipedia , lookup

BSAVE (bitmap format) wikipedia , lookup

Framebuffer wikipedia , lookup

Apple II graphics wikipedia , lookup

Graphics processing unit wikipedia , lookup

Waveform graphics wikipedia , lookup

2.5D wikipedia , lookup

Molecular graphics wikipedia , lookup

Tektronix 4010 wikipedia , lookup

Transcript
Informationsteknologi
Today’s class

Input and interaction
Tuesday, November 6, 2007
Computer Graphics - Class 4
1
Informationsteknologi
Interactive input devices

Locator
 specifies
coordinate positions
 examples: thumbwheels, tablet, mouse,
trackball, joystick, touch panel

Stroke
 specifies
a sequence of coordinate positions
 example: tablets
Tuesday, November 6, 2007
Computer Graphics - Class 4
2
Informationsteknologi
Interactive input devices
(cont.)

Pick
 selects
picture components
 example: light pen

Valuator
 specifies
scalar values
 example: dial
Tuesday, November 6, 2007
Computer Graphics - Class 4
3
Informationsteknologi
Interactive input devices
(cont.)

String
 specifies
text input
 example: keyboard

Choice
 selects
menu options
 examples: keyboard, mouse buttons
Tuesday, November 6, 2007
Computer Graphics - Class 4
4
Informationsteknologi
Event driven devices
CPU must wait on the device before it can
do anything
 Examples:

 keyboard
 mouse
Tuesday, November 6, 2007
Computer Graphics - Class 4
5
Informationsteknologi
Example: rubberbanding
Rubberbanding is the process of having a
visual indicator move around the graphics
window as the mouse moves
 Events that need to be recognized are
mouse movement and mouse button
clicks (to indicate starting and stopping of
rubberbanding)

Tuesday, November 6, 2007
Computer Graphics - Class 4
6
Informationsteknologi
Overlay planes



While rubberbanding the actual image must be
preserved
This is best accomplished by using an overlay plane,
such that the actual image is drawn in the normal draw
plane and the rubberbanding shape is drawn in the
overlay plane
The image seen on the screen is made up of the
layering of these two planes:


if a pixel in the overlay plane is transparent, the pixel in
the normal draw plane is seen
if a pixel in the overlay plane is a normal color, it is seen
and the image’s pixel is hidden
Tuesday, November 6, 2007
Computer Graphics - Class 4
7
Informationsteknologi
Overlay planes in OpenGL
and GLUT




glutEstablishOverlay(); is used to
establish an overlay plane
glutUseLayer(GLUT_OVERLAY); is used to
draw in the overlay plane
glutUseLayer(GLUT_NORMAL); is used to
return drawing to the normal draw plane
OpenGL keeps separate projection matrices for
overlay planes
Tuesday, November 6, 2007
Computer Graphics - Class 4
8
Informationsteknologi
Example program
Program rubberband.c illustrates
mouse events and the overlay plane
 It runs on the SGI and Sun workstations,
but not the laptops as Windows does not
support overlay planes

Tuesday, November 6, 2007
Computer Graphics - Class 4
9
Informationsteknologi
Overview of picking



First draw scene into frame buffer as usual
Now change to selection mode and redraw the
scene (contents of frame buffer will not change
until selection mode is exited)
Upon exit of selection mode, OpenGL returns a
list of primitives that would have intersected the
viewing volume
Tuesday, November 6, 2007
Computer Graphics - Class 4
10
Informationsteknologi
Overview of picking (cont.)



Each of these primitives causes a selection hit
The list of primitives returned as an array of
integer-valued names and related data (hit
records) that correspond to the current contents
of the name stack
Name stack is constructed by loading names
onto it as you issue primitive drawing
commands while in selection mode
Tuesday, November 6, 2007
Computer Graphics - Class 4
11
Informationsteknologi
Basic steps

Specify array to be used for the returned
hit records with glSelectBuffer(),
which is passed:
 maximum
number of values that can be
stored in the array
 an array capable of holding unsigned
integers

Enter selection mode with
glRenderMode (GL_SELECT);
Tuesday, November 6, 2007
Computer Graphics - Class 4
12
Informationsteknologi
Basic steps (cont.)

Initialise the name stack with
glInitNames(); and glPushName (-1);

Define the viewing volume you want for
selection with the help of gluPickMatrix()
(usually different from rendering, so you will
want to use glPushMatrix(); and
glPopMatrix(); to save and restore
rendering transformation
Tuesday, November 6, 2007
Computer Graphics - Class 4
13
Informationsteknologi
Basic steps (cont.)
Alternately issue commands to alter the
name stack and primitive drawing
commands so that each primitive of
interest has an appropriate name
assigned
 Exit selection mode and process the
returned selection data (the hit records)

Tuesday, November 6, 2007
Computer Graphics - Class 4
14
Informationsteknologi
Hit records

Contents, in order, of a hit record:
 Number
of names on the name stack when
the hit occurred
 Minimum and maximum window-coordinate z
values of all vertices of the primitives that
intersected the viewing volume since the last
recorded hit (they lie in the range 0-1 but are
multiplied by 232-1 and rounded to the
nearest unsigned integer)
Tuesday, November 6, 2007
Computer Graphics - Class 4
15
Informationsteknologi
Hit records (cont.)

Contents, in order, of a hit record (cont.):
 Contents
of the name stack at the time of the
hit, with the bottommost element first
Tuesday, November 6, 2007
Computer Graphics - Class 4
16
Informationsteknologi
Example program

Program picksquare.cpp
demonstrates the complete technique for
picking
Tuesday, November 6, 2007
Computer Graphics - Class 4
17