//created=01 Jun 08
//description=Fractal scene rendering
//title=Fractal Scene
//titlebar=Fractal Scene Rendering
//publish=true
//tags=vrml baking
 
import SGCamera.*;
import Raytracing.*;
import Tuple.*;
 
SGCamera cam;
Raytracer tracer;
 
float sc = .2;
float off = -25.4;
float off2 = -19.2;
float off3 = 3.4;
 
float lx = -635;
float ly = -480;
float lz = 85;
 
float switchOver = 220;
 
void setup(){
 
size(550,400,P3D);
 
cam = new SGCamera(this,10,10,0,0,0,0, SGCamera.ORBIT, SGCamera.DOLLY);
//we aren't going to do any intersection tests, so don't bother to build a tree
tracer = new Raytracer(this, new ListAccelerator());
frameRate(30);
tracer.openFile("paintyBot4.mra",cam);
cam.lookAt(0,0,0);
 
}
 
public void draw(){
cam.lookAt(lx,ly,lz);
background(64);
cam.feed();
scale(100);
tracer.draw();
for (int i =0; i < 5; i++){
scale(sc);
translate(off,off2,off3);
tracer.draw();
}
 
 
if (cam.rho <= switchOver){
cam.rho = 1000;
cam.validate();
}
if (cam.rho > 1000){
cam.rho = switchOver;
cam.validate();
}
 
 
}
 
 
void keyPressed(){
if (key == 'a'){
cam.rho /= 1.1f;
cam.validate();
}
else if (key == 'z'){
cam.rho *= 1.1f;
cam.validate();
}
 
//registration by trial and error follows
/*
if (key == 's'){
off += .2;
}
else if (key == 'x'){
off -=.2;
}
if (key == 'd'){
off2 += .2;
}
else if (key == 'c'){
off2 -=.2;
}
if (key == 'f'){
off3 += .2;
}
else if (key == 'v'){
off3 -=.2;
}
*/
/*
if (key == 's'){
lx += 1;
}
else if (key == 'x'){
lx -=1;
}
if (key == 'd'){
ly += 1;
}
else if (key == 'c'){
ly -=1;
}
if (key == 'f'){
lz += 1;
}
else if (key == 'v'){
lz -=1;
}
 
if (key == 'g'){
switchOver += 10f;
}
else if (key == 'b'){
switchOver -= 10f;
}
*/
 
// println("scale:" + sc + " off:" + off + " off2:" + off2 + " off3:" + off3);
// println("off:" + lx + " off2:" + ly + " off3:" + lz + "so" + switchOver);
}