Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Help with selection/picking (mouse based)???

  1. #1
    Member Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    39

    Help with selection/picking (mouse based)???

    hi...
    I am currently working on a drawing application using openGL and C#..........this might sound silly but having a nightmare trying to grasp concept of selection/picking...
    please explain the concept pushing data to name stack and manipulating the data all examples that I have seen just print the contents of the name stack...how this data is actually used

    please suggest links/tutorials (better if in C#)
    thanks

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Help with selection/picking (mouse based)???

    Ali, you are better of by implementing a simple picking system based on bounding boxes or oclusion queries. Teh GL picking is a deprecated, not-accelerated system with many shortcomings.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: Help with selection/picking (mouse based)???

    Search Google, first 10 lines are pretty close to what you need.

    http://www.google.com/search?hl=en&q...ng&btnG=Search

    Don't worry about name stack, you don't have to use it. It can only help you identify complicated hierarchical objects.
    For simple scenes, call to glLoadName() is enough.

    @Zengar Where did you read that GL picking is deprecated?

  4. #4
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Help with selection/picking (mouse based)???

    I meant "deprecated" Just like the feedback mode, evaluators, convolution and some other things. AFAIK no consumer hardware driver accelerates it. It is clumsy, it is slow and apparently noone cares about it. This is enough reason to consider a feature deprecated.

  5. #5
    Member Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    39

    Re: Help with selection/picking (mouse based)???

    thanks for the replies..and yes i know google exists
    my application will be drawing 2D(later 3D) objects...the user will be able to select any edge of a polygon and move it around/modify it..
    I am still confused with the idea of drawing/redrawing in selection mode because in most cases my scene will be rendered before the user will select any part of it ...for example i draw a polygon using GL_LINE_LOOP I select an edge how will it be redrawn...

  6. #6
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: Help with selection/picking (mouse based)???

    You have to store all the information about your scene (DataModel) in your last render-to-screen invocation.
    When user picks (mouse click event) somewhere.
    You have to enable selection mode and run your scene update function again. In this case no real rendering is done. It is pretty fast.
    You can reuse the same rendering function in 2 places.
    for real render and for picking.
    But beware (I'm not sure about C#) but the picking functions that is called from Event dispatcher must be done in the same thread that rendered the scene. Another threads don't have the OpenGL context current.
    Another way for you is to use stencil buffer. If the number of your objects is less then 255 then you can store something like ObjectID in stencil, then during picking you can read very small region from this buffer (like 4x4 pixels) and check the object id.

    Another way:
    If you have only lines, then you can do it in your own code like Zengar suggested. Just implement algo that intersects line with small box under mouse cursor. Call it for all lines and you get all picked candidates.

    @Zengar I don't thing it is deprecated. There must some accelerated way to get back the transformed vertices. See
    brand new extension GL_NV_transform_feedback. The selection inside driver can use this ext to be fully accelerated. If you use vertex programs you cannot compute bounding box (yes you can but you have to emulate the vertex program that is not so easy.

  7. #7
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Help with selection/picking (mouse based)???

    @mfort: A nvidia employee confirmed that this feature is fully software. Mainly because it has nothing to do in general 3D API. It could be accelerated using occlusion queries, but as I said noone cares about it

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2007
    Posts
    16

    Re: Help with selection/picking (mouse based)???

    For selectin objects in 3D you can use gluUnproject() function (check it's documentation for details).

  9. #9
    Member Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    39

    Re: Help with selection/picking (mouse based)???

    hey
    i am drawing a polygon using GL_LINE_LOOP...
    but face a strange problem...when i click around the drawing no hits are recorded however hits are recorded in an another area of the screen
    ..i have checked the code 3-4 times...values that are being passed to gluPickMatrix() are valid and hits should be recorded..
    I have seen various examples for guidance and cannot figure out what could be the problem?

    thanks

  10. #10
    Member Contributor
    Join Date
    Apr 2004
    Location
    Bangalore India
    Posts
    65

    Re: Help with selection/picking (mouse based)???

    when i click around the drawing no hits are recorded however hits are recorded in an another area of the screen
    I guess can two reasons

    1)your screen point input requires some offset adjustment and may not be relatively correct.
    Thats why you may be getting hits in different areas.

    2)During selection are you setting back both modelview and projection back correctly similar to normal rendering mode...?

    glMatrixMode (GL_PROJECTION);
    glPushMatrix ();
    glLoadIdentity ();
    gluPickMatrix ((GLdouble) pt->x,(GLdouble)(viewport[3] - pt->y),2.0, 2.0, viewport);
    // set the camera settings properly now.

    Good Luck,
    kumar.k
    Regards

    K.Kumar

Page 1 of 2 12 LastLast

Similar Threads

  1. Help with GLM based mouse picking
    By imported_paul_g_griffiths in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-31-2017, 05:43 AM
  2. Drag object based on mouse selection
    By gwartney in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-15-2016, 10:15 PM
  3. help with selection ad picking??
    By Ali in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 06-20-2007, 09:33 PM
  4. help - selection and picking
    By sadhu in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-02-2002, 12:02 AM
  5. Is using selection buffer for selection or picking slow?
    By mohsin in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-11-2001, 03:56 AM

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