1) First off, changing the ellipses to spheres requires a little bit of porting -- this was a 2D app to begin with. Most obviously, replace calls to ellipse with calls to sphere. The ellipse command takes location parameters, but sphere doesn't, so you'll need to use the translate command prior to calling it. Additionally, you'll need to push/pop the matrix to save your place. So:
Code:
ellipse((int)((x+dx*length.getVal())-length.g... blah blah
becomes
Code:
pushMatrix();
translate(x+dx*length.getVal(),y+dy*length.getVal(),z+dz*length.getVal());
sphere(20);
popMatrix();
You'll want to drop the sphere detail so you don't melt your machine.
Also, all the tree points need to carry z coords too, and the branching code needs to spawn off into the 3rd dimension so that the tree isn't smooshed.
You'll also need to turn off transparency on the leaves or use some depth sorting to prevent overlap issues.
2) Regarding limiting the tree depth, just keep a global variable for the depth and increment on every beat. When the depth gets above a set level, reset the tree and depth.
Code:
if (beat.isSnare()) {
if (depth < 4){
trunk.branch();
swide*=1.1;
depth++;
}
else{
trunk = new Point(this, 0,-1,0,20,75,2);
trunk.branch();
depth = 0;
swide = 1.1;
}
}
As a side note, I've modded the camera code to point at the trunk -- it's a little bit easier to control.
Code:
cam = new SGCamera(this,width/2,350,500,width/2,350,0);
I don't have the ID3 lib, so I clipped those parts .. sorry. Hope this helps.
video here http://www.vimeo.com/431611
code here http://www.screamyguy.net/tree/tree_v3.zip