toxiclibs TriangleMesh problem
in
Contributed Library Questions
•
1 year ago
Hi guys,
was hoping someone might be able to help me out with a toxiclibs related problem. I have a TriangleMesh that I'm building around points but it seems to be doing something a bit strange....when I instruct the mesh to build it doesn't do it immediately as with most examples I have seen. Instead it grows slowly and slows the sketch down considerable. I also have problems with it running out of memory after a while.
Is this something to do with how I have it set up? I would really appreciate someone having a look for me. I have posted part of the sketch containing the mesh below in case anyone can spot any glaring errors.
There is a video of an early experiment on my vimeo page which shows what I mean when I describe the mesh as 'growing' (vimeo.com/33283368).
Thanks,
Phill
- Mesh threadMesh;
- ToxiclibsSupport gfx;
- void setup() {
- gfx = new ToxiclibsSupport(this);
- threadMesh = new Mesh(15, 100);
- }
- void draw() {
- threadMesh.drawMesh(meshPartList);
- }
- class Mesh extends TriangleMesh {
- /*------------------------------------------------------------------
- *** CLASS VARIABLES ***
- ------------------------------------------------------------------*/
- float density = 1;
- int meshDens = 300;
- ArrayList meshPartList;
- Vec3D SCALE = new Vec3D(bBox.x, bBox.y, bBox.z).scale(2);
- float isoThreshold;
- float brushRadius = 20;
- int brushSize;
- VolumetricSpace volume;
- VolumetricBrush brush;
- IsoSurface surface;
- /*------------------------------------------------------------------
- *** CLASS CONSTRUCTOR ***
- ------------------------------------------------------------------*/
- Mesh(int brushSize_, float isoThreshold_) {
- brushSize = brushSize_;
- isoThreshold = isoThreshold_;
- volume = new VolumetricSpaceArray(SCALE, meshDens, meshDens, meshDens);
- brush = new RoundBrush(volume, brushRadius);
- surface = new ArrayIsoSurface(volume);
- }
- /*------------------------------------------------------------------
- *** CLASS FUNCTIONS ***
- ------------------------------------------------------------------*/
- void drawMesh(ArrayList meshPartList_) {
- meshPartList = meshPartList_;
- if (drawMesh) {
- for (int i = 0; i < meshPartList.size(); i++) {
- brush.setSize(brushSize);
- Particle newPart = (Particle) meshPartList.get(i);
- brush.drawAtAbsolutePos(new Vec3D(newPart.pos.x, newPart.pos.y, newPart.pos.z), density);
- }
- volume.closeSides();
- surface.reset();
- surface.computeSurfaceMesh(this, isoThreshold);
- }
- if (isWireframe) {
- stroke(255);
- strokeWeight(1);
- noFill();
- }
- else {
- lightSpecular(230, 230, 230);
- directionalLight(255, 255, 255, 1, 1, -1);
- shininess(1.0);
- noStroke();
- fill(200);
- }
- gfx.mesh(this);
- }
- }
1