我有一个我想要绘制为实心区域的点列表。 我可以将这些点绘制为LineStripArray(见图)。 但是当我尝试将这些点绘制为IndexedTriangleArray / IndexedQuadArray时,我会得到一个奇怪的形状。我也尝试过使用GeometryInfo和Stripifier但没有成功。
使用GeometryInfo的代码:
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geometryInfo.setCoordinates(points3f);
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
Stripifier st = new Stripifier();
st.stripify(geometryInfo);
Shape3D shape = new Shape3D();
shape.setAppearance(app);
shape.setGeometry(geometryInfo.getGeometryArray());
区域解决方案(加上新问题):
Appearance app = new Appearance();
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
app.setPolygonAttributes(pa);
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(points3f);
int[] stripCountArray = { points3f.length };
int[] countourCountArray = {stripCountArray.length};
geometryInfo.setContourCounts( countourCountArray );
geometryInfo.setStripCounts( stripCountArray );
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
Shape3D shape = new Shape3D();
shape.setAppearance(app);
shape.setGeometry(geometryInfo.getGeometryArray());
形状也有深度。但我不能只是复制数组添加Z-index并再次合并它们(不会工作)。一个可能的解决方案是分别绘制每个面,但我认为这将是非常低效的。
有人可以帮我解决这个问题吗?