Hi Abe, many thanks for your help and guidance. Now it works and its impressive how using the PShape class helps to improve the frameRate. Processing didn’t recognized the Collection variable, even the import java.util.Collections;
but it works with the import java.util.List;
so using the codes that mentioned before, i used the List, and in order to use this, i have to modify Mesh3D with TriangleMesh, and convert the input data by casting.
Also, i was getting NullPointerException error in the shp.vertex(t.a.x, t.a.y, t.a.z, t.uvA.x, t.uvA.y);
line, so i deleted the arguments t.uvA.x, t.uvA.y
because i don’t know their function (i’m still curious about it).
PShape toxicToPShapeSmooth(final TriangleMesh m) {
m.computeVertexNormals();
// Collection<Face> triangles = m.getFaces();
List<Face> triangles = m.getFaces();
PShape shp;
shp = createShape();
shp.setStroke(false);
shp.beginShape(PConstants.TRIANGLES);
shp.textureMode(PConstants.NORMAL);
for (final Face t : triangles) {
shp.normal(t.a.normal.x, t.a.normal.y, t.a.normal.z);
shp.vertex(t.a.x, t.a.y, t.a.z);
shp.normal(t.b.normal.x, t.b.normal.y, t.b.normal.z);
shp.vertex(t.b.x, t.b.y, t.b.z);
shp.normal(t.c.normal.x, t.c.normal.y, t.c.normal.z);
shp.vertex(t.c.x, t.c.y, t.c.z);
}
shp.endShape();
shp.setSpecular(0xFFFFFFFF);
shp.setShininess(50);
return shp;
}
Thanks again!