PDA

View Full Version : moving objects with mouse in 3D



yakovm
04-10-2010, 05:38 AM
I am rendering the model using
glMatrixMode(GL_MODELVIEW);
after detecting the click on object (select/pick) I want to move the object according to the moUse movement
I use gluUnProject to unproject the mouse coordinates
Do I get a result as coordinates in local system ?

Rosario Leonardi
04-11-2010, 07:39 AM
If you use gluUnProject with the camera model view matrix and the camera projection matrix you get the point in world coordinate.

If you use the model view matrix of the cameraMVM*objectMVM you get the point in local coordinate.

The unProject function only take your matrix and viewport and apply the inverse transformation.