Computer Graphics

Download Report

Transcript Computer Graphics

Computer Graphics
Chapter 2
Input Devices
1
Input Devices
 Logical Input Devices
Categorized based on functional
characteristics.
Each device transmits a particular kind of
data.
The different types of data are called input
primitives.
 Physical Input Devices
Categorized based on the physical machine.
RM
[2]-2
Logical Input Devices
 Locator Devices
Input Primitive: Coordinate position (x,y)
Examples: Mouse, Keyboard (CursorPosition Keys), Tablet(Digitizer), Trackballs,
Lightpens.
Applications: Interactive drawing and editing,
Graph digitizing.
RM
[2]-3
Digitizer
RM
[2]-4
Joystick and Trackball
RM
[2]-5
Logical Input Devices
 String Devices
Input Primitive: A string of characters
Example: Keyboard
Applications: Text input
RM
[2]-6
Logical Input Devices
 Valuator
Input primitive: Scalar
between 0 and 1).
values
(typically
Examples: Control Dials, Sensing devices,
Joysticks
Applications: Input of graphics parameters,
Graphics representation of analog values,
Process simulation, Games.
RM
[2]-7
Logical Input Devices
 Choice
Input primitive:
options.
A selection from a list of
Examples: Mouse, Keyboard (Function
Keys), Touch Panel etc
Applications: Interactive menu selection,
Program control.
RM
[2]-8
Logical Input Devices
 Pick
Input primitive: Selection of a part of the
screen.
Examples: Mouse, Cursor Keys, Tablet.
Applications: Interactive editing and
positioning.
RM
[2]-9
Physical Input Devices
 Keyboard (input functions: String, Choice,
Locator).
 Mouse (input functions: Locator, Pick,
Choice).
 Joystick (input functions: Locator, Valuator).
 Knob (Valuator).
 Tablet (Locator, Pick).
RM
[2]-10
3D Interaction Devices (Recent
additions)
These devices are used in advanced rendering
methods
and virtual reality systems for providing
These devices are used in advanced rendering methods and virtual reality
systems for providing information about three dimensional positions and
information
about three dimensional positions and
motion.Few examples are
motion.Few
1.
DATA GLOVESexamples are
2.
1.3.
2
RM
SPACE BALLS
DATA GLOVES
SPACE BALLS
IMAGING SENSORS
[2]-11
Space Ball, Data Glove
RM
[2]-12
Event Driven Programming
Mouse clicked.
Mouse dragged.
A key is pressed.
The window is resized.
The window is moved.
Event
Register.
Define.
Call-back
Functions
Event Queue
RM
[2]-13
Mouse Interaction
 Mouse Event
Event that occurs when the mouse button is
pressed or released.
 Mouse Motion Event
Event that occurs when the mouse is moved
while one of the buttons is pressed.
RM
[2]-14
Mouse Event
 Contains the following information:
Button: The mouse button that is pressed –
left, middle, right.
State: The state of the button – up, down.
Position: The position of the mouse when
the event occurs (x, y).
RM
[2]-15
Mouse Event (OpenGL)
Registering with Mouse Event:
glutMouseFunc(myMouse);
Call-back function:
void myMouse(int button, int state, int x, int y)
Values for button: GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON
GLUT_RIGHT_BUTTON
Values for state:
GLUT_UP,
GLUT_DOWN
x, y: Screen coordinates of mouse position (origin at top-left corner).
RM
[2]-16
Mouse Motion Event
 Contains the following information:
Position: The current position of the mouse
as the mouse is being dragged holding one
of the buttons pressed. The events are
continuously generated as the mouse button
is pressed and dragged.
RM
[2]-17
Mouse Motion Event (OpenGL)
Registering with Mouse Motion Event:
glutMotionFunc(myMovedMouse);
Call-back function:
void myMovedMouse(int x, int y)
x, y: Screen coordinates of mouse position (origin at top-left corner).
RM
[2]-18
Keyboard Event
 Contains the following information:
key: The ASCII value of the key pressed.
Position: The current position of the mouse
when the key is pressed.
RM
[2]-19
Keyboard Event (OpenGL)
Registering with Keyboard Event:
glutKeyboardFunc(myKeyboard);
Call-back function:
void myKeyboard(unsigned int key, int x, int y)
Values of key:
ASCII value for normal keys
GLUT_KEY_LEFT, GLUT_KEY_RIGHT..(Arrow keys)
x, y: Screen coordinates of mouse position (origin at top-left corner).
RM
[2]-20
Window Events
 The Window Redraw Event occurs
whenever the window needs to be redrawn.
This happens when the window is first
opened and when the window is exposed by
moving another window off of it.
 The Window Reshape Event is generated
when the window is resized with the mouse.
RM
[2]-21
Window Events (OpenGL)
Registering with Window Redraw Event:
glutDisplayFunc(myDisplay);
Registering with Window Reshape Event:
glutReshapeFunc(myReshape);
RM
[2]-22