Results 1 to 4 of 4

Thread: Finding location on a polygon?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2006
    Posts
    23

    Finding location on a polygon?

    What I need to do is to find the location on a polygon where I click with the mouse. Is this possible with openGL commands? What I need is the location in texture space (S and T).

    I'm fairly certain I can do this manually by finding where a ray created via the projection matrix intercepts with the selected polygon. However, this seems like something that would be commonly needed and so there is probably an existing solution somewhere. I can't find it though. Can someone point the way?

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

    Re: Finding location on a polygon?

    What do you mean by "location in the texture space"? If you need the texture coordinates for selected polygon, you must find them manually by inspecting your model. OpenGL does not store information about polygons, they just get rendered. You should probably look into selection and feedback mode of GL, I never use them so I can't tell you the details. Hovewer, your solution by raytracing seems most fast and stable to me.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2006
    Posts
    23

    Re: Finding location on a polygon?

    OK. That's what I figured. I just didn't want to do a lot of work only to find out later that there was a gluGetInterceptCoord command. Thanks.

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Finding location on a polygon?

    Actually the simplest method is to map your object with a special texture which encodes the uv-space in the color, well, or use a fragment shader writing that directly and readback the single pixel where you clicked with the mouse.
    If you have multiple independent objects to click, encode their ID in another output component.
    Then decode the color and you get your ID and uv-coords in modelspace without any complicated 3D math and exactly how the hardware mapped it.
    That's how some 3D paint tools do it.

    Be careful with the image's color resolution, FSAA and other color changing features. Rendering the data directly into a framebuffer object with floating point data would make sense to overcome pixelownership and color conversion issues.

Similar Threads

  1. finding if polygon can be seen by light?
    By Andy Gilbert in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 04-28-2010, 05:21 PM
  2. Finding location of a Polygon
    By Random89 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-21-2009, 11:41 AM
  3. Finding the area of a polygon
    By cutting_crew in forum OpenGL: General
    Replies: 3
    Last Post: 08-29-2008, 07:59 AM
  4. Finding a polygon out of several points
    By Azdo in forum OpenGL: General
    Replies: 2
    Last Post: 06-21-2005, 05:37 AM
  5. Finding a light's location relative to an object
    By tbc++ in forum OpenGL: General
    Replies: 3
    Last Post: 05-28-2004, 02:20 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
  •  
Proudly hosted by Digital Ocean