Problem export Obj with Toxi

edited March 2014 in Library Questions

Hi, I have some troubles with the Toxi exporter OBJ. It works fine most of the time but with VolumetricSpaceArray, IsoSurface the Obj file mess with vertex after few frames ( invalid vertex index). (the two first has no problem). Does someone has an idea?

ie, sorry for my bad English

Tagged:

Answers

  • edited March 2014

    Just to give an example. Here is a script from the toxiclib, VolumetricCup. I just had a obj exporter for the frame 1 and 12, the frame 1 export well and the 12 has a mess with the vertex index.

    import toxi.geom.*;
    import toxi.geom.mesh.*;
    import toxi.volume.*;
    import toxi.math.waves.*;
    import toxi.processing.*;
    import peasy.*;
    import processing.opengl.*;
    
    int DIMX=96;
    int DIMY=96;
    int DIMZ=128;
    
    float ISO_THRESHOLD = 0.1;
    float NS=0.03;
    Vec3D SCALE=new Vec3D(256,256,384);
    
    VolumetricSpace volume;
    VolumetricBrush brush;
    IsoSurface surface;
    TriangleMesh mesh;
    
    AbstractWave brushSize;
    
    boolean isWireframe=false;
    boolean doSave=false;
    
    float currScale=1;
    float density=0.5;
    float spin=8;
    float currZ=0;
    float Z_STEP=0.005;
    
    ToxiclibsSupport gfx;
    PeasyCam cam;
    
    void setup() {
      size(1024,768,OPENGL);
    //  hint(ENABLE_OPENGL_4X_SMOOTH);
      cam = new PeasyCam (this, 900);
      gfx=new ToxiclibsSupport(this);
      strokeWeight(0.5);
      volume=new VolumetricSpaceArray(SCALE,DIMX,DIMY,DIMZ);
      brush=new RoundBrush(volume,SCALE.x/2);
      brushSize=new SineWave(-HALF_PI,2*TWO_PI*Z_STEP,SCALE.x*0.03,SCALE.x*0.06);
      surface=new ArrayIsoSurface(volume);
      mesh=new TriangleMesh();
    }
    
    void draw() {
      brush.setSize(brushSize.update());
      float offsetZ=-SCALE.z+currZ*SCALE.z*2.6666;
      float currRadius=SCALE.x*0.4*sin(currZ*PI);
    
    
    
      for(float t=0; t<TWO_PI; t+=TWO_PI) {
        Vec3D pos = new Vec3D(currRadius*cos(t+currZ*spin),currRadius*sin(t+currZ*spin),offsetZ);
        brush.drawAtAbsolutePos(pos,density);
      }
      currZ+=Z_STEP;
      volume.closeSides();
      surface.reset();
      surface.computeSurfaceMesh(mesh,ISO_THRESHOLD);
    
    
      if ((frameCount==1)||(frameCount==12)) {
        mesh.saveAsOBJ(sketchPath("cup_"+frameCount+".obj"));
      }
      background(128);
      translate(width/2,height/2,0);
      lightSpecular(230,230,230);
      directionalLight(255,255,255,1,1,-1);
      shininess(1.0);
    
      scale(currScale);
      noStroke();
      gfx.mesh(mesh);
    }
    
  • edited March 2014

    It might be worth trying

    noLoop(); mesh.save..... loop();

    to stop vertices updating whilst saving?

  • Thank you Monkstone, but it does not work. The method to implement the line meshSave works fine with others way to handle TriangleMesh. It just doesn't work with VolumetricSpace and IsoSurface. I still have the same window that pop up when I try to import it. Invalid Vertex index.

  • edited March 2014

    t

Sign In or Register to comment.