Upload
barnaby-tyler
View
219
Download
0
Tags:
Embed Size (px)
Citation preview
104/19/23 11:52
Graphics II Syllabus
Selection and Picking
Session 1
204/19/23 11:52
Course Website:
www.cs.uml.edu/~hmasterm/graphics2.html
304/19/23 11:52
Parametric Surfaces
404/19/23 11:52
Shadowing Techniques
504/19/23 11:52
Rendered with Gouraud Shading
604/19/23 11:52
Rendered with Ray Tracing
704/19/23 11:52
Rendered with Radiosity
804/19/23 11:52
Environment Mapping
904/19/23 11:52
Realistic Materials
Image: R. Rost: OpenGL Shading Language, Addison Wesley
1004/19/23 11:52
Diffraction and Chromatic Aberration
Image: R. Rost: OpenGL Shading Language, Addison Wesley
1104/19/23 11:52
Noise Textures
Image: R. Rost: OpenGL Shading Language, Addison Wesley
1204/19/23 11:52
Volume Rendering
1304/19/23 11:52
Volume Rendering:Medical Application
1404/19/23 11:52
Image Based Rendering
View Morph Demo:
1504/19/23 11:52
Simple Legged AnimationAnkle Rotation Script
1604/19/23 11:52
Simple Legged AnimationResulting Animation
1704/19/23 11:52
Nonlinear Global DeformationAn Example
Undeformed
Taper
Twist
Bend
1804/19/23 11:52
Factor Curves:An Example: the Animated Spoon
1904/19/23 11:52
PICKING
Direct Manipulation Demo
2004/19/23 11:52
Computer GraphicsConceptual Model
ApplicationModel
ApplicationProgram Graphics
System
OutputDevices
InputDevices
API
Function Callsor Protocol
Data
2104/19/23 11:52
Interaction with Graphics System
ChangeImage
Reactto
Change
Graphics System User
InputDevice
Display
2204/19/23 11:52
Logical Input Devices
0 String- Provides ASCII strings to user program- Usually implemented as physical keyboard
0 Locator- Inputs position in defined coordinate system- Absolute vs. relative- Direct vs. indirect
0 Choice- Choice among a discrete number of options- Implemented by menus or control button widget
0 Valuator (or Dial)- Provides analog input to user program- Bounded vs. unbounded- Often implemented as slidebar widget
2304/19/23 11:52
Logical Input Devices, contd.
0 Pick - Returns identifier of an object to user program- Can be implemented by locator and choice
0 Stroke- Returns an array of locations- Can be implemented by locator and choice
2404/19/23 11:52
Event Mode Input
EventQueue Program
Await
Event
TriggerProcess
MeasureProcess
Trigger Event:Device & Measure
Events
2504/19/23 11:52
OpenGL Geometric Pipline
ModelviewTransformation
Vertex Coordinatesx, y, z, w
Object Coordinates
Eye Coordinates
Clip Coordinates
Device Coordinates
Window Coordinates x,y
ProjectionTransformation
PerspectiveDivision
ViewportTransformation
Modelview Matrix
Projection Matrix
Part of OpenGL State
ViewportTransformation
2604/19/23 11:52
Object Picking by Ray Tracing
p1
COP
p2
WindowCoordinates
Object 1Object 2
2704/19/23 11:52
Picking is supported bySelection in OpenGL
z
x
y
Yellow Cube
1
zmin
zmax
Yellow Cube
Name Stack
Select Buffer
# Names on Stack
2804/19/23 11:52
OpenGL Rendering Mode
glRenderMode()GL_RENDER
GL_SELECT 1
zmin
zmax
Yellow CubeglRenderMode(GL_RENDER) returns the number of hits while in SELECT mode
2904/19/23 11:52
Selection in OpenGL:The Basic Steps
0 Specify the array to be used for the returned hit records using: glSelectBuffer()
0 Enter the selection mode using: glRenderMode(GL_SELECT);
0 Initialize the name stack using: glInitNames();0 Define the viewing volume you want to use for selection. This
does not have to be the same as used for viewing.0 Alternately issue primitive drawing commands and
commands to manipulate the name stack so that each primitive of interest has a name assigned.
0 Exit selection mode using: glRenderMode(GL_RENDER); and process the returned selection data in the select buffer.
3004/19/23 11:52
Initializing a Select Buffer
Void glSelectBuffer(Glsizei size, Gluint *buffer);
You must call glSelectBuffer() beforeentering select mode.
0
1
2
size-1
32-bitunsignedintegers
3104/19/23 11:52
Manipulating the Name Stack
glInitNames(void); Clears the name stack so that it’s empty
glPushName(Gluint name); Pushes name onto name stack
glPopName(void); Pops one name off the top of the name stack
glLoadName(Gluint name); Replaces the value on top of the name stackNote: returns error if stack is empty. Therefore push at least one name onstack using glPushName() first.
3204/19/23 11:52
Interpreting the Hit Record:Contents of the Selection Buffer
num_hits
zmin
zmax
name
glRenderMode() returns the number of hits thatcan be used to index into Selection Buffer
num_hits is an unsigned integer corresponding to the number of hits before name stack is manipulated
zmin and zmax store the maximum and minimumz-buffer value values for each hit. Z ranges in [0.0, 1.0] which is normalized as a 32 bit unsignedinteger in range [0, 232-1]
name is an unsigned integer
3304/19/23 11:52
Selection:Code Example
120 goto 120
3404/19/23 11:52
Picking in OpenGL
y
xz
z
x
y
Plane z= -1
Plane z= +1
DOP
z
x
y
Perspective View Volume Canonical View Volume
Projection
Transform
Pick MatrixTransform
Screen Coordinates
3504/19/23 11:52
Generating a Pick Matrix
Void gluPickMatrix(GLdouble x, Gldouble y, Gldouble width, Gldouble height, Gl int viewport[4]);
x cursor x location in window coordinatesy cursor y location in window coordinateswidth width of the picking region in screen coordinatesheight height of the picking region in screen coordinatesviewport current viewport boundaries in pixel screen coordinates
Typical usage:
glMatrixMode (GL_PROJECTION);glPushMatrix();glLoadIdentity();gluPickMatrix(. . .);gluPerspective( or glOrtho, glFrustrum, etc)/* draw the scene for picking */. . .glPopMatrix();
3604/19/23 11:52
Picking:Code Example
120 goto 120
3704/19/23 11:52
Backup Slide:OpenGL: Pick Matrix Transformation
z
x
y