0
votes

I am looking for an efficient algorithm for mesh (set of triangles) and cone (given by origin, direction and angle from that direction) intersection. More precisely I want to find intersection point which is closest to the cone's origin. For now all what I can think about is to intersect a mesh with several rays from the cone origin and get the closest point. (Of course some spatial structure will be constructed for mesh to reject unnecessary intersections)

Also I found the following algo with brief description: "Cone to mesh intersection is computed on the GPU by drawing the cone geometry with the mesh and reading the minimum depth value marking the intersection point". Unfortunately it's implementation isn't obvious for me.

So can anyone suggest something more efficient than I have or explain in more details how it can be done on GPU using OpenGL?

1
This may be of helpLorah Attkins

1 Answers

0
votes

on GPU I would do it like this:

  1. set view

    • to cones origin
    • directing outwards
    • covering the bigest circle slice
    • for infinite cone use max Z value of mesh vertexes in view coordinate system
  2. clear buffers

  3. draw mesh

    • but in fragment shader draw only pixels intersecting cone
    • |fragment.xyz-screen_middle|=tan(cone_ang/2)*fragment.z
  4. read z-buffer

    • read fragments and from valid (filled) select the closest one to cones origin

[notes]

  • if your gfx engine can handle also output values from your fragment shader
  • then you can skip bullet 4 and do the min distance search inside bullet 3 instead of rendering ...
  • that will speed up the process considerably (need just single xyz vector)