Triangle Stripes ?

Have jReality programming problems or questions? Post them here.
Post Reply
skfcz
Posts: 4
Joined: Sat 3. May 2008, 22:04

Triangle Stripes ?

Post by skfcz » Thu 8. May 2008, 21:42

Hello,

as far as I understand, the IndexedFaceSetFactory is used to create
Triangle Fans. Is it also possible to create geometry from triangle stripes ?

E.g. When useing the Cube example with the following faceIndices

int[][] faceIndices = new int[][]{
{0, 1, 5, 4, 7, 3, 2, 1}
};

I could only close half off the cube. Given I need to enter the following
points how is this done with the IndexedFaceSetFactory ?

0---1---2---3
| \ | \ | \ |
4--5----6---7

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Post by steffen » Fri 9. May 2008, 18:33

as far as I understand, the IndexedFaceSetFactory is used to create
Triangle Fans. Is it also possible to create geometry from triangle stripes ?
An IndexedFaceSetFactory is used to create an IndexedFaceSet, which has faces with arbitrary number of vertices. Each face is given by a list of vertex indices, in the cube example each face is a quad for each side. There is no special TriangleFan/TriangleStrip geometry in jReality, but you can just use triangles in the face indices list.

With your face indices you create one polygon with 7 of the 8 vertices (vertex 6 is missing), and the polygon is somehow triangulated, usually by the graphics card.

You need to create an int[][] containing only triangles, i. e.

int[][] faceIndices = new int[][]{
{0, 1, 5},
{1, 5, 4},
{5, 4, 7},
...
};

skfcz
Posts: 4
Joined: Sat 3. May 2008, 22:04

Strips

Post by skfcz » Fri 9. May 2008, 22:15

Hello Steffen,

thanks for the answer. So in the end there is no performance bonus whether I provide single triangle indicees or a complete strip ?

Bye, Carsten

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Post by steffen » Sat 10. May 2008, 08:48

Currently no. But it would be possible to add a Geometry Attribute to the IndexedFaceSet in case the face indices represent triangle stripes. Maybe Charles (who wrote the jogl backend) would add some extra code to speed up such triangle stripes (should be fairly simple), but I guess this only works for smooth shaded stuff.

The right way to implement this would be to write a TriangleStripFactory (which extends AbstractIndexedFaceSetFactory) which allows setting GL-style triangle strip indices, converts them to standard face indices and sets the corresponding Geometry Attribute for the IndexedFaceSet.

Please let us know if you currently need this performance optimization, I think it is only significant for large meshes.

Post Reply