1 / 17

Today’s class

Learn about various interactive input devices used in computer graphics, such as locator, stroke, pick, valuator, string, and choice, and how they are implemented.

jfelecia
Télécharger la présentation

Today’s class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Today’s class • Input and interaction Computer Graphics - Class 4

  2. Interactive input devices • Locator • specifies coordinate positions • examples: thumbwheels, tablet, mouse, trackball, joystick, touch panel • Stroke • specifies a sequence of coordinate positions • example: tablets Computer Graphics - Class 4

  3. Interactive input devices (cont.) • Pick • selects picture components • example: light pen • Valuator • specifies scalar values • example: dial Computer Graphics - Class 4

  4. Interactive input devices (cont.) • String • specifies text input • example: keyboard • Choice • selects menu options • examples: keyboard, mouse buttons Computer Graphics - Class 4

  5. Event driven devices • CPU must wait on the device before it can do anything • Examples: • keyboard • mouse Computer Graphics - Class 4

  6. 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) Computer Graphics - Class 4

  7. 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 Computer Graphics - Class 4

  8. 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 Computer Graphics - Class 4

  9. 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 Computer Graphics - Class 4

  10. 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 Computer Graphics - Class 4

  11. 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 Computer Graphics - Class 4

  12. 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); Computer Graphics - Class 4

  13. 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 Computer Graphics - Class 4

  14. 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) Computer Graphics - Class 4

  15. 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) Computer Graphics - Class 4

  16. 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 Computer Graphics - Class 4

  17. Example program • Program picksquare.cpp demonstrates the complete technique for picking Computer Graphics - Class 4

More Related