Export 3D scene with more than one object

Hello,

I checked out very very many examples of exporting 3D meshes from Processing (for instance with the nervous system library). None of them exported more than one shape at once, and when I tried to create an OBJ file of a scene with 2 spheres, I always ended up with only one sphere in the OBJ file, no matter what I tried. So without much code and everything, I just wanted to make sure if that's even possible? Or does a sketch be one solid shape so that one can export and 3D print it?

Thanks a lot in advance,

Sissi

Answers

  • Can you write some example?

  • edited June 2015

    Hey there, Sorry I didn't reply for a bit.

    Here's the code, when you try it in processing, it shows the entire flower, but when I export it, the OBJ file contains only the first piece of it?

    import nervoussystem.obj.*;
    boolean record = false;
    
    void setup(){
      size(900,700,P3D);
      //cam = new PeasyCam(this,0,0,0,10);
    }
    
    void draw(){
      if (record) {
        beginRecord("nervoussystem.obj.OBJExport", "trians.obj");
      }  
      translate(width/2,height/2);
      stroke(50,50,100); fill(100,100,200);
      for(float i=0; i<1; i+=0.05){
        petal(1.,0.,0.,100.,PI/i, 1-i);}
    
      if (record) {
        endRecord();
        record = false;
        println("done"); 
      }
    }
    
     void petal(float p, float x, float y, float l, float angle, float dir) {
      pushStyle(); pushMatrix(); 
      stroke(100,0,200); fill(200,0,200);
      strokeWeight(l / 20);
      float aa = dir * PI/4; 
    
      float endX = x + cos(angle + aa) * l;
      float endY = y + sin(angle + aa) * l;
    
      float ca = PI/5; 
      float cp = 0.35 * dist (x, y, endX, endY); 
      float cox = x + cos (angle + aa + ca) * cp;
      float coy = y + sin (angle + aa + ca) * cp;
    
      float ctx = x + cos (angle + aa - ca) * cp;
      float cty = y + sin (angle + aa - ca) * cp;
    
      beginShape();
      curveVertex (ctx, cty, 0);
      curveVertex (x, y, 0);
      curveVertex (cox, coy, 10);
      curveVertex (endX, endY, 0);
      curveVertex (endX, endY, 0);
      curveVertex (ctx, cty, 0);
      curveVertex (x, y, 0);
      curveVertex (cox, coy, 10);
      endShape(CLOSE);
      line (x, y, 0, endX, endY, 0);
      popStyle(); popMatrix();
    }
    
    void keyPressed() {
      record = true;
    }
    
Sign In or Register to comment.