Tag:

Here is a simple example showing how to use unlekkerLib to output and input 3D geometry in STL format.

// STLBoxes.pde - demonstrates how to use unlekkerLib to
// import / export STL geometry data.
//
// Marius Watz - http://workshop.evolutionzone.com/

import unlekker.data.*;

STL stl;

public void setup() {
  size(400,400, P3D);
  frameRate(25);
  sphereDetail(12);
}

public void draw() {
  translate(width/2,height/2);

  if(frameCount==10) outputSTL();
  else if(frameCount==11) readSTL();
  if(frameCount<12) return;

  background(0);
  noStroke();
  lights();
  rotateY(radians(frameCount));
  rotateX(radians(frameCount*0.25f));
  fill(0,200,255, 128);
  stl.draw();

}

public void readSTL() {
  stl=new STL(this,"Boxes.stl");
  stl.normalize(400); // scale object
  stl.center(); // center it around world origin
}

public void outputSTL() {
  float rad;

  stl=(STL)beginRaw("unlekker.data.STL","Boxes.stl");
  for(int i=0; i<200; i++) {
    pushMatrix();
    translate(random(-200,200),0,-random(400));
    rotateX(((float)(int)random(6))*radians(30));
    rotateY(((float)(int)random(6))*radians(30));

    rad=random(5,25);
    if(random(100)>5) box(rad,random(50,200),rad);
    else sphere(rad);
    popMatrix();
  }
  endRaw();
}

8 Comments »

AHO RP 004 Object #1 - #3 [lo]

Rapid prototyping objects generated with Processing and output to STL using unlekkerLib.

I’ve just uploaded a new Processing library called unlekkerLib. It is a collection of tools and code snippets I use frequently, and which I’ve now just barely cleaned up enough for other people to use. Instead of releasing them piece by piece, I’ve decided to bundle them together in a package hierarchy.

The main reason I decided to release it now is the STL export code I’ve written for my rapid prototyping projects. Several people have asked for the code, so I wanted to get it out there for you to play with. Obviously, it works as well with Processing as it does with regular Java.

Caveat emptor:There’s not much documentation but I do provide the source code. This is v.0001 - the very first release, so it’s pretty basic. See below for an idea of what the library contains. Right now the most exciting new component is the unlekker.data.STL class, which supports export and import of STL stereolithography files for rapid prototyping. Have a look at the Javadoc for more details.

Updates will appear here: http://workshop.evolutionzone.com/unlekkerlib/.

Read the rest of this entry »

No Comments »