Results 1 to 3 of 3

Thread: Moving an Object

  1. #1
    Senior Member Regular Contributor
    Join Date
    Sep 2005
    Location
    Dayton
    Posts
    148

    Moving an Object

    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!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2005
    Location
    Dayton
    Posts
    148

    Re: Moving an Object

    I figured out my problem. It was just a lot of math manipulation that was required but now it is working perfectly. Thanks again!

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Moving an Object

    Thanks who ?

Similar Threads

  1. moving object in circle across of other object
    By openGLWriter in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-19-2015, 09:18 AM
  2. Moving an Object
    By sumeet in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-18-2008, 05:07 AM
  3. moving around and going near an object...
    By Turbo555 in forum OpenGL: General
    Replies: 4
    Last Post: 03-27-2008, 11:46 AM
  4. Moving an Object in 2D
    By Sklar in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-23-2004, 02:08 PM
  5. "moving" around object
    By gemini in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2003, 07:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean