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.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

372<br />

Figure 9-24. Disregarded extra vertex() calls<br />

The last three modes I’ll discuss briefly are TRIANGLE_STRIP, TRIANGLE_FAN, <strong>and</strong><br />

QUAD_STRIP. These modes build contiguous meshes of polygons, which is very useful in 3D.<br />

They work sort of similarly to the last two modes discussed, except that the multiple forms<br />

created are attached. Also, extra vertex() lines are not disregarded. However, a minimum<br />

number of vertex() comm<strong>and</strong>s need to be issued—three for TRIANGLE_STRIP <strong>and</strong><br />

TRIANGLE_FAN, <strong>and</strong> four for QUAD_STRIP—before any shapes are rendered. Here’s an<br />

example using TRIANGLE_STRIP mode (see Figure 9-25):<br />

// TRIANGLE_STRIP Mode<br />

size(400, 400);<br />

smooth();<br />

int x = width/2;<br />

int y = height/2;<br />

int outerRad = 150;<br />

int innerRad = 200;<br />

float px = 0, py = 0, angle = 0;<br />

float pts = 36;<br />

float rot = 360.0/pts;<br />

beginShape(TRIANGLE_STRIP);<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!