What The Hell?
P5Sunflow is an easy way to make your Processing sketches look sexy as hell. Well, only three-dimensional ones, but whatever. Sunflow is a ray tracer written in Java. It's pretty awesome.
- Make sure to put
noStroke()at the beginning of your draw method. Ray Tracers have a problem with things that aren't surfaces. Lines will make it explode until I get my new shader code checked in. - Don't call
lights(). It'll turn off global illumination, and you'll have a world of pain to look forward to. - Sunflow is compiled to Java 1.5 (well, usually 1.6, but 1.5 in my zip. You're welcome). My code's compiled to 1.5. You simply cannot run this with Java 1.4. When you download the Processing bundle that comes with Java, you're running Java 1.4. Don't do that.
Documentation
If you feel like digging deep, here's some more information. You won't need any of this to get started, though.
Quick Start
That includes Sunflow. If you'd just like this library, it lives here (25k). It's probably easier just to grab the zip above.
Extract the zip to your Processing library folder, then start a new sketch. Let's go with the following little example.
void setup() {
size(350, 200, P3D);
noLoop();
}
void draw() {
background(255);
int numSpheres = 4;
float yStep = width/4;
float y = 40;
for(int i=0; i<numSpheres; i++) {
pushMatrix();
translate(y, height/2);
fill( i*(255/numSpheres), random(100, 200), random(0, 100) );
sphere(40);
popMatrix();
y += yStep;
}
}
You should get something like this:

Now, we'll add the p5sunflow library to our sketch by going to Sketch > Import Library > p5sunflow. If you don't see it on the list, make sure what you unzipped looks like the rest of the folders wherever.
Now change your size method to the following:
size(350, 200, "hipstersinc.P5Sunflow");
If you're lucky, the IDE is going to start spitting out a lot of text like Rendering [52%], then you'll get something like:

Awesome. That's it. Shoot an email if you run in to problems.
