sure it was not intended to be used like this, but it works (only P3D, OPENGL is too sensible):
Code:
float fov;
float cameraZ;
void setup()
{
size(200, 200, P3D);
noFill();
fov = PI/3.0;
cameraZ = (height/2.0) / tan(PI * fov / 360.0);
}
PGraphics3 pg;
void draw()
{
pg = new PGraphics3( width, height, null );
pg.defaults();
pg.background(255);
pg.perspective( fov*rot, float(width)/float(height), cameraZ/10.0, cameraZ*10.0);
pg.translate(width/2, height/2, -300);
pg.rotateX(-PI*0.18*rot);
pg.rotateY(PI*0.333*rot);
pg.fill(122);
pg.box(100);
rot += 0.02;
rot %= TWO_PI;
pg.translate( 100,100,-100 );
pg.rotateZ( PI * 0.2 );
pg.rotateX( PI * 0.2 );
pg.fill( 255 );
pg.box( 100 );
pg.translate( 10, 10, 100 );
pg.fill( #FF0000 );
pg.box( 20 );
image( pg , 0,0 );
fill( 255 );
rect( bb,bb,20,20 );
rect( bb-40,bb,20,20 );
rect( bb,bb-40,20,20 );
bb += 3;
bb %= width;
}
float rot = 0.0;
int bb = 0;
F