PDA

View Full Version : How to drag object in opengl by mouse?



tgtt
02-14-2004, 12:39 AM
The position and direction of the object is changed at anytime.I want to drag the object by my mouse.

How to do this in opengl?


I'm sorry for so many question?this is the last http://www.opengl.org/discussion_boards/ubb/smile.gif
Thanks everybody here.

V-man
02-14-2004, 08:53 AM
dragging involves selection. So search on this forum for "picking".

For draging, I think you could first transform a point on the object to window space

gluProject(....., object.xyz);

then feed this into...
gluUnProject(mouse.x, mouse.y, object.z, ....);

to get back that point, and find the new translation for the object.

Dragging in ortho projection can be simpler though.

jwatte
02-14-2004, 01:20 PM
C'mon, this has nothing to do with Advanced OpenGL. This is a UI question, and possibly a question on whatever scene graph library you're using.