Results 1 to 11 of 11

Thread: How to Implement Hittest with QGLWidget ???

  1. #1
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to Implement Hittest with QGLWidget ???

    Hi,

    I am trying to implement an OpenGL(QGLWidget) widget and need to implement hittest for the features that need to be included.

    I am little confused where to start ... I have the QGLWidget and need help with implementation of hittest as I am not very familiar with it.

    I would really appreciate any help related to this or any guidance on how to start it ??

    Regards,
    Raj

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Implement Hittest with QGLWidget ???

    I would start with reimplementing mousePressEvent As for the hittest itself, take a look at NeHe lessons, as far as I remember it's described there how to project the cursor into 3D space.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Implement Hittest with QGLWidget ???

    Heheheh ... Thanks Wysota.
    I actually need a head start on hittest logic.
    I was hoping if Qt by default provided something similar.

    Regards,
    Raj

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Implement Hittest with QGLWidget ???

    Qt3D might (seems that QGLCamera might be what you're after), the basic flavour of Qt doesn't as it doesn't have any control (or awareness) over your projection matrix.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    rajji_saini (7th September 2010)

  6. #5
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Implement Hittest with QGLWidget ???

    OK. How about, if I was using a regular QGraphicsView and Scene to add items.
    Is there something available for that ??

    Thanks & Regards,
    Raj

  7. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to Implement Hittest with QGLWidget ???

    QGraphicsView/Scene/Item is strictly 2 dimensional, but it does offer collision detection if that's what you're looking for.

    There has been some complaining here about performance of this algorithm, however.

  8. #7
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Implement Hittest with QGLWidget ???

    Yup, thats exactly what I am looking for ... I do not care about the 3D.
    It will be great if you could please provide me some info related to the collision detection and its pros & cons so that I will have a better idea.


    Regards,
    Raj

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Implement Hittest with QGLWidget ???

    Quote Originally Posted by rajji_saini View Post
    Yup, thats exactly what I am looking for ... I do not care about the 3D.
    It will be great if you could please provide me some info related to the collision detection and its pros & cons so that I will have a better idea.
    What is it exactly that you want to do? Why were you asking about QGLWidget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Implement Hittest with QGLWidget ???

    Here is what I am trying ....

    MyGraphicsView::MyGraphicsView(QWidget *parent):QGraphicsView(parent)
    {
    myScene = new QGraphicsScene(this);
    setScene(myScene);
    setViewport(new GLWidget(this));

    }
    Here I am setting my custom QGLWidget as as viewport of my QGraphicsView.
    So this is where I need help with.

    Regards,
    Raj

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Implement Hittest with QGLWidget ???

    I mean what is your ultimate goal of doing all that? The GL viewport doesn't change anything if you are using Graphics View, it just gives you hardware acceleration without changing the API layer. So collision detection is still done by Graphics View and not QGLWidget. For collision detection in the scene see the family of QGraphicsScene::items() and QGraphicsScene::collidingItems() methods.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Implement Hittest with QGLWidget ???

    Yes, I am using QGLWidget on QGraphicsView for hardware acceleration.
    I am trying to create a map control with very high refresh rate something similar to TomTom device in a moving vehicle(i.e a fast moving map). But it supports interaction with items on the map.

    So my confusion was that once I set the QGLWidget as viewport how is it going to change the behavior ... May be I didnt put my question properly in the beginning
    As you are suggested that Collision detection is still done by QGraphicsView. I will go ahead and try it out.

    Thanks for your help.
    Regards,
    Raj

Similar Threads

  1. How does Qt implement layers?
    By FinderCheng in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 13:12
  2. Trying to implement QMainWindow...
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 23rd October 2008, 19:12
  3. how to implement this widget
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2007, 11:10
  4. What's the best way to implement a MainWindow
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2007, 17:46
  5. how to implement it ?
    By qtopiahooo in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2006, 17:01

Tags for this Thread

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.