Intersection with arbitrary solid

Post: #1
I think this is a simple problem, but I am not sure. I have arbitary solids, and need to find out if and where a ray intsects them. I don't think I can do it mathmatically because I am using an API to import these solids. But there must be something in Opengl that says where something intersects.
To sum up, if I give a x and y location, I need the z locations where the solid is bounded.
Quote this message in a reply
Posts: 184
Joined: 2004.07
Post: #2
It is possible to do this with OpenGL- you can use the selection buffer. You basically set your viewport to look down the ray you want (basically you will use an ortho projection with a very small width and height) and then you make a call to glRenderMode(GL_SELECT); Now, you draw your object. You then get the result in your selection buffer, and you can find the point closest to the viewer, which will be your intersection. They explain how to do this in the Red Book, though I can try to help you if you're having trouble with it.

However, I would recommend you not do this in OpenGL, and instead use one of the very many collision libraries out there. For example, OPCODE is the one used by ODE (ode has a decent interface to doing collision itself as well.) Why? You get considerably more accuracy and flexibility, as you can do collisions between two solids, a solid and a ray, plane, point, etc. what have you.

The OpenGL route however may be faster for rays, depending on how complex your object is- I'd have to know exactly what you're doing.
Quote this message in a reply
Posts: 304
Joined: 2002.04
Post: #3
Are you looking to do selection and picking?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Need ray-sphere intersection code MattDiamond 23 21,311 Aug 31, 2009 02:28 PM
Last Post: Gengar003
  Rendering a reflection about an arbitrary plane TomorrowPlusX 3 6,014 Jan 14, 2008 07:51 AM
Last Post: TomorrowPlusX
  Calculating tangent coords for arbitrary poly meshes TomorrowPlusX 8 7,999 Jul 9, 2007 03:10 PM
Last Post: Hog
  2d Polygon Intersection bizimCity 6 8,787 Aug 31, 2006 05:29 PM
Last Post: reubert
  Math question: deriving rotation by plane intersection TomorrowPlusX 6 5,628 Jan 24, 2006 07:28 AM
Last Post: TomorrowPlusX