//NESTING BSPACE
BSpace s1,s2,s3;
float angle;
void setup(){
size(200,200);
background(200);
smooth();
// Create three BSpace objects
s1 = new BSpace(this);
s2 = new BSpace(s1); // nest s2 enviornment into s1. // An alterantive is using the nestIn() command: s2.nestIn(s1);
s3 = new BSpace(s2); // nest s3 enviornment into s2.
s2.setAxis(20,20); // s2 Axis coordinate system is now relative to the s1 axis which is affected by the mouse.
s3.setAxis(20,20);
}
void loop(){
angle += 0.04;
s1.setAxis(mouseX,mouseY); // move the BSpace (and all nested BSpaces) to mouse cursor.
s1.rotateZ(angle);
s1.rect(0,0,20,20);
s2.rotateZ(angle);
s2.rect(0,0,20,20);
s3.rotateX(angle);
s3.rect(0,0,20,20);
}
|