<?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>simppa.fi/blog &#187; source</title>
	<atom:link href="http://www.simppa.fi/blog/category/source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simppa.fi/blog</link>
	<description>minä kaikkeudessa.</description>
	<lastBuildDate>Wed, 11 Jan 2012 11:10:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Introducing open source evoSpicyParticleEngine</title>
		<link>http://www.simppa.fi/blog/introducing-open-source-evospicyparticleengine/</link>
		<comments>http://www.simppa.fi/blog/introducing-open-source-evospicyparticleengine/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 16:25:05 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[evoSpicyParticleEngine]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[stage3d]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=1314</guid>
		<description><![CDATA[In this post I&#8217;m going to explain some of my findings when playing around with Adobe&#8217;s Stage3D and particles. I have pushed the current version of particle engine called evoSpicyParticleEngine into GitHub, will show some examples how to play with it and explain tricks used in it. &#8230; but first I want to joyously announcing [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.simppa.fi/blog/wp-content/uploads/2011/11/evospicyparticleengine1.jpg' alt='' title='evospicyparticleengine' width='920' height='377' class='alignnone size-full wp-image-1787' /></p>
<p>In this post I&#8217;m going to explain some of my findings when playing around with Adobe&#8217;s Stage3D and particles. I have pushed the current version of particle engine called evoSpicyParticleEngine into GitHub, will show some examples how to play with it and explain tricks used in it.<br />
<span id="more-1314"></span><br />
&#8230; but first I want to joyously announcing that I do not owe you shit. Nor does anyone else that open source stuff or release what ever. So if you don&#8217;t like the syntax or what ever don&#8217;t pressure me with feature requests. Get involved by forking my codes.</p>
<p>We are the most spoiled generation ever. The notorious West. At that nanosecond everything isn&#8217;t absolutely perfect we start to whine like children. One can just wonder how complaining when train schedule fails for 10 minutes sounds from majority perspective. (including those four billion people that live under $2.50 a day)<br />
How utterly ridiculous it is to whine when some extremely sophisticated technology fails to work at that precious moment one felt like using it? (e.g. Internet)<br />
Or how about whining when some refugee that came four months ago from country middle of oil war fails to pronounce the pizza delivery right?</p>
<p>Here&#8217;s a <a href="http://www.youtube.com/watch?v=8r1CZTLk-Gk" target="_blank">great sort youtube clip</a> from Conan O&#8217;Briens show related to this. </p>
<p>We face this nonsense when perspective is fucked up. Lets say we ditch the whining and preserve efforts.</p>
<p>Here&#8217;s my next effort for our playgrounds wellbeing (no more preaching):</p>
<p><strong>evoSpicyParticleEngine</strong></p>
<p>The idea behind this engine was to be able to render massive amount of moving particles. So this meant some restrictions. For example it only renders full buffers, it renders triangles instead of quads and all particles share some properties.</p>
<p>All this stuff can be find from GitHub. You&#8217;ll get links at the bottom of this gigantic post. Lets take a look from outside. This is how you render basic particles with sphere explosion movement:</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="co1">// Create engine instance. (Reference to stage, stageIndex = which stage.stage3Ds to use, enableErrorChecking, set f-key as fullscren trigger)</span><br />
spicy = <span class="kw1">new</span> EvoSpicyParticleEngine<span class="br0">&#40;</span><span class="kw7">stage</span><span class="sy0">,</span> 0<span class="sy0">,</span> <span class="kw1">false</span><span class="sy0">,</span> <span class="kw1">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="co1">// If context3d failed</span><br />
spicy<span class="sy0">.</span>on3DFailed<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span>on3DFailed<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="co1">// Get info about users GPU.</span><br />
spicy<span class="sy0">.</span>onGPUInfo<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span>onGPUInfo<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="co1">// Wait until the engine is ready.</span><br />
spicy<span class="sy0">.</span>onEngineReady<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span>onEngineReady<span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>&#8230;</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="kw1">private</span> <span class="kw3">function</span> onEngineReady<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Z-Sort particles or not.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>setDepthTest<span class="br0">&#40;</span><span class="kw1">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Texture for particles.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>setTextureParticle<span class="br0">&#40;</span><span class="kw1">new</span> TextureParticleAlphaKill<span class="br0">&#40;</span>128<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// BlendMode of particles.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>setBlendMode<span class="br0">&#40;</span><a href="http://www.google.com/search?q=blendmode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:blendmode.html"><span class="kw5">BlendMode</span></a><span class="sy0">.</span><span class="kw8">NORMAL</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// How far away particles are rendered</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>zFar = <span class="nu0">30000</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Field Of View</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>fov = <span class="nu0">90</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// count : int (maximum particle count = 1398080), valueClass : IValue (settings for particles. start points, end points, speeds, colors) </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>addParticles<span class="br0">&#40;</span> &nbsp; &nbsp; <span class="nu0">139808</span><span class="sy0">,</span> <span class="co1">// Particle count</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">new</span> ValueExplosionSphere<span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">new</span> ColorGradient<span class="br0">&#40;</span><span class="br0">&#91;</span>0x3bc1ff<span class="sy0">,</span> 0x84481b<span class="sy0">,</span> 0xFFc1ff<span class="sy0">,</span> 0x3bc1ff<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">100</span><span class="sy0">,</span> <span class="nu0">100</span><span class="sy0">,</span> <span class="nu0">100</span><span class="sy0">,</span> &nbsp;<span class="co1">// Start position multipliers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">2500</span><span class="sy0">,</span> <span class="nu0">2500</span><span class="sy0">,</span> <span class="nu0">2500</span><span class="sy0">,</span> <span class="co1">// End position multipliers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">16</span><span class="sy0">,</span> <span class="co1">// Size of single particle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">true</span><span class="sy0">,</span> <span class="co1">// Randomize sizes or not</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><span class="co1">// Add random value for individual speed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// particle renderer. </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> renderer<span class="sy0">:</span>RendererLinear<span class="sy0">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>setRenderer<span class="br0">&#40;</span>renderer = <span class="kw1">new</span> RendererLinear<span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">new</span> ProgramLinear<span class="br0">&#40;</span>EaseProgram<span class="sy0">.</span><span class="kw8">LINEAR</span><span class="sy0">,</span> <span class="kw1">false</span><span class="sy0">,</span> <span class="kw1">true</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="co1">// Shaders</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">0.00008</span><span class="sy0">,</span> <span class="co1">// Speed of particles</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">128</span><span class="sy0">,</span> <span class="co1">// How many particles to rebirth in every frame</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x1e1b17<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Background color</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Move the start point</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; renderer<span class="sy0">.</span>startPoints<span class="br0">&#91;</span>0<span class="br0">&#93;</span><span class="sy0">.</span><span class="kw7">y</span> = <span class="sy0">-</span><span class="nu0">500</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// add extra start point(s) (renderer.startPoints[1])</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; renderer<span class="sy0">.</span>addStartPoint<span class="br0">&#40;</span><span class="kw1">new</span> StartPoint3D<span class="br0">&#40;</span>0<span class="sy0">,</span> 500<span class="sy0">,</span> 0<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Start rendering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span><span class="sy0">.</span><span class="kw7">addEventListener</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span class="kw5">Event</span></a><span class="sy0">.</span><span class="kw8">ENTER_FRAME</span><span class="sy0">,</span> run<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>&#8230;</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="kw1">private</span> <span class="kw3">function</span> run<span class="br0">&#40;</span>event<span class="sy0">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span class="kw5">Event</span></a><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> <span class="kw7">time</span><span class="sy0">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span class="kw5">int</span></a> = <span class="kw7">getTimer</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> <span class="kw7">angle</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span class="kw5">Number</span></a> = <span class="kw7">time</span> <span class="sy0">*</span> <span class="sy0">.</span>0001<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> rad<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span class="kw5">Number</span></a> = <span class="nu0">1000</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>camera<span class="sy0">.</span><span class="kw7">position</span><span class="sy0">.</span><span class="kw7">x</span> = rad <span class="sy0">*</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span class="kw5">Math</span></a><span class="sy0">.</span><span class="kw7">sin</span><span class="br0">&#40;</span><span class="kw7">angle</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>camera<span class="sy0">.</span><span class="kw7">position</span><span class="sy0">.</span>z = rad <span class="sy0">*</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span class="kw5">Math</span></a><span class="sy0">.</span><span class="kw7">cos</span><span class="br0">&#40;</span><span class="kw7">angle</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>camera<span class="sy0">.</span><span class="kw7">position</span><span class="sy0">.</span><span class="kw7">y</span> = <span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>camera<span class="sy0">.</span>lookAtPoint<span class="br0">&#40;</span>0<span class="sy0">,</span>0<span class="sy0">,</span>0<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span>camera<span class="sy0">.</span>rotationZ = <span class="kw7">time</span> <span class="sy0">*</span> <span class="sy0">.</span>01<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; spicy<span class="sy0">.</span><span class="kw7">render</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Code above in action<br />
<a href="http://www.simppa.fi/experimental/as3/2011/evospicyparticleengine/spicyparticlebasic/"><img src="http://www.simppa.fi/experimental/as3/2011/evospicyparticleengine/spicyparticlebasic/screenshot.jpg" alt="SpicyParticleBasic" />SpicyParticleBasic</a>.</p>
<p>Another example that&#8217;s also in GitHub<br />
<a href="http://www.simppa.fi/experimental/as3/2011/evospicyparticleengine/spicyparticleblurperlin/"><img src="http://www.simppa.fi/experimental/as3/2011/evospicyparticleengine/spicyparticleblurperlin/screenshot.jpg" alt="SpicyParticleBlurPerlin" />SpicyParticleBlurPerlin</a>.</p>
<p>That looks easy enough?</p>
<p>Lets take a look on some of the tricks.</p>
<p><strong>Single particle</strong><br />
Like I mentioned earlier in this engine particles are triangles. The &#8216;normal&#8217; way would have them in quad that contains two triangles. That takes 4 vertices which is more then 3 and triangle can draw a particle as well.</p>
<p><img src="http://www.simppa.fi/blog/wp-content/uploads/2011/11/particletriangle.jpg" alt="" title="particletriangle" width="640" height="200" class="alignnone size-full wp-image-1374" /> </p>
<p>Common sense, huh? ;)</p>
<p><strong>Face particle to camera</strong><br />
This is a trick that I got idea and code examples from <a href="http://jpauclair.net/2011/07/18/massive-3d-particle-system-in-flash-molehill/">blog post</a> by Jean-Philippe Auclair who works at <a href="http://frimastudio.com/">Frima Studio</a>. It&#8217;s a great post about particles. Make sure to read it up if you haven&#8217;t already.<br />
Trick goes like this:</p>
<p>1. Precalculate a single triangle and store it to GPU. Store those register numbers (10,11,12) into individual particle position component (x, y, z, w <- right there).</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="kw2">var</span> <span class="kw7">data</span><span class="sy0">:</span>Vector<span class="sy0">.&lt;</span>Number<span class="sy0">&gt;</span> = Vector<span class="sy0">.&lt;</span>Number<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#91;</span><span class="sy0">-</span>1<span class="sy0">,</span> <span class="sy0">-</span>1<span class="sy0">,</span> 0<span class="sy0">,</span> 1<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
context3d<span class="sy0">.</span>setProgramConstantsFromVector<span class="br0">&#40;</span>Context3DProgramType<span class="sy0">.</span>VERTEX<span class="sy0">,</span> 10<span class="sy0">,</span> <span class="kw7">data</span><span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw7">data</span> = Vector<span class="sy0">.&lt;</span>Number<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#91;</span>0<span class="sy0">,</span> 1<span class="sy0">,</span> 0<span class="sy0">,</span> 1<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
context3d<span class="sy0">.</span>setProgramConstantsFromVector<span class="br0">&#40;</span>Context3DProgramType<span class="sy0">.</span>VERTEX<span class="sy0">,</span> 11<span class="sy0">,</span> <span class="kw7">data</span><span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw7">data</span> = Vector<span class="sy0">.&lt;</span>Number<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#91;</span>1<span class="sy0">,</span> <span class="sy0">-</span>1<span class="sy0">,</span> 0<span class="sy0">,</span> 1<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
context3d<span class="sy0">.</span>setProgramConstantsFromVector<span class="br0">&#40;</span>Context3DProgramType<span class="sy0">.</span>VERTEX<span class="sy0">,</span> 12<span class="sy0">,</span> <span class="kw7">data</span><span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>2. In render method create a matrix that&#8217;s invert from camera matrix and pass it on to GPU</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="co1">// CAMERA</span><br />
transformCamera<span class="sy0">.</span><span class="kw7">identity</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
transformCamera<span class="sy0">.</span><span class="kw7">position</span> = camera<span class="sy0">.</span><span class="kw7">position</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">if</span><span class="br0">&#40;</span>camera<span class="sy0">.</span>_doLookAt<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; transformCamera<span class="sy0">.</span>pointAt<span class="br0">&#40;</span>camera<span class="sy0">.</span>_renderLookAt<span class="sy0">,</span> Vector3D<span class="sy0">.</span>Z_AXIS<span class="sy0">,</span> _up<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; camera<span class="sy0">.</span>_doLookAt = <span class="kw1">false</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
transformCamera<span class="sy0">.</span>prependRotation<span class="br0">&#40;</span>camera<span class="sy0">.</span>rotationX<span class="sy0">,</span> Vector3D<span class="sy0">.</span>Y_AXIS<span class="br0">&#41;</span><span class="sy0">;</span><br />
transformCamera<span class="sy0">.</span>prependRotation<span class="br0">&#40;</span>camera<span class="sy0">.</span>rotationY<span class="sy0">,</span> Vector3D<span class="sy0">.</span>Y_AXIS<span class="br0">&#41;</span><span class="sy0">;</span><br />
transformCamera<span class="sy0">.</span>prependRotation<span class="br0">&#40;</span>camera<span class="sy0">.</span>rotationZ<span class="sy0">,</span> Vector3D<span class="sy0">.</span>Z_AXIS<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
transformCamera<span class="sy0">.</span>copyToMatrix3D<span class="br0">&#40;</span>transformParticle<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">// Copy camera matrix</span><br />
transformCamera<span class="sy0">.</span><span class="kw7">invert</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Invert camera</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="co1">// MODEL</span><br />
transformModel<span class="sy0">.</span><span class="kw7">identity</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
transformModel<span class="sy0">.</span><span class="kw7">position</span> = <span class="kw1">this</span><span class="sy0">;</span><br />
transformModel<span class="sy0">.</span>append<span class="br0">&#40;</span>transformCamera<span class="br0">&#41;</span><span class="sy0">;</span><br />
transformModel<span class="sy0">.</span>append<span class="br0">&#40;</span>transformProjection<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
context3d<span class="sy0">.</span>setProgramConstantsFromMatrix<span class="br0">&#40;</span>Context3DProgramType<span class="sy0">.</span>VERTEX<span class="sy0">,</span> 0<span class="sy0">,</span> transformModel<span class="sy0">,</span> <span class="kw1">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
context3d<span class="sy0">.</span>setProgramConstantsFromMatrix<span class="br0">&#40;</span>Context3DProgramType<span class="sy0">.</span>VERTEX<span class="sy0">,</span> 13<span class="sy0">,</span> transformParticle<span class="sy0">,</span> <span class="kw1">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>3. In vertex shader get position of stored triangle, rotate that with camera invert. Scale it to desired size and transform to world space.</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;">agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mov vt2, vc[va0.w] <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// get vertice position from stored triangle</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;m33 vt0.xyz, vt2.xyz, vc13 <span class="es0">\n</span>&quot;</span><span class="sy0">;</span>&nbsp; &nbsp; <span class="co1">// rotate vertice with camera invert matrix</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mov vt0.w, vt2.w <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// set proper w value from stored triangle</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mul vt0.xyz, vt0.xyz, va3.z <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; <span class="co1">// va3.z = Size of individual particle</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;add vt0.xyz, vt0.xyz, vt1.xyz <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> <span class="co1">// set new position for vertice </span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;m44 op, vt0, vc0 <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// transform and output vertex x,y,z</span></div>
</div>
<p>Tadaa! now it&#8217;s always facing the camera and this trick didn&#8217;t cost a penny.</p>
<p><strong>Moving particles in vertex shader</strong><br />
In AGAL vertex shader we cannot add values to vertices. Like move them a bit in x-axel in every frame. The data isn&#8217;t stored anywhere. All values must be at memory and push to GPU and then it&#8217;s just drawn. Continue movement could be done by storing movement values into a texture but we do not have access to texture in vertex shader. This a challenge and there&#8217;s a trick to get around this: We store start and end point of every vertices. Give a start time value to every particle and send constantly increasing time value to vertex shader. Then simply tween the particle position between those points according to time and start time value.</p>
<p>This way we can &#8216;rebirth&#8217; single particle by setting it&#8217;s start time value to current time value.<br />
This is how it looks like in AGAL:</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;">agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mov vt1, va0 <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// vertex</span><br />
<span class="co1">// va3 = individual component for every particle</span><br />
<span class="co1">// va3.x = starttime</span><br />
<span class="co1">// va3.y = speed multiplier</span><br />
<span class="co1">// va3.z = size of particle</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;sub vt3.x, vc4.x, va3.x <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; <span class="co1">// time &#8211; start time</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mul vt3.x, vt3.x, va3.y <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; <span class="co1">// multiply time with move.y (to get individual speed)</span><br />
<span class="co1">// LINEAR MOVEMENT</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;sub vt6.xyz, va4.xyz, vt1.xyz <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> <span class="co1">// b &#8211; a</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mul vt7.xyz, vt6.xyz, vt3.x <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; <span class="co1">// movement</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;add vt1.xyz, vt1.xyz, vt7.xyz <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> <span class="co1">// add move</span></div>
</div>
<p>And that&#8217;s how we can move <a href="http://www.simppa.fi/blog/1_point_4_million_particles/" target="_blank">1.4 million particles in flash</a>.</p>
<p><strong>Manipulate the movement</strong><br />
AGAL is not limiting language. (except that &#8216;no access to texture&#8217;-thing) It has a stack of mathematical functions. With those a lot is possible. Here&#8217;s how particle movement is eased in exponential fashion:</p>
<div class="codesnip-container" >
<div class="actionscript3 codesnip" style="font-family:monospace;"><span class="co1">// EXPO OUT</span><br />
<span class="co1">// &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; c * (-Math.pow(2, -10 * t/d) + 1) + b;</span><br />
<span class="co1">// where &nbsp; &nbsp; &nbsp; &nbsp;t = time; b = 0; c = 1; d = 1;</span><br />
<span class="co1">// so it&#8217;s &nbsp; &nbsp; &nbsp;1 * (-Math.pow(2, -10 * time/1) + 1) + 0;</span><br />
<span class="co1">// and &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; -Math.pow(2, -10 * time) + 1;</span><br />
<span class="co1">//________________________________________________________________</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;mul vt6.x, vc5.z, vt3.x <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; <span class="co1">// -10 * vt3.x</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;pow vt7.x, vc5.w, vt6.x <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; <span class="co1">// Math.pow(2, vt6)</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;neg vt7.x, vt7.x <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// -Math.pow(2, vt6)</span><br />
agalVertexSource <span class="sy0">+</span>= <span class="st0">&quot;add vt3.x, vt7.x, vc5.y <span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; <span class="co1">// -Math.pow(2, vt6) + 1</span></div>
</div>
<p><strong>Get your forks polished</strong><br />
 &#8211; <a href="https://github.com/simppafi/evoSpicyParticleEngine">evoSpicyParticleEngine at GitHub</a>. Also check those examples.</p>
<p>Hopefully you learn something from it. You can use it anyway you like. Contributing for its development by forking at GitHub is desirable. I&#8217;m slowly developing it more as time goes by. Post process filters, background and overlays are on table. Ohh and lights of course. All those are actually in my classes commented out waiting for polishing.</p>
<p>Peace and love, Simo</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/introducing-open-source-evospicyparticleengine/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Laboratory output n°74 RaySlime</title>
		<link>http://www.simppa.fi/blog/rayslime/</link>
		<comments>http://www.simppa.fi/blog/rayslime/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 19:42:25 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Experimentals]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pixelbender]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=914</guid>
		<description><![CDATA[I wanted to post these &#8216;oldies&#8217; to get them into my gallery. They are raytraced balls and some slimy turds in 1&#215;1 pixels with decent framerate. I used Pixel Bender to create them. I haven&#8217;t done much experimenting because of two reasons. 1. I&#8217;ve been coding a lot of Objective-C lately. It felt easier to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simppa.fi/experimental/as3/2010/raytracing/rayslime/"><img src="http://www.simppa.fi/experimental/as3/2010/raytracing/rayslime/screenshot.png" alt="RaySlime" /></a><br />
<a href="http://www.simppa.fi/experimental/as3/2010/raytracing/1024x576/"><img src="http://www.simppa.fi/experimental/as3/2010/raytracing/1024x576/screenshot.png" alt="RayTracing" /></a></p>
<p>I wanted to post these &#8216;oldies&#8217; to get them into my gallery. They are raytraced balls and some slimy turds in 1&#215;1 pixels with decent framerate. I used Pixel Bender to create them. I haven&#8217;t done much experimenting because of two reasons. </p>
<p>1. I&#8217;ve been coding a lot of Objective-C lately. It felt easier to return coding with whole different language. It&#8217;s still sometimes a bit frustrating to code AS3. I do typos for example with &#8216;<>&#8216;-marks and with some sort-cuts but when it comes to iPhone SDK I learned new way of typing. I also want to point out that the development tools of Apple are excellent. I should get my first App out very soon.</p>
<p>2. I joined the <a href="http://away3d.com/">Away3D group</a> to help them with new extremely secret project. I have nothing more to say about that yet :)</p>
<p>Lastly here are few Pixel Bender tricks for you:</p>
<p>How to create a loop in Pixel Bender?<br />
 &#8211; With help of clever brains of <a href="http://twitter.com/#!/MrKishi">@MrKishi</a> = <a href="http://www.simppa.fi/source/LoopMacros2.pbk">http://www.simppa.fi/source/LoopMacros2.pbk</a></p>
<p>How to make your #define&#8217;s readable?<br />
- with &#8220;\&#8221;-mark</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="co2">#define method(param) foo += param; \</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo <span class="sy0">*</span>= bar; \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo -= foo<span class="sy0">*</span><span class="nu0">0.1</span>;</div>
</div>
<p>And apparently you can do like this:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="co2">#define col(b) float4(1.0, 1.0, b, 1.0);</span></p>
<p><span class="kw3">void</span><br />
evaluatePixel<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; dst = col<span class="br0">&#40;</span>0.5<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/rayslime/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Victory at Assembly, opensourced evoCunningParticleEngine and some bad news</title>
		<link>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/</link>
		<comments>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 07:40:16 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[evoCunningParticleEngine]]></category>
		<category><![CDATA[evoSync]]></category>
		<category><![CDATA[evoTinyEngine]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=905</guid>
		<description><![CDATA[After 4-5 months of twiddle it payed off and we won again at Assembly. You can checkout the outcome in realtime by clicking the picture or view it in HD at Youtube. Here&#8217;s also the link to the info file and link to pouet of course. As I mentioned earlier I invited David Lenaerts to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simppa.fi/asm10/spiralout/"><img src="http://www.simppa.fi/blog/wp-content/uploads/2010/08/screen_simppafi_spo.jpg" alt="" title="Evoflash - Spiral Out" width="605" height="340" class="alignnone size-full wp-image-907" /></a><br />
After 4-5 months of twiddle it payed off and we won again at Assembly. You can checkout the outcome in realtime by clicking the picture or view it in <a href="http://www.youtube.com/watch?v=64LmkYV4KrQ">HD at Youtube</a>. <a href="http://www.simppa.fi/asm10/spiralout/evo-spo.nfo.txt">Here&#8217;s also the link to the info file</a> and <a href="http://www.pouet.net/prod.php?which=55593">link to pouet of course</a>.</p>
<p>As I mentioned earlier I invited <a href="http://www.derschmale.com/">David Lenaerts</a> to help with the demo. All those fancy Away3dLite stuff with shadows and reflections came by his hands. Awesome!</p>
<p>I also compiled the whole shit through <a href="http://blog.joa-ebert.com/">Joa Ebert&#8217;s Apparat</a>. It did speed up it a bit.</p>
<p>I also had a presentation at Assembly. I talked about my flash art and introduced the evoTinyEngine, evoCunningParticleEngine and evoSync-tool. I haven&#8217;t found the recording of the speech yet but here are some of the links I had there.</p>
<p> &#8211; <a href="http://evocunningparticleengine.googlecode.com/">evoCunningParticleEngine at googlecode</a><br />
 &#8211; <a href="http://evotinyengine.googlecode.com/"> evoTinyEngine at googlecode</a><br />
 &#8211; <a href="http://dl.dropbox.com/u/5754229/evoSync.air">download the evoSync air app</a></p>
<p>You can also <a href="http://www.simppa.fi/talk/asm10/asm10_simppa.pdf">download the presentation in pdf format</a>.</p>
<p>Then the bad news. I had an accident last Friday. I fall down from the fence and my wedding ring got stuck at the top of the fence.<br />
The ring peel off all the skin, muscles and stuff out of my finger. The main tragedy about it was that it also ruined my fingers blood vessels and the finger had to be amputated. So I won&#8217;t be coding new experiments for a while now I guess. I also need to learn how to type fast with 9 fingers. I will recover eventually, but it&#8217;ll take some time and hard work.</p>
<p>I&#8217;ll post more info about the particle engine later when it won&#8217;t hurt so much to type.</p>
<p>p.s. We also did <a href="http://www.simppa.fi/asm10/4k/sof/">this little demo</a> with Jalava to show that 4k intro can be done with Flash. It&#8217;s not too fancy but it proofs the concept :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>EvoFlash Severity Of Grey Sources</title>
		<link>http://www.simppa.fi/blog/evoflash-severity-of-grey-sources/</link>
		<comments>http://www.simppa.fi/blog/evoflash-severity-of-grey-sources/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 19:26:21 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[evo3d]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=411</guid>
		<description><![CDATA[All the following stuff is under this completely open license. These sources consist four different parts: &#8211; EvoTinyEngine &#8211; Evo3d &#8211; EvoTween &#8211; SoG Demo None of these are documented so I have created this little pdf to clarify the concept of demoengine used in this demo. These libraries are rather easy to use. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>All the following stuff is under <a href="http://www.simppa.fi/source/LICENSE.TXT">this completely open license</a>.</p>
<p>These sources consist four different parts:<br />
 &#8211; <a href="http://www.simppa.fi/source/evo_tiny_engine_src.zip">EvoTinyEngine</a><br />
 &#8211; <a href="http://www.simppa.fi/source/evo3d_src.zip">Evo3d</a><br />
 &#8211; <a href="http://www.simppa.fi/source/evo_tween_src.zip">EvoTween</a><br />
 &#8211; <a href="http://www.simppa.fi/source/evo_sog_src.zip">SoG Demo</a></p>
<p>None of these are documented so I have created <a href="http://www.simppa.fi/source/jac_EvoTinyEngine.pdf">this little pdf</a> to clarify the concept of demoengine used in <a href="http://www.simppa.fi/asm09/">this demo</a>.<br />
<span id="more-411"></span><br />
These libraries are rather easy to use. Here&#8217;s the HelloWorld of EvoTinyEngine:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">assets = <span class="kw2">new</span> Assets<span class="br0">&#40;</span>720, 405<span class="br0">&#41;</span>;</p>
<p>engine = <span class="kw2">new</span> TinyEngine<span class="br0">&#40;</span>assets<span class="br0">&#41;</span>;</p>
<p>engine.<span class="me1">addModifier</span><span class="br0">&#40;</span><span class="kw2">new</span> ModifierPixels<span class="br0">&#40;</span>assets, <span class="st0">&quot;pixel&quot;</span><span class="br0">&#41;</span>, 0, 64<span class="br0">&#41;</span>;<br />
engine.<span class="me1">addModifier</span><span class="br0">&#40;</span><span class="kw2">new</span> ModifierMandel<span class="br0">&#40;</span>assets, <span class="st0">&quot;mandel&quot;</span><span class="br0">&#41;</span>, 64, 256<span class="br0">&#41;</span>;<br />
engine.<span class="me1">addModifier</span><span class="br0">&#40;</span><span class="kw2">new</span> ModifierBloom<span class="br0">&#40;</span>assets, <span class="st0">&quot;bloom&quot;</span><span class="br0">&#41;</span>, 256, 512<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
addChild<span class="br0">&#40;</span>engine<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
engine.<span class="kw3">play</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p>You should have all the examples you need about other libraries in the SoG Demo zip. Here are few example lines about syntax&#8217;s.</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="co1">// EvoTween is a Command-pattern based tweener that uses the linked list method. This way you can run few thousands tween&#8217;s at ones. So convenient&#8230; :)</span><br />
<span class="co1">// Only minus at the moment is that it only supports public variables.</span></p>
<p><span class="kw2">new</span> EvoTween<span class="br0">&#40;</span><span class="kw3">this</span>, &nbsp;<span class="br0">&#123;</span>value:1<span class="br0">&#125;</span>, &nbsp;<span class="kw3">duration</span>, &nbsp;Expo.<span class="me1">easeInOut</span>, &nbsp;delay, complete:<span class="kw2">Function</span>, &nbsp;param:<span class="sy0">*</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">// After the tween is over it is disposed and the Garbage Collector takes care of the rest.</span></div>
</div>
<p>Evo3d is powerful because of following solutions:<br />
 &#8211; It use linked list.<br />
 &#8211; It only z-sort meshes not polygons.<br />
 &#8211; The z-sort is based on <a href="http://en.wikipedia.org/wiki/Insertion_sort">Insertion Sorting</a>. Slightly modified from <a href="http://lab.polygonal.de/">Michael Baczynski</a>&#8216;s code.<br />
 &#8211; It uses the graphics.drawGraphicsData(graphicsData:Vector.IGraphicsData) method.</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="co1">// Here&#8217;s how to do Sphere. Following classes have much more parameters then here. This is only the sort way.</span></p>
<p><span class="kw2">var</span> <span class="kw3">camera</span>:<span class="kw3">Camera</span> = <span class="kw2">new</span> Camera3D<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> renderer:RendererBitmapData = <span class="kw2">new</span> RendererBitmapData<span class="br0">&#40;</span>bitmapdata, <span class="kw2">null</span>, 0&#215;000000<span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> engine3d:Engine3D = <span class="kw2">new</span> Engine3D<span class="br0">&#40;</span>renderer, <span class="kw3">camera</span><span class="br0">&#41;</span>;</p>
<p><span class="kw2">var</span> light:Light = engine3d.<span class="me1">light</span>;</p>
<p><span class="kw2">var</span> material:MaterialBitmap = <span class="kw2">new</span> MaterialBitmap<span class="br0">&#40;</span>frontTexture, backTexture<span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> shading:ShadingPhong = <span class="kw2">new</span> ShadingPhong<span class="br0">&#40;</span>0xFFFFFF, 0, BlendMode.<span class="me1">MULTIPLY</span><span class="br0">&#41;</span><br />
<span class="kw2">var</span> sphere:Sphere = <span class="kw2">new</span> Sphere<span class="br0">&#40;</span>material, 50, 16, 16, shading<span class="br0">&#41;</span>;</p>
<p>engine3d.<span class="me1">addMesh</span><span class="br0">&#40;</span>sphere<span class="br0">&#41;</span>;<br />
engine3d.<span class="me1">render</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p>I hope this will give you some ideas or help you some way. It would be awesome to see demo made with this stuff!<br />
I&#8217;m going to develop these more, but won&#8217;t start an open svn since I do not want this stuff to become a burden for me. It could feel like a job and I all ready have <a href="http://www.fwd.fi">one</a>. I think I&#8217;ll post some more libraries after next demo. Don&#8217;t report any bugs if you find them.</p>
<p>I have few new ideas about approaches to get that 3d much faster, but now I need a break.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/evoflash-severity-of-grey-sources/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

