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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

quadBG[2] = color(30, 30, 175, 150);<br />

quadBG[3] = color(175, 175, 30, 150);<br />

quadBG[4] = color(175, 30, 175, 150);<br />

quadBG[5] = color(175, 87, 30, 150);<br />

c1 = new Cube(200, 200, 200);<br />

c2 = new Cube(100, 100, 100);<br />

}<br />

void draw(){<br />

background(100);<br />

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

rotateX(frameCount*PI/50);<br />

rotateY(frameCount*PI/60);<br />

// create larger colored cube<br />

noStroke();<br />

c1.create(quadBG);<br />

// create inner black cube<br />

fill(0, 200);<br />

stroke(255);<br />

c2.create();<br />

}<br />

// Updated custom Cube class<br />

class Cube{<br />

Point3D[] vertices = new Point3D[24];<br />

float w, h, d;<br />

// Constructors<br />

// default constructor<br />

Cube(){<br />

}<br />

// constructor 2<br />

Cube(float w, float h, float d){<br />

this.w = w;<br />

this.h = h;<br />

this.d = d;<br />

// cube composed of 6 quads<br />

//front<br />

vertices[0] = new Point3D(-w/2,-h/2,d/2);<br />

vertices[1] = new Point3D(w/2,-h/2,d/2);<br />

vertices[2] = new Point3D(w/2,h/2,d/2);<br />

vertices[3] = new Point3D(-w/2,h/2,d/2);<br />

//left<br />

vertices[4] = new Point3D(-w/2,-h/2,d/2);<br />

vertices[5] = new Point3D(-w/2,-h/2,-d/2);<br />

vertices[6] = new Point3D(-w/2,h/2,-d/2);<br />

vertices[7] = new Point3D(-w/2,h/2,d/2);<br />

3D<br />

629<br />

13

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

Saved successfully!

Ooh no, something went wrong!