hi!
i hope someone can help me. this problem is worrying me for more than a week. i know there are a lot of posts about this subject and i really tried to find the answer to my problem but i didn’t.
my program shows an object (data from an stl file). now i want to allow the user to zoom the object near and far (mousewheel). ok, this is no problem!
but i would be prefer this: the user clicks somewhere on the object and then the whole object moves in this way: the clicked point is moved to the center of the window. the zooming starts.
i don’t know why this doesn’t work, i will explain you how i’m trying to solve this.
(picking and selection works, i controlled this with another program)
Please correct me if my way is wrong:
1.) i render the object with the selection mode.
2.) i get the minimum z value from the selectBuf and want to use this z for the glUnProject(), but this is a real big number. i tried to scale it but i don’t know how. the value (in GLdouble) has to be between 0.0 ans 1.0, i know. (if i scale with 100000000, i get something like 0.4)
or how can i scale it in another way?
or:
2.) i use glReadPixel() with my mouse coordinates to get the z value, it is always 1.0. also if in the selectBuf the value is different. using glUnProject() with 1.0 returns acceptable values, but the translation doesn’t move the point to the center.
or:
2.) if use z=0.0, then i get very small values, almost no translation can be seen.
perhaps someone of you can help me,
thank you so much,
tanja