Results 1 to 10 of 14

Thread: Ray and convex polygon intersection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    It's just for the modelling program mainly. All models are converted to triangles when it comes to games, for shaders and consistency. But while editing models, it is often times more effortless to deal with less faces. For example when editing a cube, i only need to deal with 6 faces instead of 12. Easier to do texturemapping, smoothing, extrude and so on.

  2. #2
    1 other optimization that i'm adding, is approximating the face normal better. It is possible that polygon is not entirely flat. (See attached image) I will be using the method on right. These indices can be count like:
    Code:
    p0 = 0
    p1 = 1+Count div 5
    p2 = Count-1-Count div 5
    I figured that 5 vertex polygon is smallest one to benefit from this change. It is possible that 3 periodic vertices are in line formation too, and in that case, the left side method (0, 1, 2) would make a really bad normal approximation.
    Attached Images Attached Images

  3. #3
    why not do this:
    p0 = 0;
    p1 = Count div 3;
    p2 = Count * 2 div 3;
    this will give you an even spread of plane base points across the entire polygon.
    btw in your example this will give you exactly the same points as you have on the right picture.

  4. #4
    You're really good at math, and thanks again It wasn't straightforward to come up with pattern that cover all polygon sizes, including triangles.

    The function works fine with triangles still, and it's now in use in the editor too. I hope the (0, 1, 2) vertices weren't necessary somehow for your projection formula, would guess no. Regards to projection, what did it actually do? It transforms vertices to plane of face normal's space? (that sounded weird) It's cool idea, and i noticed immediately how few calculations it's doing. Definitely much much faster than if dealing with normal way like 3D ray-triangle. Kind of genious.

  5. #5
    yes that's pretty much how it works. all the vertices of the polygon and the intersection point are on the same plane, so project them and work with 2d instead of 3d.

Bookmarks

Posting Permissions

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