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.

vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);<br />

}<br />

vertices2[j].x = cos(radians(latheAngle))*vertices[j].x;<br />

vertices2[j].y = sin(radians(latheAngle))*vertices[j].x;<br />

vertices2[j].z = vertices[j].z;<br />

// optional helix offset<br />

if (isHelix){<br />

vertices[j].z+=helixOffset;<br />

}<br />

vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);<br />

}<br />

// create extra rotation for helix<br />

if (isHelix){<br />

latheAngle+=720.0/segments;<br />

}<br />

else {<br />

latheAngle+=360.0/segments;<br />

}<br />

endShape();<br />

}<br />

}<br />

/*<br />

left/right arrow keys control ellipse detail<br />

up/down arrow keys control segment detail.<br />

'a','s' keys control lathe radius<br />

'z','x' keys control ellipse radius<br />

'w' key toggles between wireframe <strong>and</strong> solid<br />

'h' key toggles between toroid <strong>and</strong> helix<br />

*/<br />

void keyPressed(){<br />

if(key == CODED) {<br />

// pts<br />

if (keyCode == UP) {<br />

if (pts3){<br />

pts--;<br />

}<br />

}<br />

// extrusion length<br />

if (keyCode == LEFT) {<br />

if (segments>3){<br />

segments--;<br />

}<br />

}<br />

3D<br />

665<br />

13

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

Saved successfully!

Ooh no, something went wrong!