View Full Version : Mouse Control in 3D
06-16-2005, 08: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?
06-16-2005, 10: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/
06-16-2005, 11: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.
06-16-2005, 01: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.
06-16-2005, 01: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.
06-17-2005, 03: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...
06-17-2005, 11:22 AM
Thanks for your help! I will see if I can make this work.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.