37
1 03/25/22 17:36 Graphics II Syllabus Selection and Picking Session 1

19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

Embed Size (px)

Citation preview

Page 1: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

104/19/23 11:52

Graphics II Syllabus

Selection and Picking

Session 1

Page 2: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

204/19/23 11:52

Course Website:

www.cs.uml.edu/~hmasterm/graphics2.html

Page 3: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

304/19/23 11:52

Parametric Surfaces

Page 4: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

404/19/23 11:52

Shadowing Techniques

Page 5: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

504/19/23 11:52

Rendered with Gouraud Shading

Page 6: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

604/19/23 11:52

Rendered with Ray Tracing

Page 7: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

704/19/23 11:52

Rendered with Radiosity

Page 8: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

804/19/23 11:52

Environment Mapping

Page 9: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

904/19/23 11:52

Realistic Materials

Image: R. Rost: OpenGL Shading Language, Addison Wesley

Page 10: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1004/19/23 11:52

Diffraction and Chromatic Aberration

Image: R. Rost: OpenGL Shading Language, Addison Wesley

Page 11: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1104/19/23 11:52

Noise Textures

Image: R. Rost: OpenGL Shading Language, Addison Wesley

Page 12: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1204/19/23 11:52

Volume Rendering

Page 13: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1304/19/23 11:52

Volume Rendering:Medical Application

Page 14: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1404/19/23 11:52

Image Based Rendering

View Morph Demo:

Page 15: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1504/19/23 11:52

Simple Legged AnimationAnkle Rotation Script

Page 16: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1604/19/23 11:52

Simple Legged AnimationResulting Animation

Page 17: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1704/19/23 11:52

Nonlinear Global DeformationAn Example

Undeformed

Taper

Twist

Bend

Page 18: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1804/19/23 11:52

Factor Curves:An Example: the Animated Spoon

Page 19: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

1904/19/23 11:52

PICKING

Direct Manipulation Demo

Page 20: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

2004/19/23 11:52

Computer GraphicsConceptual Model

ApplicationModel

ApplicationProgram Graphics

System

OutputDevices

InputDevices

API

Function Callsor Protocol

Data

Page 21: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

2104/19/23 11:52

Interaction with Graphics System

ChangeImage

Reactto

Change

Graphics System User

InputDevice

Display

Page 22: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 23: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 24: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

2404/19/23 11:52

Event Mode Input

EventQueue Program

Await

Event

TriggerProcess

MeasureProcess

Trigger Event:Device & Measure

Events

Page 25: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 26: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

2604/19/23 11:52

Object Picking by Ray Tracing

p1

COP

p2

WindowCoordinates

Object 1Object 2

Page 27: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 28: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 29: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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.

Page 30: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 31: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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.

Page 32: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 33: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

3304/19/23 11:52

Selection:Code Example

120 goto 120

Page 34: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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

Page 35: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

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();

Page 36: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

3604/19/23 11:52

Picking:Code Example

120 goto 120

Page 37: 19/4/2015 15:32 Graphics II Syllabus Selection and Picking Session 1

3704/19/23 11:52

Backup Slide:OpenGL: Pick Matrix Transformation

z

x

y