View Full Version : Mouse Control in 3D
jjcheng
06-16-2005, 07:15 AM
I have a 3D object displayed in a window, and I want to be able to click on it, and rotate it. I am not sure where to start.
Originally, I had a button system to rotate the object, but I would rather have it be more interactive. Could someone help me with this? Or point me in the right direction?
t3jem
06-16-2005, 09:06 AM
You might want to try nehe's picking tutorial, I can't remember witch one it is so you'll have to look, but here's the address http://nehe.gamedev.net/
Aeluned
06-16-2005, 10:01 AM
this isn't an OpenGL question:
when the user left clicks store the x,y mouse position;
on each mouse move message - find the difference of the last stored x,y position from the current one - map this to some rotation value (perhaps 2*delta x for rotations about the y axis as an example).
set the last stored x,y value to the current one;
if the left button is down, rotate the object (by whatever number of degrees or radians are obtained by your mapping).
I hope this simple overview is somewhat clear.
t3jem
06-16-2005, 12:46 PM
Well, actually Aeluned (not to be rude or anything) if you use glut then to use the mouse you use glutMouseFunc(); which is an opengl function.
Aeluned
06-16-2005, 12:57 PM
yes, but the entire problem boils down to how to get a value for degrees to a glRotate call using the mouse. The operations to achieve that include nothing more than Windows API calls: namely an WM_LBUTTON_DOWN, WM_MOUSE_MOVE and WM_LBUTTON_UP.
even using glutMouseFunc(), the problem boils down to the method I outlined before.
It's not a big deal that it's not an OpenGL question really, I was just making a statement.
redarrow
06-17-2005, 02:14 AM
Originally posted by Terminatore3:
Well, actually Aeluned (not to be rude or anything) if you use glut then to use the mouse you use glutMouseFunc(); which is an opengl function. No it's not, glut is not opengl it's just a utility toolkit to make implementing it easier, opengl is a graphics library not a game development library.
The Mouse/keyboard/joystick etc. functions in glut have nothing to do with opengl.
Just my 2 cents...
jjcheng
06-17-2005, 10:22 AM
Thanks for your help! I will see if I can make this work.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.