Results 1 to 3 of 3

Thread: picking in QGLWidget

  1. #1
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default picking in QGLWidget

    Hi!
    First of all i wish all of you a happy new year!
    And now to my problem. I'm a kind of 3d Desktop and use QGLWidget (OpenGL) and ode for realizing it. I did everything well, but now i ask me how to pick objects with the mouse.
    I call only these two transformations in paintGL:
    Qt Code:
    1. glTranslatef(0.0, 0.0, -80.0);
    2. glRotatef(90, 1.0, 0.0, 0.0);
    To copy to clipboard, switch view to plain text mode 
    The Z-Axis doesn't matter for me i only need the x/y coordinates of one object (or x/z because of the rotation).
    Now i tried following to translate the coordinates of the objects to normal paint coordinates, but somehow it doesn't work.......
    Qt Code:
    1. float *geoPos = (float*)dGeomGetPosition(objs[i].geom);
    2. QPoint bodyPos = QPoint((geoPos[2]+8)*80, (geoPos[0]+8)*80);
    3. QRegion bodyRegion(bodyPos.x(), bodyPos.y(), 80, 80);
    4. if(bodyRegion.contains(mousePos))
    5. qDebug("contains");
    To copy to clipboard, switch view to plain text mode 

    Can anyone help me and say how i translate the object coordinates into the same format as the mouse coordinates are?

  2. #2
    Join Date
    Sep 2007
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: picking in QGLWidget

    Hello and happy new year,

    I think you should take a look at the OpenGl picking mechanism (through the use of logig names for every entity that you want to be able to pick).

    Take a look at: http://gpwiki.org/index.php/OpenGL:Tutorials:Picking
    or google it!

  3. The following user says thank you to adonel for this useful post:

    kernel_panic (2nd January 2008)

  4. #3
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: picking in QGLWidget

    this helped me very much.
    thanks!

Similar Threads

  1. Transparent widgets on top of QGLWidget
    By tseval in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2007, 21:03
  2. Transparent QWidget on QGLWidget
    By showhand in forum Qt Programming
    Replies: 2
    Last Post: 27th November 2006, 01:00
  3. QGLWidget on another QGLWiget
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2006, 09:59
  4. Using QGLWidget paint engine to draw regular widgtes?
    By high_flyer in forum Qt Programming
    Replies: 11
    Last Post: 9th October 2006, 12:06
  5. QGLWidget updateGL()
    By Lele in forum Qt Programming
    Replies: 7
    Last Post: 30th May 2006, 15:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.