Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Ray Picking

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    14

    Ray Picking

    Hi guys, I know there's heaps of hits on picking on google but I've got some questions that I've been unable to find answers for so here it goes:

    I'm obviously interested in getting some picking happening in my application. I'm aware that ray tracing is the best method so that's the direction that I'm leaning and I more or less understand the pseudo code for ray tracing... up until the point of actually getting it to work with my display lists. What I mean by that is:

    1.) How do I determine which display list a triangle belongs to? The way I see it:

    Code :
    for(iterate through display lists)
    {
        perform a ray triangle intercept test
        if(hit occors)
        return(object index) //we found a hit
    }

    Given this pseudo code, I don't understand how this is any different to simply doing something along the lines of (I'm just trying to implement a button click detection):

    [CODE]for(iterate through display lists)
    {
    if(mouse click is < right most point of display list coord && mouse click > left most point of display list coordinate && mouse click < upper most point of display list coordinates && mouse click is > bottom most point of dsiplay list
    return(object index) //we found a hit
    }

    Obviously this isn't the most elegant solution but it will work but it will also require a lot of stuffing around in terms of doing #defines or writing a lot of switch case statements later on to do certain things if a certain button is clicked, so it becomes quite big and ugly.

    Can someone explain a way of doing box picking without having so much hard coding? Just trying to make a simply button interface.

    2.) How do I access a display list vertex? Say I want to do something along the lines of:

    vector ReturnListObjectCoordinates(GLuint ListObject)
    {
    return vector;
    }
    Last edited by Atomic_Sheep; 08-18-2013 at 11:15 PM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    I find your post to be a little confusing.

    To summarize: you want to do picking of GUI elements you somehow manage in your application and render with OpenGL and want to simulate classic event handling when a ray cast hits a GUI element, right? This is all 2D? Are GUI elements always perpendicular to the camera's direction? Are all elements rectangular and not rotated (i.e edges are parallel or perpendicular (depending on the axis) to the screen edges and do they coincide with the near-plane?

  3. #3
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    14
    Yes to all those qs, if you have some info on having all this work with keyboard inputs as well, that would be good. In other words techniques for re-using code in the parts of the program that take input from keystrokes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •