PDA

View Full Version : Moving object in 3D space



Alessandro_dup1
12-12-2011, 03:14 PM
I have developed a small opengl application that allows to pick an object in the viewport. I'd like to move such object in 3D space, dragging it around with the mouse.
In the first image (picked.jpg), I just picked the object at 0,0,-10; when I move it around, the object z-depth returned by glUnProject is going to the end of the far plane (see moved.jpg), while I'd like my object to keep the same z-depth.
Any idea how could I solve this?
Thanks

mobeen
12-12-2011, 10:38 PM
Check these two projects here:

Direct link: http://www.spacesimulator.net/wiki/images/SimplePicking.zip
Direct link: http://www.spacesimulator.net/wiki/images/SimplePickingSelectionBuffer.zip

which do something similar to what you are doing.

shuixian
12-13-2011, 05:03 AM
Thanks

Alessandro_dup1
12-13-2011, 09:33 AM
Thanks, I'm going to check those!