380 likes | 552 Views
Graphics II Syllabus Selection and Picking. Session 1. Course Website:. www.cs.uml.edu/~hmasterm/graphics2.html. Parametric Surfaces. Shadowing Techniques. Rendered with Gouraud Shading. Rendered with Ray Tracing. Rendered with Radiosity. Environment Mapping. Realistic Materials.
E N D
Course Website: www.cs.uml.edu/~hmasterm/graphics2.html
Realistic Materials Image: R. Rost: OpenGL Shading Language, Addison Wesley
Diffraction and Chromatic Aberration Image: R. Rost: OpenGL Shading Language, Addison Wesley
Noise Textures Image: R. Rost: OpenGL Shading Language, Addison Wesley
Image Based Rendering View Morph Demo:
Nonlinear Global DeformationAn Example Undeformed Taper Twist Bend
PICKING Direct Manipulation Demo
Computer GraphicsConceptual Model API Output Devices Application Program Application Model Graphics System Input Devices Function Calls or Protocol Data
Interaction with Graphics System Graphics System User Display React to Change Change Image Input Device
Logical Input Devices • String • Provides ASCII strings to user program • Usually implemented as physical keyboard • Locator • Inputs position in defined coordinate system • Absolute vs. relative • Direct vs. indirect • Choice • Choice among a discrete number of options • Implemented by menus or control button widget • Valuator (or Dial) • Provides analog input to user program • Bounded vs. unbounded • Often implemented as slidebar widget
Logical Input Devices, contd. • Pick • Returns identifier of an object to user program • Can be implemented by locator and choice • Stroke • Returns an array of locations • Can be implemented by locator and choice
Event Mode Input Trigger Trigger Process Measure Process Event: Device & Measure Await Event Queue Program Events Event
OpenGL Geometric Pipline Vertex Coordinates x, y, z, w Object Coordinates Modelview Transformation Modelview Matrix Eye Coordinates Projection Transformation Projection Matrix Clip Coordinates Perspective Division Device Coordinates Viewport Transformation Viewport Transformation Part of OpenGL State Window Coordinates x,y
Object Picking by Ray Tracing Object 2 Object 1 p2 p1 COP Window Coordinates
Picking is supported bySelection in OpenGL Name Stack Yellow Cube y Select Buffer x 1 # Names on Stack zmin z zmax Yellow Cube
OpenGL Rendering Mode GL_RENDER glRenderMode() GL_SELECT 1 zmin zmax glRenderMode(GL_RENDER) returns the number of hits while in SELECT mode Yellow Cube
Selection in OpenGL:The Basic Steps • Specify the array to be used for the returned hit records using: glSelectBuffer() • Enter the selection mode using: glRenderMode(GL_SELECT); • Initialize the name stack using: glInitNames(); • Define the viewing volume you want to use for selection. This does not have to be the same as used for viewing. • Alternately issue primitive drawing commands and commands to manipulate the name stack so that each primitive of interest has a name assigned. • Exit selection mode using: glRenderMode(GL_RENDER); and process the returned selection data in the select buffer.
Initializing a Select Buffer Void glSelectBuffer(Glsizeisize,Gluint*buffer); 32-bit unsigned integers 0 1 2 size-1 You must call glSelectBuffer() before entering select mode.
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 stack Note: returns error if stack is empty. Therefore push at least one name on stack using glPushName()first.
Interpreting the Hit Record:Contents of the Selection Buffer glRenderMode()returns the number of hits that can 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 minimum z-buffer value values for each hit. Z ranges in [0.0, 1.0] which is normalized as a 32 bit unsigned integer in range [0, 232-1] name is an unsigned integer num_hits zmin zmax name
Selection:Code Example 120 goto 120
Picking in OpenGL Perspective View Volume Canonical View Volume Projection Transform Pick Matrix Transform Screen Coordinates
Generating a Pick Matrix Void gluPickMatrix(GLdouble x, Gldouble y, Gldouble width, Gldouble height, Gl int viewport[4]); x cursor x location in window coordinates y cursor y location in window coordinates width width of the picking region in screen coordinates height height of the picking region in screen coordinates viewport 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();
Picking:Code Example 120 goto 120
y x z Backup Slide:OpenGL: Pick Matrix Transformation