Results 1 to 4 of 4

Thread: polygons to triangles

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Location
    Spain
    Posts
    24

    polygons to triangles

    this might be a little offtopic:

    how can I convert a N-Vertex polygon to a triangle list?

    I tried to iterate the different vertices of te polygon, and generate triangles like this:

    Triangle Vertex0 - Polygon Vertex 0
    Triangle Vertex1 - Polygon Vertex N+1
    Triangle Vertex2 - Polygon Vertex N+2

    But a lot of times it just makes a mess, with a lot of garbage triangles, so I figure I have something missing.

    so, which is the correct algorythm?

    thanks in advance

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    The easiest thing to do is make a triangle fan.
    triangle 0 vert 0 = polygon vert 0
    traingle 0 vert 1 = polygon vert 1
    triangle 0 vert 2 = polygon vert 2
    triangle 1 vert 0 = polygon vert 0
    triangle 1 vert 1 = polygon vert 2
    triangle 1 vert 2 = polygon vert 3
    triangle 2 vert 0 = polygon vert 0
    triangle 2 vert 1 = polygon vert 3
    triangle 2 vert 2 = polygon vert 4
    ...

    -Andy

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Location
    Spain
    Posts
    24
    Quote Originally Posted by alorino
    The easiest thing to do is make a triangle fan.
    triangle 0 vert 0 = polygon vert 0
    traingle 0 vert 1 = polygon vert 1
    triangle 0 vert 2 = polygon vert 2
    triangle 1 vert 0 = polygon vert 0
    triangle 1 vert 1 = polygon vert 2
    triangle 1 vert 2 = polygon vert 3
    triangle 2 vert 0 = polygon vert 0
    triangle 2 vert 1 = polygon vert 3
    triangle 2 vert 2 = polygon vert 4
    ...

    -Andy
    this is exactly what I'm doing...

    I'm trying to convert polygons to triangles, in collada documents exported with the 3dsmax plugin... it is possible that the 3dsmax plugin exports polygons incorrectly? (still experimental...)

    thanks in advance

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    are you taking into account the input elements correctly?

    be careful to use the right offsets, and remember that the number of inputs is not neccessarily the highest offset since multiple inputs can share the same offset/index.

    -Andy

Posting Permissions

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