mouse dragging

I’ve implemented selection - what I now need is to be able to drag and move objects around the scene - any ideas, examples ??

U want to pick an object and to move it in the 3D world?

U have many solutions, first u can say that when u click with the rigth button of u’r mouse, it will make translation of the object (along its axes). And when u click on the left button, u rotate it (around its axes too).

I’m not sure i understood u’r question but if it was it , ok…

Yes that’s it - I’ve got the whole scene rotating and zooming with code in onMouseMove - what about if I want to move individual objects in that scene?

[This message has been edited by fox (edited 11-03-2000).]

I suppose you have a method to render all of your objects ??

If you have two objects A and B, and if you want to move the A object in the scene.
You just have to add

gltranslatef(XDisplacement, YDisplacement, ZDisplacement);

You have to add this line just before drawing the object.

To change the viewpoint position and orientation, use glulookat (or something else) and to move an object (or rotate it), use gltranslatef() (or glrotatef) before drawing this object.

…so for my scene I have

glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glTranslated (0.0, 0.0, -25.0); //initial position of scene

glTranslated (1.0, 0.0, m_Zoom1);
glTranslated (0.0, 1.0, m_Zoom2);
glRotated (m_xRotate, 1.0, 0.0, 0.0);
glRotated (m_yRotate, 0.0, 1.0, 0.0);

where the zoom and rotate is controlled in the onmousemove - and I use left and right mouse buttons for each so do I use the same variables to control my objects