04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

cube count-lower/raise to test P3D/OPENGL performance<br />

int limit = 600;<br />

//array for all cubes<br />

Cube[]cubes = new Cube[limit];<br />

void setup(){<br />

//try substituting P3D for OPENGL<br />

//argument to test performance<br />

size(800, 550, OPENGL);<br />

//instantiate cubes, passing in r<strong>and</strong>om vals for size <strong>and</strong> postion<br />

for (int i = 0; i< cubes.length; i++){<br />

cubes[i] = new Cube(int(r<strong>and</strong>om(-20, 20)), int(r<strong>and</strong>om(-20, 20)), ➥<br />

int(r<strong>and</strong>om(-20, 20)), int(r<strong>and</strong>om(-340, 340)), ➥<br />

int(r<strong>and</strong>om(-340, 340)), int(r<strong>and</strong>om(-340, 340)));<br />

}<br />

frameRate(30);<br />

}<br />

void draw(){<br />

background(0);<br />

fill(200);<br />

//set up some different colored lights<br />

pointLight(51, 102, 255, 65, 60, 100);<br />

pointLight(200, 40, 60, -65, -60, -150);<br />

//raise overall light in scene<br />

ambientLight(70, 70, 10);<br />

/*center geometry in display window.<br />

you can change 3rd argument ('0')<br />

to move block group closer(+)/further(-)*/<br />

translate(width/2, height/2, 150);<br />

//rotate around y <strong>and</strong> x axes<br />

rotateY(radians(ang));<br />

rotateX(radians(ang));<br />

//draw cubes<br />

for (int i = 0; i< cubes.length; i++){<br />

cubes[i].drawCube();<br />

}<br />

//used in rotate function calls above<br />

ang++;<br />

}<br />

THE PROCESSING ENVIRONMENT<br />

167<br />

5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!