Tuesday, 30 September 2014

Code That Creates
For the new project I have decided to have my output at 3D specifically 3D printing, I have been working with processing and the library toxiclibs in order to output my STL files.

First test
While coming to grips with how the toxiclibs library works I have created my first experiment

Code
import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.volume.*;
import toxi.processing.*;

ToxiclibsSupport gfx;
TriangleMesh mesh;
VolumetricSpace volume;

void setup() {
  size(1200,670,P3D);
  gfx = new ToxiclibsSupport(this);

  volume = new VolumetricSpaceArray(new Vec3D(200,200,200),100,100,100);
  
  IsoSurface surface = new ArrayIsoSurface(volume);
  mesh = new TriangleMesh();

VolumetricBrush brush = new RoundBrush( volume, 10 );
for ( int i=0; i < 50; i ++) {
  brush.setSize( i*1.2 + 6 );
  float x = sin( i * TWO_PI / 200 ) * 100;
  float y = tan( i * TWO_PI / 50 ) * 10;
  brush.drawAtAbsolutePos( new Vec3D(x,10*5*i,y), 400 );
}
for ( int i=4; i < 20; i+=4) {
  brush.setSize( i/1.5+4 );

  float x = cos( i * TWO_PI / 20 ) * (i*1.2+16);
  float y = sin( i * TWO_PI / 20 ) * (i*1.2+16);

  brush.drawAtAbsolutePos( new Vec3D(x,-25+i * 7,y), 1 );

 brush.setSize( i/2+2 );
  float x2 = cos( i * TWO_PI / 20  ) * (i*1.2+18);
  float y2 = sin( i * TWO_PI / 20  ) * (i*1.2+18);
  brush.drawAtAbsolutePos( new Vec3D(x2,-25+i * 7,y2), -1.4 );

  volume.closeSides();
  surface.reset();
  surface.computeSurfaceMesh(mesh, 0.5);  // Second parameter is surface iso value, aka: blobbiness.Try values between 0 - 1.

}

void draw() {
  background(255);
  lights();
  translate(width/2,height/2,0);
  rotateX(mouseY*0.01);
  rotateY(mouseX*0.01);
  scale(2);
  fill(100,100,100);
  noStroke();
  
  beginShape(TRIANGLES);
  gfx.mesh( mesh );
  endShape();
}

void keyPressed() {
  if (key=='p') {
    mesh.saveAsSTL( sketchPath( "toxic_output.stl" ));
  }
}

This created this



















And this is the real world contextualization of this model