For faster rendering it’s important to keep the shape in the GPU. I don’t remember right now if ToxicLibs was updated to do that. When I used it it was not the case, so I wrote some simple code to convert the mesh from ToxicLibs to PShape. PShape shapes are kept in the GPU.
Do you know how many vertices your shapes have? And what kind of GPU you use?
Here some incomplete Java code that may be useful as a starting point:
public static void toxicToPShape(final TriangleMesh m, final PShape shp) {
List<Face> triangles = m.getFaces();
shp.beginShape(PConstants.TRIANGLES);
shp.textureMode(PConstants.NORMAL);
for (final Face t : triangles) {
addFaceToPShape(shp, t.a, t.b, t.c);
}
shp.endShape();
shp.setSpecular(0xFFFFFFFF);
shp.setShininess(50); // * (float) Math.random()
}
public static void addFaceToPShape(PShape shp, Vec3D a, Vec3D b, Vec3D c,
Vec2D uva, Vec2D uvb, Vec2D uvc) {
shp.vertex(a.x, a.y, a.z, uva.x, uva.y);
shp.vertex(b.x, b.y, b.z, uvb.x, uvb.y);
shp.vertex(c.x, c.y, c.z, uvc.x, uvc.y);
}
public static void addFaceToPShape(PShape shp, Vec3D a, Vec3D b, Vec3D c) {
shp.vertex(a.x, a.y, a.z);
shp.vertex(b.x, b.y, b.z);
shp.vertex(c.x, c.y, c.z);
}
public static void setFaceInPShape(PShape shp, int index, Vec3D a, Vec3D b,
Vec3D c) {
shp.setVertex(index, a.x, a.y, a.z);
shp.setVertex(index + 1, b.x, b.y, b.z);
shp.setVertex(index + 2, c.x, c.y, c.z);
}
Maybe simpler would be to export your shapes from ToxicLibs and load them as PShape, if generating them on the fly is not important.