070925 | Code, Processing / Java
Tags: Code, export, library, pde, processing.org, rapid-prototyping, stereolithography, stl, unlekkerlib
Tags: Code, export, library, pde, processing.org, rapid-prototyping, stereolithography, stl, unlekkerlib
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();
}





now stupid me has a brandnew problem:(
java.lang.UnsupportedClassVersionError: unlekker/data/STL (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
Oops, I suspect I compiled the library for Java 1.5. I’ll fix it and post a new version.
great, thanks a lot for your efforts marius.
Same problem for me ! where found a new version for Java 1.6 ?
Bonjour Monsieur Watz,
The unlekkerLib has disappeared into a 404. What happened to it?
Hi Paul, I’m sorry the code was incorrect. You’ll find it here, I just posted a minor update as well.
Very nice an elegant example! Thanks!
Awesome Marius! Thank you!
i reall like your lib.
but it looks like this example (or stl import at all) does not work anymore in current processing (0155):
Exception in thread “Animation Thread” java.lang.NoSuchMethodError: processing.core.PGraphics3D.(IILprocessing/core/PApplet;)V
at unlekker.data.STL.(STL.java:69)
at STLBoxes.readSTL(STLBoxes.java:52)
at STLBoxes.draw(STLBoxes.java:38)
at processing.core.PApplet.handleDraw(PApplet.java:1395)
at processing.core.PApplet.run(PApplet.java:1300)
at java.lang.Thread.run(Unknown Source)
i tested the same sketch in 0148 and it works. do you know a solution or workaround?
thank you.
Thanks for letting me know, I just got the same error with 0155. I will look into it.