Part of the Khronos Group

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Newbie
    Join Date
    May 2012

    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.

Posting Permissions

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