primitiveType = GeometryInfo.TRIANGLE_STRIP_ARRAY;
} else {
primitiveType = GeometryInfo.POLYGON_ARRAY;
}
GeometryInfo geometryInfo = new GeometryInfo(primitiveType);
geometryInfo.setCoordinates(this.geometryVertices);
geometryInfo.setCoordinateIndices(getIndices(this.geometryVertexOffset));
if (this.geometryNormals != null) {
geometryInfo.setNormals(this.geometryNormals);
geometryInfo.setNormalIndices(getIndices(this.geometryNormalOffset));
}
if (this.geometryTextureCoordinates != null) {
Integer stride = this.sourceAccessorStrides.get(this.geometryTextureCoordinates);
// Support only UV texture coordinates
float [] textureCoordinates;
if (stride > 2) {
textureCoordinates = new float [this.geometryTextureCoordinates.length / stride * 2];
for (int i = 0, j = 0; j < this.geometryTextureCoordinates.length; j += stride) {
textureCoordinates [i++] = this.geometryTextureCoordinates [j];
textureCoordinates [i++] = this.geometryTextureCoordinates [j + 1];
}
} else {
textureCoordinates = this.geometryTextureCoordinates;
}
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, textureCoordinates);
geometryInfo.setTextureCoordinateIndices(0, getIndices(this.geometryTextureCoordinatesOffset));
}
if ("trifans".equals(name)
|| "tristrips".equals(name)) {
int [] stripCounts = new int [this.facesAndLinesPrimitives.size()];
for (int i = 0; i < stripCounts.length; i++) {
stripCounts [i] = this.facesAndLinesPrimitives.get(i).length / this.inputCount;
}
geometryInfo.setStripCounts(stripCounts);
} else if ("polylist".equals(name)) {
geometryInfo.setStripCounts(this.vcount);
} else if ("polygons".equals(name)) {
int [] stripCounts = new int [this.facesAndLinesPrimitives.size() + this.polygonsPrimitives.size()
+ this.polygonsHoles.size()];
int [] contourCounts = new int [this.facesAndLinesPrimitives.size() + this.polygonsPrimitives.size()];
int stripIndex = 0;
int countourIndex = 0;
for (int i = 0; i < this.facesAndLinesPrimitives.size(); i++) {
stripCounts [stripIndex++] = this.facesAndLinesPrimitives.get(i).length / this.inputCount;
contourCounts [countourIndex++] = 1; // One polygon
}
for (int i = 0; i < this.polygonsPrimitives.size(); i++) {
stripCounts [stripIndex++] = this.polygonsPrimitives.get(i).length / this.inputCount;
List<int []> polygonHoles = this.polygonsHoles.get(i);
for (int j = 0; j < polygonHoles.size(); j++) {
stripCounts [stripIndex++] = polygonHoles.get(j).length / this.inputCount;
}
contourCounts [countourIndex++] = 1 + polygonHoles.size(); // One polygon + its holes count
}
geometryInfo.setStripCounts(stripCounts);
geometryInfo.setContourCounts(contourCounts);
}
if (this.geometryNormals == null) {
new NormalGenerator(Math.PI / 2).generateNormals(geometryInfo);
}
return geometryInfo.getGeometryArray(true, true, false);
}