

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cwwang.com &#187; Comp Form</title>
	<atom:link href="http://cwwang.com/category/comp-form/feed/" rel="self" type="application/rss+xml" />
	<link>http://cwwang.com</link>
	<description>Che-Wei Wang</description>
	<lastBuildDate>Sat, 06 Nov 2010 15:58:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Adobe Honorable Mention for Grass Type</title>
		<link>http://cwwang.com/2008/08/16/adobe-honorable-mention-for-grass-type/</link>
		<comments>http://cwwang.com/2008/08/16/adobe-honorable-mention-for-grass-type/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 04:05:57 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[2D Graphics]]></category>
		<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[Press]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=818</guid>
		<description><![CDATA[Grass Type received an honorable mention for the 2008 Adobe Design Achievement Awards. [ADAA pdf] Grass Type was built with Tim Stutts]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-2.png" title="grasspicture-2.png" rel="lightbox[818]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-2.thumbnail.png" alt="grasspicture-2.png" width="128" height="96" class="attachment wp-att-439 " /></a></p>
<p><a href="http://cwwang.com/grasstype/">Grass Type</a> received an honorable mention for the <a href="http://www.adaaentry.com/">2008 Adobe Design Achievement Awards</a>.  [<a href="http://cwwang.com/wordpress/wp-content/uploads/che-weiwangadaa_hmcertificate.pdf">ADAA pdf</a>]</p>
<p>Grass Type was built with <a href="http://timstutts.com/">Tim Stutts</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/08/16/adobe-honorable-mention-for-grass-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Align to Point Rhinoscript</title>
		<link>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/</link>
		<comments>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 19:54:46 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/2008/03/15/align-to-point-rhinoscript/</guid>
		<description><![CDATA[A basic Rhinoscript to rotate surfaces to align their normal to a point. Option Explicit 'Script written by Che-Wei Wang 'Script version Friday, March 07, 2008 10:55:15 AM Call Main() Sub Main() 'select srfs to rotate Dim arrSurfaces:arrSurfaces=Rhino.GetObjects("select surfaces to rotate") 'select point Dim point:point=Rhino.GetPoint("select light source point") 'calcuate vector from point to each srf [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/rotatesurfacescript.jpg" title="rotatesurfacescript.jpg" rel="lightbox[677]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/rotatesurfacescript.thumbnail.jpg" width="128" height="60" alt="rotatesurfacescript.jpg" class="imageframe" /></a></p>
<p>A basic Rhinoscript to rotate surfaces to align their normal to a point.<br />
<span id="more-677"></span></p>
<pre><code>Option Explicit
'Script written by Che-Wei Wang
'Script version Friday, March 07, 2008 10:55:15 AM

Call Main()
Sub Main()
	'select srfs to rotate
	Dim arrSurfaces:arrSurfaces=Rhino.GetObjects("select surfaces to rotate")

	'select point
	Dim point:point=Rhino.GetPoint("select light source point")

	'calcuate vector from point to each srf
	Dim srf
	For Each srf In arrSurfaces
		'find center of each srf
		Dim arrCentroid:arrCentroid=Rhino.SurfaceAreaCentroid(srf)
		'arrCentroid(0) is the center point
		Dim lightVector:lightVector=Rhino.VectorCreate( point,arrCentroid(0) )		

		'calculate normal to srf
		Dim srfNormal:srfNormal=Rhino.SurfaceNormal( srf, Array(0,0) )
		'normalize vectors
		lightVector=Rhino.VectorUnitize(lightVector)
		srfNormal=Rhino.VectorUnitize(srfNormal)

		'calcuate dot product and convert to radians
		Dim Angle:Angle=acos(Rhino.VectorDotProduct( lightVector,srfNormal)) 

		'calculate rotation axis
		Dim rotAxis:rotAxis=Rhino.VectorCrossProduct(lightVector, srfNormal )

		'rotate srf by that angle
		Call Rhino.RotateObject(srf,arrCentroid(0),360-Rhino.toDegrees(angle),rotAxis)

	Next	

End Sub</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Branching RhinoScript</title>
		<link>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/</link>
		<comments>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 19:41:58 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/2008/03/15/basic-branching-rhinoscript/</guid>
		<description><![CDATA[Option Explicit 'Script written by Che-Wei Wang 'Script version Friday, March 14, 2008 11:38:10 AM Call Main() Sub Main() ReDim arrStart(0) 'set startpoint arrStart(0)= array(0,0,0) 'call drawBraches Function with initial settings(arrStart startPostition, L initialLength, number of branches, number of generations) Call drawBranches(arrStart, 2, 2, 6) End Sub Function drawBranches( arrStart(), L, nBranches, generations) ReDim arrEndPoints(nBranches) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/branching.jpg" title="branching.jpg" rel="lightbox[674]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/branching.thumbnail.jpg" width="128" height="103" alt="branching.jpg" class="imageframe" /></a><br />
<span id="more-674"></span></p>
<pre><code>Option Explicit
'Script written by Che-Wei Wang
'Script version Friday, March 14, 2008 11:38:10 AM

Call Main()
Sub Main()

	ReDim arrStart(0)
	'set startpoint
	arrStart(0)= array(0,0,0)
	'call drawBraches Function with initial settings(arrStart startPostition, L initialLength, number of branches, number of generations)
	Call drawBranches(arrStart, 2, 2, 6)

End Sub

Function drawBranches( arrStart(), L, nBranches, generations)
	ReDim arrEndPoints(nBranches)
	Dim k,j
	Dim arrEnd, strobject, branchCount
	'reset branch count
	branchCount=0
	'for each start point
	For k = 0 To uBound(arrStart)
		'draw branches
		For j=0 To nBranches-1
			'endpoint based on startpoint
			arrEnd=array(arrStart(k)(0),arrStart(k)(1)+L,arrStart(k)(2)+rnd*L)
			'add line
			strObject=rhino.addline(arrStart(k), arrEnd)
			'rotate line randomly between -30 and 30
			Call rhino.RotateObject(strObject, arrStart(k), rnd*60-30)	 		

			'save each branches endpoint in an array
			ReDim Preserve arrEndPoints(branchCount)
			arrEndPoints(branchCount)=	Rhino.CurveEndPoint(strObject)
			'keep a count of the number of branches drawn
			branchCount=branchCount+1								     		

		Next
	Next

	'exit loop if generations=0
	If generations&gt;0 Then
		'recursive call with endpoints as startpoints, modified length, number of branches, and generation count-1
		Call drawBranches(arrEndPoints, l*.85, nBranches , generations-1)
	End If				

End Function</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comp Form: CFOF</title>
		<link>http://cwwang.com/2007/12/30/comp-form-cfof/</link>
		<comments>http://cwwang.com/2007/12/30/comp-form-cfof/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 01:21:53 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[openFrameworks]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/2007/12/30/comp-form-cfof/</guid>
		<description><![CDATA[CFOF is an audio to visual translator that maps audio frequencies and volume onto a minimal surface (Catalan&#8217;s Surface). Audio history is viualized and recorded onto the outer rings and move towards the center over time. The overall geometry is also affected by the audio input as high frequencies adjust parameters to expand the Catalan&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-4.png" title="cfof02_picture-4.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-4.thumbnail.png" alt="cfof02_picture-4.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-5.png" title="cfof02_picture-5.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-5.thumbnail.png" alt="cfof02_picture-5.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-6.png" title="cfof02_picture-6.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-6.thumbnail.png" alt="cfof02_picture-6.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-7.png" title="cfof02_picture-7.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-7.thumbnail.png" alt="cfof02_picture-7.png" class="imageframe" height="80" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-8.png" title="cfof02_picture-8.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-8.thumbnail.png" alt="cfof02_picture-8.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-9.png" title="cfof02_picture-9.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-9.thumbnail.png" alt="cfof02_picture-9.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-10.png" title="cfof02_picture-10.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-10.thumbnail.png" alt="cfof02_picture-10.png" class="imageframe" height="80" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-11.png" title="cfof02_picture-11.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-11.thumbnail.png" alt="cfof02_picture-11.png" class="imageframe" height="80" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-12.png" title="cfof02_picture-12.png" rel="lightbox[531]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/cfof02_picture-12.thumbnail.png" alt="cfof02_picture-12.png" class="imageframe" height="80" width="128" /></a></p>
<p>CFOF is an audio to visual translator that maps audio frequencies and volume onto a minimal surface  (<a href="http://mathworld.wolfram.com/CatalansSurface.html">Catalan&#8217;s Surface</a>).</p>
<p><span id="more-531"></span>Audio history is viualized and recorded onto the outer rings and move towards the center over time. The overall geometry is also affected by the audio input as high frequencies adjust parameters to expand the Catalan&#8217;s surface, while low pitches do the opposite.  Real-time frequencies and volume are displayed as ripples in across the entire surface.</p>
<p>Download: <a href="http://cwwang.com/wordpress/wp-content/uploads/cfof02app.zip" title="cfof02app.zip">cfof02app.zip</a> (mac)</p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/12/30/comp-form-cfof/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grass Type</title>
		<link>http://cwwang.com/2007/10/28/grass/</link>
		<comments>http://cwwang.com/2007/10/28/grass/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 19:32:02 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://cwwang.com/wordpress/2007/10/28/grass/</guid>
		<description><![CDATA[Grass Type is a virtual grass mat. Mouse movements send waves of wind across the grass, erasing the imprinted text which then slowly reappears over time as the wind dies down. (developed with Tim Stutts) Download grasstextapp.zip GrassTypeAdobe.app.zip (for Macs written in C and openGL). Installation]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-2.png" title="grasspicture-2.png" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-2.thumbnail.png" alt="grasspicture-2.png" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-5.png" title="grasspicture-5.png" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-5.thumbnail.png" alt="grasspicture-5.png" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-6.png" title="grasspicture-6.png" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-6.thumbnail.png" alt="grasspicture-6.png" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-4.png" title="grasspicture-4.png" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grasspicture-4.thumbnail.png" alt="grasspicture-4.png" class="imageframe" height="96" width="128" /></a></p>
<p>Grass Type is a virtual grass mat. Mouse movements send waves of wind across the grass, erasing the imprinted text which then slowly reappears over time as the wind dies down. (developed with <a href="http://timstutts.com">Tim Stutts</a>)</p>
<p>Download <strike>grasstextapp.zip</strike> <a href="http://cwwang.com/wordpress/wp-content/uploads/GrassTypeAdobe.app.zip" title="GrassTypeAdobe.app.zip">GrassTypeAdobe.app.zip</a> (for Macs written in C and openGL).</p>
<p><span id="more-371"></span><strong>Installation</strong><br />
<a href="http://cwwang.com/wordpress/wp-content/uploads/dsc00056.jpg" title="dsc00056.jpg" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/dsc00056.thumbnail.jpg" alt="dsc00056.jpg" class="imageframe" height="85" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/dsc00057.jpg" title="dsc00057.jpg" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/dsc00057.thumbnail.jpg" alt="dsc00057.jpg" class="imageframe" height="85" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/img_0563.jpg" title="img_0563.jpg" rel="lightbox[371]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/img_0563.thumbnail.jpg" alt="img_0563.jpg" class="imageframe" height="96" width="128" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/10/28/grass/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grass: Brush</title>
		<link>http://cwwang.com/2007/10/19/grass-brush/</link>
		<comments>http://cwwang.com/2007/10/19/grass-brush/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 07:08:04 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/wordpress/2007/10/19/grass-brush/</guid>
		<description><![CDATA[A small step towards realistic grass in openGL and C. Grass responds to &#8220;petting&#8221; via mouse control. //grass # define nBlades 30000 int randomX[nBlades]; int randomY[nBlades]; int randomHeight[nBlades]; float randomWindVelocity[nBlades]; float t[nBlades]; float distance[nBlades]; float angle[nBlades]; float sway[nBlades]; float pmouseX=0; float pmouseY=0; void drawBlade2(float x, float y, int i){ angle[i]=atan2(mouseX-x,mouseY-y); //angle to mouse distance[i]=dist(x,y,mouseX,mouseY); //distance [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/wk6grassscreenshot_1.png" title="wk6grassscreenshot_1.png" rel="lightbox[352]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/wk6grassscreenshot_1.thumbnail.png" width="128" height="87" alt="wk6grassscreenshot_1.png" class="imageframe" /></a><br />
A small step towards realistic grass in openGL and C.  Grass responds to &#8220;petting&#8221; via mouse control.</p>
<p><span id="more-352"></span></p>
<pre><code>//grass
# define nBlades 30000

int randomX[nBlades];
int randomY[nBlades];
int randomHeight[nBlades];
float randomWindVelocity[nBlades];
float t[nBlades];
float distance[nBlades];
float angle[nBlades];
float sway[nBlades];
float	pmouseX=0;
float	pmouseY=0;
void drawBlade2(float x, float y, int i){
	angle[i]=atan2(mouseX-x,mouseY-y); //angle to mouse
	distance[i]=dist(x,y,mouseX,mouseY); //distance to mouse
	float tilt=sin(radians(t[i]))*randomHeight[i]/5;//sway distance
		Vec2d mouse=Vec2d(mouseX,mouseY);
		Vec2d A=Vec2d(x,y);//grass root
			Vec2d B=Vec2d(x*3,y*3+randomHeight[i]*.1);//first control point
				Vec2d C=Vec2d(x*3,y*3+randomHeight[i]*.7);
				Vec2d D=Vec2d(x+tilt,y+randomHeight[i]);//grass tip

					float brushSize=dist(pmouseX,pmouseY,mouseX,mouseY);

					if( distance[i]&lt;brushSize){
						sway[i]=randomWindVelocity[i]/distance[i]*9*(constrain(angle[i],-2,2));//random velocity * direction in relation to mouse
					}
					t[i]=t[i]+sway[i]; //sway speed

					//decay
					if (t[i]&gt;.01|| t[i]&lt;-.01){
						t[i]=t[i]*.982;
					}

					glColor3f(.2,(randomHeight[i]/30.0),.15);

					glBegin(GL_LINE_STRIP);
					for (float p=0;p&lt;=1.0;p=p+.5){
						float b=1.0-p;

						Vec2d F=A*b*b*b+B*b*b*p+C*p*p*b+D*p*p*p;

						float gradient=p;
						float nTilt=tilt/80;
						glColor4f(.2*gradient-nTilt,(randomHeight[i]/60.0)*gradient-nTilt,.15*gradient-nTilt,.9);

						glVertex2f(F.x,F.y);

					}
					glEnd();
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/10/19/grass-brush/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grass 01</title>
		<link>http://cwwang.com/2007/10/11/grass-01/</link>
		<comments>http://cwwang.com/2007/10/11/grass-01/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 04:53:34 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/wordpress/2007/10/11/grass-01/</guid>
		<description><![CDATA[I&#8217;m working on an interactive grass mat with Tim Stutts. Using the subtleties in the grass movements, we can imprint text or figures into realistically rendered grass, projected from above. Here&#8217;s my first step. . . Updated Here: Grass Type //grass # define nBlades 10000 int randomX[nBlades]; int randomY[nBlades]; int randomHeight[nBlades]; float randomWindVelocity[nBlades]; float t[nBlades]; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an interactive grass mat with <a href="http://itp.nyu.edu/~ts1200/blog/">Tim Stutts</a>.  Using the subtleties in the grass movements, we can imprint text or figures into realistically rendered grass, projected from above.  Here&#8217;s my first step. . .</p>
<p>Updated Here: <a href="http://cwwang.com/2007/10/28/grass/">Grass Type</a><br />
<span id="more-331"></span><br />
<a href="http://cwwang.com/wordpress/wp-content/uploads/grass01wk5.png" title="grass01wk5.png" rel="lightbox[331]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/grass01wk5.thumbnail.png" alt="grass01wk5.png" class="imageframe" height="99" width="128" /></a></p>
<pre><code>//grass
# define nBlades 10000

int randomX[nBlades];
int randomY[nBlades];
int randomHeight[nBlades];
float randomWindVelocity[nBlades];
float t[nBlades];
float distance[nBlades];
float angle[nBlades];
float sway[nBlades];

void drawBlade2(float x, float y, int i){

	angle[i]=atan2(mouseX-x,mouseY-y); //angle to mouse
	distance[i]=dist(x,mouseX,y,mouseY); //distance to mouse
	float tilt=sin(radians(t[i]))*randomHeight[i]/5;//sway distance

		Vec2d A=Vec2d(x,y);//grass root
			Vec2d B=Vec2d(x*3,y*3+randomHeight[i]*.1);//first control point at 1/4 of height
				Vec2d C=Vec2d(x*3,y*3+randomHeight[i]*.9);
				Vec2d D=Vec2d(x+tilt,y+randomHeight[i]);//grass tip

					if( distance[i]&amp;lt;100){
						sway[i]=randomWindVelocity[i]/50*constrain(angle[i],-1,1);//random velocity * direction in relationt to mouse
					}
					t[i]=t[i]+sway[i]; //sway speed

					//decay
					if (t[i]&amp;gt;.01|| t[i]&amp;lt;-.01){
						t[i]=t[i]*.997;
					}

					glColor3f(.2,(randomHeight[i]/80.0),.15);

					glBegin(GL_LINE_STRIP);
					for (float p=0;p&amp;lt;1.0;p=p+.4){
						float b=1.0-p;

						Vec2d y=A*b*b*b+B*b*b*p+C*p*p*b+D*p*p*p;

						float gradient=p;
						glColor4f(.2*gradient,(randomHeight[i]/60.0)*gradient,.15*gradient,.9);
						glVertex2f(y.x,y.y);
					}
					glEnd();
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/10/11/grass-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

