Hello everyone,
I’m having a problem moving a 3D object on the screen. I would like the object to follow the mouse movements (the object’s center and the mouse’s cursor do not necessary have to be the same on the screen).
I know the object’s world coordinates and the mouse position. This should be done with gluProject and gluUnproject but so far I have been unsuccessfull.
Can someone help me/point me to an example?
Thanks in advance Hans.
Why do you need this UpProject?
If i understood you correctly, all is much simplier - you just have to map coordinates like following:
nx = (mx-winx/2.)/(winx/2.)*XP+x0,
where: winx - windows width
mx - mouse position
XP - X coordinate of right corner in GL coordinates on the depth of object.
x0 - starting coordinate, may be 0
nx - new coordinate
i calculated XP by experiments but it can be calculated accurately
Hi RandyU,
Well this was what I thought:
The mouse is moved by an amound (mx,my,0), I map this vector in world coordinates (with glUnProject) and translate the world by the mapped vector.
Is this what your formula is doing?
Greetings
Hans