CSE 411 Computer Graphics Lecture 5 Interactive Input

  • Slides: 35
Download presentation
CSE 411 Computer Graphics Lecture #5 Interactive Input Methods Prepared & Presented by Asst.

CSE 411 Computer Graphics Lecture #5 Interactive Input Methods Prepared & Presented by Asst. Prof. Dr. Samsun M. BAŞARICI

Objectives HB Ch. 20 Classification of Input Devices Input Functions Interactive Picture-Construction Techniques GLUT

Objectives HB Ch. 20 Classification of Input Devices Input Functions Interactive Picture-Construction Techniques GLUT Mouse Functions GLUT Keyboard Functions GLUT Menu Functions Interactive Input Methods 2

Logical Classification of Input Devices Locator Devices q Interactive selection of a coordinate point

Logical Classification of Input Devices Locator Devices q Interactive selection of a coordinate point Mice Joysticks Trackballs Spaceballs Etc. Interactive Input Methods 3

Logical Classification of Input Devices (cont. ) Stroke Devices q Input a sequence of

Logical Classification of Input Devices (cont. ) Stroke Devices q Input a sequence of coordinate positions Mice (continuous movement) Graphic tablets Etc. Interactive Input Methods 4

Logical Classification of Input Devices (cont. ) String Devices q (Character) String input Keyboards

Logical Classification of Input Devices (cont. ) String Devices q (Character) String input Keyboards Interactive Input Methods 5

Logical Classification of Input Devices (cont. ) Valuator Devices q Input a scalar value

Logical Classification of Input Devices (cont. ) Valuator Devices q Input a scalar value Faders Trimmers Potentiometers Etc. Interactive Input Methods 6

Logical Classification of Input Devices (cont. ) Choice Devices q Selecting menu options Mice

Logical Classification of Input Devices (cont. ) Choice Devices q Selecting menu options Mice Keyboards Etc. Interactive Input Methods 7

Logical Classification of Input Devices (cont. ) Pick Devices q Selecting objects Mice Keyboards

Logical Classification of Input Devices (cont. ) Pick Devices q Selecting objects Mice Keyboards Joysticks Etc. Interactive Input Methods 8

Logical Classification of Input Devices (cont. ) Pick Devices q Example: Selecting one object

Logical Classification of Input Devices (cont. ) Pick Devices q Example: Selecting one object d 2 d 1 (x, y) Interactive Input Methods 9

Logical Classification of Input Devices (cont. ) Pick Devices q Example: Selecting multiple objects

Logical Classification of Input Devices (cont. ) Pick Devices q Example: Selecting multiple objects (pick window) Bounding Rectangle ymax ymin xmin Interactive Input Methods xmax 10

Input Devices Locator Devices: q Stroke Devices: q Specify scalar value Choice Devices: q

Input Devices Locator Devices: q Stroke Devices: q Specify scalar value Choice Devices: q Specify text input Valuator Devices: q Specify set of coordinate positions String Devices: q Specify one coordinate position Select menu options Pick Devices: q Select component(s) of a picture Interactive Input Methods 11

Input Functions for Graphical Data Input Modes: q Request mode: q Sample mode: q

Input Functions for Graphical Data Input Modes: q Request mode: q Sample mode: q Data entry initiated by application program Suspend process, wait for input data Input device and program operate alternately Input device and program operate independent Event mode: Data entry initiated by input device (event initiated) Data stored in queue Input device and program operate alternately Interactive Input Methods 12

Interactive Techniques Positioning Position Cursor and Press Button Interactive Input Methods Object Displayed at

Interactive Techniques Positioning Position Cursor and Press Button Interactive Input Methods Object Displayed at Cursor Position 13

Interactive Techniques Dragging Interactive Input Methods 14

Interactive Techniques Dragging Interactive Input Methods 14

Interactive Techniques Constraints: q Procedure for altering input coordinate values Press Button to Select

Interactive Techniques Constraints: q Procedure for altering input coordinate values Press Button to Select First Endpoint Press button to Select First Endpoint Interactive Input Methods Press Button to Select Second Endpoint 15

Interactive Techniques Grids q A kind of constraint Press Button to Select First Endpoint

Interactive Techniques Grids q A kind of constraint Press Button to Select First Endpoint Interactive Input Methods Press Button to Select Second Endpoint 16

Interactive Techniques Rubber-Bands Interactive Input Methods 17

Interactive Techniques Rubber-Bands Interactive Input Methods 17

Interactive Techniques Rubber-Bands Press button to start Arc stretches out from start. Pressing stop

Interactive Techniques Rubber-Bands Press button to start Arc stretches out from start. Pressing stop button & position as cursor moves ends process Rectangle stretches out as cursor moves Interactive Input Methods Press button to stop 18

Interactive Techniques Gravity Field Interactive Input Methods 19

Interactive Techniques Gravity Field Interactive Input Methods 19

GLUT Input Device Functions Device input is handled by GLUT and not by Open.

GLUT Input Device Functions Device input is handled by GLUT and not by Open. GL core library Why? Interactive Input Methods 20

GLUT Mouse Functions glut. Mouse. Func (mouse. Fcn); void mouse. Fcn(GLint button, GLint action,

GLUT Mouse Functions glut. Mouse. Func (mouse. Fcn); void mouse. Fcn(GLint button, GLint action, GLint xmouse, GLint ymouse) q button q action q GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON GLUT_DOWN , GLUT_UP xmouse, ymouse position relative to window when the button is pressed or released Interactive Input Methods 21

Example Programs ch 20 Mouse. Plot. Point. c ch 20 Mouse. Plot. Polyline. c

Example Programs ch 20 Mouse. Plot. Point. c ch 20 Mouse. Plot. Polyline. c Interactive Input Methods 22

GLUT Mouse Functions (cont. ) glut. Motion. Func(fnc. Do. Something); q q void fcn.

GLUT Mouse Functions (cont. ) glut. Motion. Func(fnc. Do. Something); q q void fcn. Do. Something(GLint x. Mouse, GLint y. Mouse) Invokes when mouse moves with a button pressed glut. Passive. Motion. Func(fnc. Do. Something. Else); q q void fcn. Do. Something. Else(GLint x. Mouse, GLint y. Mouse) Invokes when mouse moves without pressing a button Interactive Input Methods 23

GLUT Keyboard Functions glut. Keyboard. Func (key. Fcn); q void key. Fcn(GLubyte key, GLint

GLUT Keyboard Functions glut. Keyboard. Func (key. Fcn); q void key. Fcn(GLubyte key, GLint x. Mouse, GLint y. Mouse) key is assigned a character value or the corresponding ASCII code Example q ch 20 Keyboard. Curve. Drawing. c Interactive Input Methods 24

GLUT Keyboard Functions (cont. ) glut. Special. Func (special. Key. Fcn); q void special.

GLUT Keyboard Functions (cont. ) glut. Special. Func (special. Key. Fcn); q void special. Key. Fcn(GLint special. Key, GLint x. Mouse, GLint y. Mouse) special. Key can be GLUT_KEY_F 1…GLUT_KEY_F 12, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_PAGE_DOWN, GLUT_KEY_HOME Example q ch 20 Mouse. Keyboard. Squares. c Interactive Input Methods 25

GLUT Menu Functions (cont. ) Creating a GLUT Menu q q q glut. Create.

GLUT Menu Functions (cont. ) Creating a GLUT Menu q q q glut. Create. Menu (menu. Fcn); void menu. Fcn(GLint menu. Item. Number) glut. Add. Menu. Entry(char. String, menu. Item. Number); q glut. Create. Menu (menu. Fcn); glut. Add. Menu. Entry(“First Menu Item”, 1); glut. Add. Menu. Entry(“Second Menu Item”, 2); glut. Attach. Menu (button); Example q ch 20 GLUTMenu. c Interactive Input Methods 26

GLUT Menu Functions (cont. ) Creating and Managing Multiple GLUT Menus menu. ID =

GLUT Menu Functions (cont. ) Creating and Managing Multiple GLUT Menus menu. ID = glut. Create. Menu (menu. Fcn); q glut. Set. Menu (menu. ID); q glut. Destroy. Menu (menu. ID); q current. Menu. ID = glut. Get. Menu (); q Interactive Input Methods 27

GLUT Menu Functions (cont. ) Creating GLUT Submenus submenu. ID = glut. Create. Menu

GLUT Menu Functions (cont. ) Creating GLUT Submenus submenu. ID = glut. Create. Menu (sub. Menu. Fcn); glut. Add. Menu. Entry(“First Submenu Item”, 1); . . glut. Create. Menu (menu. Fcn); glut. Add. Menu. Entry(“First Menu Item”, 1); . . glut. Add. Sub. Menu (“Submenu Option”, submenu. ID); Example q ch 20 GLUTSubmenu. c Interactive Input Methods 28

Open. GL Input Functions Interactive Input Methods 29

Open. GL Input Functions Interactive Input Methods 29

Open. GL Input Functions (cont. ) Interactive Input Methods 30

Open. GL Input Functions (cont. ) Interactive Input Methods 30

Open. GL Input Functions (cont. ) Interactive Input Methods 31

Open. GL Input Functions (cont. ) Interactive Input Methods 31

Open. GL Input Functions (cont. ) Interactive Input Methods 32

Open. GL Input Functions (cont. ) Interactive Input Methods 32

Open. GL Input Functions (cont. ) Interactive Input Methods 33

Open. GL Input Functions (cont. ) Interactive Input Methods 33

Next Lecture 2 D Geometric Transformations Interactive Input Methods 34

Next Lecture 2 D Geometric Transformations Interactive Input Methods 34

References Donald Hearn, M. Pauline Baker, Warren R. Carithers, “Computer Graphics with Open. GL,

References Donald Hearn, M. Pauline Baker, Warren R. Carithers, “Computer Graphics with Open. GL, 4 th Edition”; Pearson, 2011 Sumanta Guha, “Computer Graphics Through Open. GL: From Theory to Experiments”, CRC Press, 2010 Edward Angel, “Interactive Computer Graphics. A Top-Down Approach Using Open. GL”, Addison. Wesley, 2005 Interactive Input Methods 35