PDA

View Full Version : Moving an Object



ToddAtWSU
06-13-2006, 04:00 PM
I am trying to move the object inside my Qt QGLWidget. I want to be able to click on the screen anywhere inside the widget, move the mouse from one spot to another, and the object to move over exactly that amount. So if I click on the image at 1/4 * width and move the cursor to 2/4 * width, I want what appeared at 1/4*width to now appear at 3/4*width and everything else to move properly. This should result in part of the image now moving off the right side of the screen if it is wide enough.

I know how to capture my screen positions for where my mouse starts and moves to and finally stops. I am having problems trying to get the object to move as fast or slow as I move the mouse. I thought if I calculated the amount it moved over, say 100 pixels from left to right when the widget is say 700 pixels wide. So it moved 1/7 of the screen over to the right. I thought if I then said, my glOrtho() goes from -7 to 7 that I could just change my ortho to -5 to 9. Is this a correct assumption as to what would happen?

I am changing the ortho for zooming in on this object so I want to keep the things similar and would prefer to manually change the ortho for translations instead of calling glTranslate. Also, I need to always know the min and max values of my ortho, so it is easier for me to keep track of these if I always calculate them.

Does anyone have any idea of how to get my objects to move correctly so they keep up with the mouse? Thanks!

ToddAtWSU
06-14-2006, 09:56 AM
I figured out my problem. It was just a lot of math manipulation that was required but now it is working perfectly. Thanks again!

jide
06-14-2006, 02:53 PM
Thanks who ? :confused: