Mouse events, Advanced camera control George Georgiev Telerik Corporation .
-
Upload
tyler-thornton -
Category
Documents
-
view
216 -
download
0
Transcript of Mouse events, Advanced camera control George Georgiev Telerik Corporation .
![Page 1: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/1.jpg)
OpenGL & GLUTMouse Interaction &
Camera ControlMouse events, Advanced camera control
George GeorgievTelerik Corporationwww.telerik.
com
![Page 2: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/2.jpg)
Table of Contents GLUT Mouse Interaction
Mouse up/down events
Passive motion
Active motion OpenGL Camera
Default transformation
“Manual” control
Custom camera class
2
![Page 3: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/3.jpg)
GLUT Mouse Interaction
Mouse event callbacks
![Page 4: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/4.jpg)
GLUT Mouse Interaction
4
GLUT provides mouse detection capabilities Advantages
Multi-platform
Similar to other GLUT routines
Easy to code
Disadvantages
Doesn’t receive device information
No scroll information
Unstable ‘leave’ and ‘enter’ events
![Page 5: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/5.jpg)
GLUT Mouse Interaction
5
Detecting mouse buttons Registering callback function
glutMouseFunc(void(*func)(int button, int state, int x, int y))
func – mouse button callback function
button – mouse button raising the event
state – type of event
x, y – cursor coordinates (from upper left corner)
![Page 6: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/6.jpg)
GLUT Mouse Interaction
6
Detecting mouse buttons (2) Callback parameter values
button
GLUT_LEFT_BUTTON
GLUT_MIDDLE_BUTTON
GLUT_RIGHT_BUTTON
state
GLUT_DOWN
GLUT_UP
![Page 7: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/7.jpg)
GLUT Mouse Interaction
7
Detecting mouse buttons (2) Callback parameter values
button
GLUT_LEFT_BUTTON
GLUT_MIDDLE_BUTTON
GLUT_RIGHT_BUTTON
state
GLUT_DOWN
GLUT_UP
![Page 8: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/8.jpg)
GLUT Mouse Interaction
8
Detecting movement Types
Passive
Mouse moves
No buttons pressed
Active
Mouse moves
One or more buttons pressed
![Page 9: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/9.jpg)
GLUT Mouse Interaction
9
Passive motion Registering callback function
glutPassiveMotionFunc(void(*func)(int x, int y))
func – mouse passive motion callback
x, y – cursor coordinates (from upper left corner)
![Page 10: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/10.jpg)
GLUT Mouse Interaction
10
Active motion Registering callback function
glutMotionFunc(void(*func)(int x, int y))
func – mouse active motion callback
x, y – cursor coordinates (from upper left corner)
![Page 11: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/11.jpg)
GLUT Mouse Interaction GLUT Mouse leave and entry routines Detect when cursor leaves and
enters window
Registering callback
glutEntryFunc(void(*func)(int state))
Func – callback handling cursor leaving and entering window
State – enter or leave event
GLUT_ENTERED
GLUT_LEFT
11
![Page 12: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/12.jpg)
GLUT Mouse Interaction Cursor-related routines
glutWarpPointer (int x, int y)
Sends cursor to specified coordinates
glutSetCursor (int cursor)
Sets the cursor image (style) for the window
Values:
GLUT_CURSOR_NONE, GLUT_CURSOR_INFO,
GLUT_CURSOR_DESTROY, etc…
Google for more (much, much more)12
![Page 13: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/13.jpg)
Mouse Interaction Object-oriented mouse handling
Custom mouse class
Current cursor position
Last cursor position and/or drag-begin position
Current mouse button states
Last mouse button states
Cursor style
Anything else you can think of13
![Page 14: Mouse events, Advanced camera control George Georgiev Telerik Corporation .](https://reader036.fdocuments.us/reader036/viewer/2022082613/5697bfea1a28abf838cb7945/html5/thumbnails/14.jpg)
Custom mouse classLive Demo