> From: tang <[EMAIL PROTECTED]>
>
>              Anyone know of the algorithm/calculation required to
> translate a trianglestrip array (generated by ObjLoad class) into a
> VRML IndexedFaceSet node? I am developing a program which needs a
> saving to VRML function but so far I couldn't find anything on this.


The mapping is fairly simple.

The coordinates from your TriangleStripArray become the Coordinates of the
IndexedFaceSet, the normals become the Normals, etc.

The coordIndex values for the IFS correspond to the triangles in the TSA,
keeping in mind that every other triangle in the TSA is wound backwards:

coordIndex [ 0 1 2 -1 # triangle 0
             1 3 2 -1 # triangle 1, note reverse order
             2 3 4 -1 # triangle 2, normal order
             3 5 4 -1 # triangle 3, reverse order
             ...
             n n+1 n+2 -1 # if n is even
             n n+2 n+1 -1 # if n is odd
             ]

A triangle strip of n points defines n-2 triangles.

Since the normals and colors (if present) have the same indexing as the coords,
you don't need to specify normalIndex, colorIndex, etc.  Leave the rest of the
fields at their default values and you should be OK.

Doug Gehringer
Sun Microsystems

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to