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
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.as far as I understand, the IndexedFaceSetFactory is used to create
Triangle Fans. Is it also possible to create geometry from triangle stripes ?
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},
...
};
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.
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.