<?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>nulldesign // lars gerckens &#187; Source</title>
	<atom:link href="http://www.nulldesign.de/category/experiments/source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nulldesign.de</link>
	<description>blog &#38; portfolio</description>
	<lastBuildDate>Mon, 30 Jan 2012 21:39:51 +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>ND2D &#8211; Now with 50% more D (and some more features)</title>
		<link>http://www.nulldesign.de/2011/11/06/nd2d-now-with-50-more-d-and-some-more-features/</link>
		<comments>http://www.nulldesign.de/2011/11/06/nd2d-now-with-50-more-d-and-some-more-features/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 17:37:12 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Molehill / Stage3D]]></category>
		<category><![CDATA[ND2D]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Talk]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=707</guid>
		<description><![CDATA[I found some time to add a little bit more &#8220;D&#8221; to ND2D. Besides the regular &#8220;rotation&#8221; property which rotated around the z-axis, all nodes now have  rotationX, rotationY, rotationZ properties and are displayed via a perspective projection. It works similar to the Flash 10 2.5D API (Planes in space), could be useful for some &#8230; <a href="http://www.nulldesign.de/2011/11/06/nd2d-now-with-50-more-d-and-some-more-features/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I found some time to add a little bit more &#8220;D&#8221; to ND2D. Besides the regular &#8220;rotation&#8221; property which rotated around the z-axis, all nodes now have  rotationX, rotationY, rotationZ properties and are displayed via a perspective projection. It works similar to the Flash 10 2.5D API (Planes in space), could be useful for some fancy transition effects.</p>
<p><a href="http://www.nulldesign.de/nd2d/tests/3d_transforms.html"><img class="alignnone size-full wp-image-708" title="Bildschirmfoto 2011-11-06 um 18.23.32" src="http://www.nulldesign.de/wp-content/uploads/2011/11/Bildschirmfoto-2011-11-06-um-18.23.32.png" alt="" width="600" height="275" /></a></p>
<p>Second, I added a few properties to change the appearance of textures. You can strech textures now and define how they should be sampled. The API let&#8217;s you choose how the texture is filtered, if mipmapping should be used and how the mipmap filtering should be. I created four predefined quality settings: LOW, MED, HIGH and ULTRA. Have fun:</p>
<p><a href="http://www.nulldesign.de/nd2d/tests/texture_options.html"><img class="alignnone size-full wp-image-709" title="Bildschirmfoto 2011-11-06 um 18.28.03" src="http://www.nulldesign.de/wp-content/uploads/2011/11/Bildschirmfoto-2011-11-06-um-18.28.03.png" alt="" width="600" height="352" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2011/11/06/nd2d-now-with-50-more-d-and-some-more-features/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ND2D Postprocessing effects</title>
		<link>http://www.nulldesign.de/2011/09/08/nd2d-postprocessing-effects/</link>
		<comments>http://www.nulldesign.de/2011/09/08/nd2d-postprocessing-effects/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 15:43:34 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Molehill / Stage3D]]></category>
		<category><![CDATA[ND2D]]></category>
		<category><![CDATA[Pixelshader]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Talk]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=655</guid>
		<description><![CDATA[I never really introduced the TextureRenderer of ND2D and what possibilities you have, when using it. The TextureRenderer does what the name suggests: It renders a display object (Sprite2D, etc.) and all subsequent objects onto a Context3D texture. The cool thing is, that you are able to draw your entire scene to a (fullscreen) texture &#8230; <a href="http://www.nulldesign.de/2011/09/08/nd2d-postprocessing-effects/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I never really introduced the <a href="http://www.nulldesign.de/nd2d/docs/" target="_blank">TextureRenderer</a> of <a href="https://github.com/nulldesign/nd2d" target="_blank">ND2D</a> and what possibilities you have, when using it. The TextureRenderer does what the name suggests: It renders a display object (Sprite2D, etc.) and all subsequent objects onto a Context3D texture. The cool thing is, that you are able to draw your entire scene to a (fullscreen) texture and add some post processing effects, by writing a new material / shader and displaying it via a standard Sprite2D.</p>
<p>Here&#8217;s the plain scene without post processing:</p>
<p><img class="alignnone size-full wp-image-656" title="postprocessing1" src="http://www.nulldesign.de/wp-content/uploads/2011/09/postprocessing1.jpg" alt="" width="600" height="308" /></p>
<p>&#8230; and here with a small &#8220;dizzyness&#8221; post process shader:</p>
<p><img class="alignnone size-full wp-image-657" title="postprocessing2" src="http://www.nulldesign.de/wp-content/uploads/2011/09/postprocessing2.jpg" alt="" width="600" height="310" /></p>
<p>I&#8217;ve added this test to the <a href="https://github.com/nulldesign/nd2d/tree/master/examples/tests" target="_blank">examples</a> incluced in the <a href="https://github.com/nulldesign/nd2d" target="_blank">ND2D</a> sources. You can see the live running example <a href="http://nulldesign.de/nd2d/tests/" target="_blank">here</a> (test #18).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2011/09/08/nd2d-postprocessing-effects/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ND2D &#8211; Stage3D Masks</title>
		<link>http://www.nulldesign.de/2011/09/02/nd2d-stage3d-masks/</link>
		<comments>http://www.nulldesign.de/2011/09/02/nd2d-stage3d-masks/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 14:39:15 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Molehill / Stage3D]]></category>
		<category><![CDATA[ND2D]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=633</guid>
		<description><![CDATA[Another feature I really wanted to implement in ND2D were masks. Just like the setMask() method in flash. In Stage3D (OpenGL), there is no such thing as a mask. You can display textured triangles, that&#8217;s it, but you know that nearly everything is possible with a pixel shader. So let&#8217;s start: The idea of masking &#8230; <a href="http://www.nulldesign.de/2011/09/02/nd2d-stage3d-masks/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Another feature I really wanted to implement in <a href="https://github.com/nulldesign/nd2d" target="_blank">ND2D</a> were masks. Just like the setMask() method in flash. In Stage3D (OpenGL), there is no such thing as a mask. You can display textured triangles, that&#8217;s it, but you know that nearly everything is possible with a pixel shader. So let&#8217;s start:</p>
<p>The idea of masking in a fragment shader is to grab the pixel color of your texture, then grab the pixel color of your mask, multiply the two colors and display the result. But how do we find the correct pixel in the mask? Our task is to find the right UV coordinates for the mask texture.</p>
<p><img class="alignnone size-full wp-image-636" title="masking_uv" src="http://www.nulldesign.de/wp-content/uploads/2011/09/masking_uv.png" alt="" width="502" height="287" /></p>
<p>If you look at the above image, the mask is rotated and overlaps the sprite we want to mask. How do we find the correct pixel (UV coordinate) of the mask, that overlaps this orange pixel in the sprite? Somehow we have to map the position of the pixel in the sprite to the pixel in the mask and we can do that by transforming it between the different coordinate systems. In a vertex shader we calculate the final pixel positon from local space to world space. The idea is to map this pixel in world space back to the local coordinate system of the mask. This way it&#8217;s pretty easy to find the correct UV coordinates. Let&#8217;s do a simple actionscript test:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// this is the top right corner of our sprite quad.</span>
<span style="color: #000000; font-weight: bold;">var</span> v:Vector3D = <span style="color: #000000; font-weight: bold;">new</span> Vector3D<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">128</span>, -<span style="color: #cc66cc;">128</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// this is the sprites matrix, translated a bit</span>
<span style="color: #000000; font-weight: bold;">var</span> clipSpaceMatrix:Matrix3D = <span style="color: #000000; font-weight: bold;">new</span> Matrix3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
clipSpaceMatrix.<span style="color: #006600;">appendTranslation</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// this is the masks matrix, it's in the same position as the sprite</span>
<span style="color: #000000; font-weight: bold;">var</span> maskClipSpaceMatrix:Matrix3D = <span style="color: #000000; font-weight: bold;">new</span> Matrix3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
maskClipSpaceMatrix.<span style="color: #006600;">appendTranslation</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// this is the masks size</span>
<span style="color: #000000; font-weight: bold;">var</span> maskBitmap:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">256</span>, <span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// invert the matrix, because we want to map back from world space to local mask space</span>
maskClipSpaceMatrix.<span style="color: #006600;">invert</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// transform our vertex from local sprite space to world space</span>
v = clipSpaceMatrix.<span style="color: #006600;">transformVector</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#93;</span> moved to clipspace: Vector3D<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">228</span>, -<span style="color: #cc66cc;">128</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// transform world space vertex back to local mask space</span>
<span style="color: #808080; font-style: italic;">// the result is the same vector of course, because the positions of mask and sprite are equal</span>
v = maskClipSpaceMatrix.<span style="color: #006600;">transformVector</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#93;</span> moved to local mask <span style="color: #0066CC;">space</span>: Vector3D<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">128</span>, -<span style="color: #cc66cc;">128</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// calculate the uv coordinates from the local pixel position</span>
v = <span style="color: #000000; font-weight: bold;">new</span> Vector3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>v.<span style="color: #006600;">x</span> + <span style="color: #66cc66;">&#40;</span>maskBitmap.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> maskBitmap.<span style="color: #0066CC;">width</span>,
                 <span style="color: #66cc66;">&#40;</span>v.<span style="color: #006600;">y</span> + <span style="color: #66cc66;">&#40;</span>maskBitmap.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> maskBitmap.<span style="color: #0066CC;">height</span>,
                  <span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">1.0</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// the result is what we expect, the top right uv coordinate:</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#93;</span> local mask uv: Vector3D<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Porting this idea to a shader is pretty straight forward. Let&#8217;s code a PB3D Material Shader:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">void</span> evaluateVertex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
     interpolatedUV = float4<span style="color: #66cc66;">&#40;</span>uvCoord.<span style="color: #006600;">x</span> + uvOffset.<span style="color: #006600;">x</span>, uvCoord.<span style="color: #006600;">y</span> + uvOffset.<span style="color: #006600;">y</span>, <span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">0.0</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
     float4 worldSpacePos = float4<span style="color: #66cc66;">&#40;</span>vertexPos.<span style="color: #006600;">x</span>, vertexPos.<span style="color: #006600;">y</span>, <span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">1.0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> objectToClipSpaceTransform;
     <span style="color: #808080; font-style: italic;">// maskObjectToClipSpaceTransform is the invertex clipspace matrix of the mask</span>
     float4 localMaskSpacePos = worldSpacePos <span style="color: #66cc66;">*</span> maskObjectToClipSpaceTransform;
&nbsp;
     <span style="color: #808080; font-style: italic;">// halfMaskSize.xy is maskBitmap.width/height * 0.5 passed as a parameter</span>
     <span style="color: #808080; font-style: italic;">// invertedMaskSize.xy = 1.0 / maskBitmap.width/height passed as a parameter, because divisions are not properly working in the current pb3d release</span>
     interpolatedMaskUV = float4<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>localMaskSpacePos.<span style="color: #006600;">x</span> + halfMaskSize.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> invertedMaskSize.<span style="color: #006600;">x</span>,
                                 <span style="color: #66cc66;">&#40;</span>localMaskSpacePos.<span style="color: #006600;">y</span> + halfMaskSize.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> invertedMaskSize.<span style="color: #006600;">y</span>,
                                  <span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">0.0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">void</span> evaluateFragment<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    float4 texel = sample<span style="color: #66cc66;">&#40;</span>textureImage, float2<span style="color: #66cc66;">&#40;</span>interpolatedUV.<span style="color: #006600;">x</span>, interpolatedUV.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>, PB3D_2D <span style="color: #66cc66;">|</span> PB3D_MIPNEAREST <span style="color: #66cc66;">|</span> PB3D_CLAMP<span style="color: #66cc66;">&#41;</span>;
    float4 texel2 = sample<span style="color: #66cc66;">&#40;</span>textureMaskImage, float2<span style="color: #66cc66;">&#40;</span>interpolatedMaskUV.<span style="color: #006600;">x</span>, interpolatedMaskUV.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>, PB3D_2D <span style="color: #66cc66;">|</span> PB3D_MIPNEAREST <span style="color: #66cc66;">|</span> PB3D_CLAMP<span style="color: #66cc66;">&#41;</span>;
&nbsp;
    result = float4<span style="color: #66cc66;">&#40;</span>texel.<span style="color: #006600;">r</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">color</span>.<span style="color: #006600;">r</span> <span style="color: #66cc66;">*</span> texel2.<span style="color: #006600;">r</span>,
                    texel.<span style="color: #006600;">g</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">color</span>.<span style="color: #006600;">g</span> <span style="color: #66cc66;">*</span> texel2.<span style="color: #006600;">g</span>,
                    texel.<span style="color: #006600;">b</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">color</span>.<span style="color: #006600;">b</span> <span style="color: #66cc66;">*</span> texel2.<span style="color: #006600;">b</span>,
                    texel.<span style="color: #006600;">a</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">color</span>.<span style="color: #006600;">a</span> <span style="color: #66cc66;">*</span> texel2.<span style="color: #006600;">a</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>If you don&#8217;t want to use PixelBender3D and like to &#8216;torture&#8217; yourself with AGAL, you can write the same shader this way:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
vertex shader:
&nbsp;
vc0-vc3 = clipspace matrix of sprite
vc4-vc7 = inverted clipspace matrix of mask
vc8.xy = half mask width / height
vc8.zw = mask width / height
va0 = vertex
va1 = uv
*/</span>
&nbsp;
m44 vt0, va0, vc0           <span style="color: #808080; font-style: italic;">// vertex * clipspace</span>
m44 vt1, vt0, vc4           <span style="color: #808080; font-style: italic;">// clipspace to local pos in mask</span>
<span style="color: #0066CC;">add</span> vt1.<span style="color: #006600;">xy</span>, vt1.<span style="color: #006600;">xy</span>, vc8.<span style="color: #006600;">xy</span>  <span style="color: #808080; font-style: italic;">// add half masksize to local pos</span>
div vt1.<span style="color: #006600;">xy</span>, vt1.<span style="color: #006600;">xy</span>, vc8.<span style="color: #006600;">zw</span>  <span style="color: #808080; font-style: italic;">// local pos / masksize</span>
mov v0, va1                 <span style="color: #808080; font-style: italic;">// copy uv</span>
mov v1, vt1                 <span style="color: #808080; font-style: italic;">// copy mask uv</span>
mov op, vt0                 <span style="color: #808080; font-style: italic;">// output position</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
fragment shader:
*/</span>
&nbsp;
mov ft0, v0                                <span style="color: #808080; font-style: italic;">// get interpolated uv coords</span>
tex ft1, ft0, fs0 <span style="color: #66cc66;">&lt;</span>2d,clamp,linear,nomip<span style="color: #66cc66;">&gt;</span>  <span style="color: #808080; font-style: italic;">// sample texture</span>
mov ft2, v1                                <span style="color: #808080; font-style: italic;">// get interpolated uv coords for mask</span>
tex ft3, ft2, fs1 <span style="color: #66cc66;">&lt;</span>2d,clamp,linear,nomip<span style="color: #66cc66;">&gt;</span>  <span style="color: #808080; font-style: italic;">// sample mask</span>
mul ft1, ft1, ft3                          <span style="color: #808080; font-style: italic;">// mult mask color with tex color</span>
mov oc, ft1                                <span style="color: #808080; font-style: italic;">// output color</span></pre></div></div>

<p>The result is visible here: <a href="http://www.nulldesign.de/nd2d/tests/mask_alpha.html" target="_blank">ND2D &#8211; alpha masks</a> (Move your mouse over the crates). I added one more feature: You can set the alpha of a mask, that means that you can specify how much the mask affects the sprite. In the demo above the alpha fades from 0.0 to 1.0. Since we&#8217;re using all four color components in our calculations (r,g,b,a), we can not only mask the alpha, but all color channels. I don&#8217;t know if this it&#8217;s a &#8220;nice thing to have&#8221; or if it will get annoying when you use sprites as masks in your game and need to provide an extra image for that. Just let me know :) Here is the example: <a href="http://www.nulldesign.de/nd2d/tests/mask_color.html" target="_blank">ND2D &#8211; disco color masks</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2011/09/02/nd2d-stage3d-masks/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cocos2D Particle System Sources</title>
		<link>http://www.nulldesign.de/2011/03/21/cocos2d-particle-system-sources/</link>
		<comments>http://www.nulldesign.de/2011/03/21/cocos2d-particle-system-sources/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 20:34:18 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Cocos2D]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=504</guid>
		<description><![CDATA[Since I&#8217;m receiving questions about the particle system I used in my FluidToy 2 quite often lately, I thought I just release the sources here. The particle system is based on a CCNode and works similar to the existing Cocos2D particle systems. The main difference is, that you can control the position and velocity of &#8230; <a href="http://www.nulldesign.de/2011/03/21/cocos2d-particle-system-sources/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m receiving questions about the particle system I used in my <a href="http://www.nulldesign.de/fluidtoy2/" target="_blank">FluidToy 2</a> quite often lately, I thought I just release the sources here.</p>
<p>The particle system is based on a CCNode and works similar to the existing <a href="http://www.cocos2d-iphone.org/">Cocos2D</a> particle systems. The main difference is, that you can control the position and velocity of each particle. Please note that this system is not very optimized and lacks in flexibility since I just built it for <a href="http://www.nulldesign.de/fluidtoy2/" target="_blank">FluidToy 2</a> and it was never meant to be more general. In other words: The code is a bit dirty! But feel free to play around with it, modify it and make use of it (and let me know what you&#8217;re making out of it).<br/><br/>There are two different systems: The SimpleParticleSystem, which draws points of any size or a point sprite using a texture. The second one is a LineParticleSystem, which will draw line particles. If you initialize the system with a size of 1000, you&#8217;ll have 500 lines, because a line consists out of 2 points (Wow, you never imagined that, did you? ;)). So if you loop through the particles, be sure to move only every second particle, the other one will follow with a small delay.</p>
<p><a href="http://www.nulldesign.de/wp-content/uploads/2011/03/Cocos2DSimpleParticleSystem.zip">Download: Cocos2DSimpleParticleSystem</a></p>
<p>It works like every other CCNode:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">particles <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SimpleParticleSystem node<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>particles initialize<span style="color: #002200;">:</span> <span style="color: #2400d9;">1000</span> width<span style="color: #002200;">:</span> size.width height<span style="color: #002200;">:</span> size.height<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>particles setTextureByString<span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;particle_small.png&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span> particles<span style="color: #002200;">&#93;</span>;
&nbsp;
Loop through particles<span style="color: #002200;">:</span>
&nbsp;
<span style="color: #a61390;">while</span><span style="color: #002200;">&#40;</span>count &lt; particles.particleCount<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
   p <span style="color: #002200;">=</span> <span style="color: #002200;">&amp;</span>particleAr<span style="color: #002200;">&#91;</span>count<span style="color: #002200;">&#93;</span>;
   p<span style="color: #002200;">-</span>&gt;dir.x <span style="color: #002200;">+=</span> CCRANDOM_MINUS1_1<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
   p<span style="color: #002200;">-</span>&gt;dir.y <span style="color: #002200;">+=</span> CCRANDOM_MINUS1_1<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
   <span style="color: #002200;">++</span>count;
   ...
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2011/03/21/cocos2d-particle-system-sources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New example by accident</title>
		<link>http://www.nulldesign.de/2009/02/18/new-example-by-accident/</link>
		<comments>http://www.nulldesign.de/2009/02/18/new-example-by-accident/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 22:39:56 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=235</guid>
		<description><![CDATA[This is what came out as I was testing to implement a custom renderer in my engine (The sources are available in the google code repository). (space = fullscreen = more fun)]]></description>
			<content:encoded><![CDATA[<p>This is what came out as I was testing to implement a custom renderer in my engine (The sources are available in the <a href="http://code.google.com/p/nd3d/" target="_blank">google code repository</a>).</p>
<p style="text-align: center;"><a href="http://www.nulldesign.de/exp/expviewer.php?file=wobbly.swf&amp;width=600&amp;height=400"><img class="aligncenter" src="http://www.nulldesign.de/exp/wobbly.jpg" alt="" width="480" height="333" /><br />
</a><br />
(space = fullscreen = more fun)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2009/02/18/new-example-by-accident/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>F10 Astro Blackhole</title>
		<link>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/</link>
		<comments>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 08:31:36 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=182</guid>
		<description><![CDATA[The Flash 10 beta player is out for a while and I found a few minutes to try out the new native 3D effects. You can get quite nice and fast results out of the new API if you only want to display flat 2D planes in 3D-space: (Space = fullscreen, Download source, Flash Player &#8230; <a href="http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://labs.adobe.com/technologies/flashplayer10/">Flash 10 beta player</a> is out for a while and I found a few minutes to try out the new native 3D effects. You can get quite nice and fast results out of the new API if you only want to display flat 2D planes in 3D-space:</p>
<p style="text-align: center;"><a href="http://www.nulldesign.de/exp/expviewer.php?file=f10_planets.swf&amp;width=600&amp;height=450"><img class="aligncenter" src="http://www.nulldesign.de/exp/f10_planets.jpg" alt="" width="480" height="305" /></a><br />
(Space = fullscreen, <a href="http://www.nulldesign.de/exp/f10_planets.zip">Download source</a>, Flash Player 10 needed)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ND3D engine goes google.code</title>
		<link>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/</link>
		<comments>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 10:30:45 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=105</guid>
		<description><![CDATA[Good news everyone! I packed everything together, cleaned up a bit and created a google.code project for my 3D engine. Since it became popular under the name &#8216;nulldesign&#8217;s 3d engine&#8217; I call it ND3D from now on ;). I will post additional infos, more examples and future developments here in my blog and on the &#8230; <a href="http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Good news everyone! I packed everything together, cleaned up a bit and created a <a href="http://code.google.com/p/nd3d/">google.code project</a> for my 3D engine. Since it became popular under the name &#8216;nulldesign&#8217;s 3d engine&#8217; I call it ND3D from now on ;). I will post additional infos, more examples and future developments <a href="http://www.nulldesign.de/nd3d-as3-3d-engine/">here</a> in my blog and on the project page. So long&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>3d engine website</title>
		<link>http://www.nulldesign.de/2008/07/11/3d-engine-website/</link>
		<comments>http://www.nulldesign.de/2008/07/11/3d-engine-website/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 10:41:32 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Talk]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=71</guid>
		<description><![CDATA[I just got a mail from Mr.Doob, he made a 3d line clock for the D///FEST 2008 website with my 3d engine. You can download the sources on the website: Btw.: I&#8217;m planning to put the engine up to google code and continue working on it. It will stay lightweight, small and simple!]]></description>
			<content:encoded><![CDATA[<p>I just got a mail from <a href="http://mrdoob.com/blog/" target="_blank">Mr.Doob</a>, he made a 3d line clock for the <a href="http://d3fest.org/2008/" target="_blank">D///FEST 2008</a> website with my <a href="http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/" target="_blank">3d engine</a>. You can download the sources on the website:</p>
<p><a href="http://d3fest.org/2008/" target="_blank"><img class="alignnone size-full wp-image-72" title="d3fest" src="http://www.nulldesign.de/wp-content/uploads/2008/07/d3fest.jpg" alt="" width="500" height="237" /></a></p>
<p>Btw.: I&#8217;m planning to put the engine up to google code and continue working on it. It will stay lightweight, small and simple!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/07/11/3d-engine-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>3D Engine Sources + Examples</title>
		<link>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/</link>
		<comments>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 12:31:21 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=61</guid>
		<description><![CDATA[About some time ago I started to code my own 3D engine in flash. Derived from a small AS2 project, I challenged myself to built my own flash 3D engine. So I took out my good old Actionscript Animation Book and opened the 3D chapter. Very soon I could move a cube around. A few &#8230; <a href="http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>About some time ago I started to code my own 3D engine in flash. Derived from a small AS2 project, I challenged myself to built my own flash 3D engine. So I took out my good old <a href="http://www.friendsofed.com/book.html?isbn=1590595181" target="_blank">Actionscript Animation Book</a> and opened the 3D chapter. Very soon I could move a <a href="http://www.nulldesign.de/2006/11/10/solid3dengine/" target="_blank">cube</a> around. A few pages later I learned how to implement simple <a href="http://www.nulldesign.de/exp/expviewer.php?file=lighting_test.swf&amp;width=800&amp;height=400">dynamic lighting</a>. The next challenge was to get texture mapping to work. Since flash still can&#8217;t distort images, you need a workaround. After I found these great examples: <a href="http://www.sebleedelisle.com/?page_id=7" target="_blank">Seb Lee-Delisle&#8217;s flash texture maps</a> and <a href="http://session.andre-michelle.com/w3d/" target="_blank">Andre Michelle&#8217;s texture examples</a> it was done. Somewhere inbetween I switched to AS3, which was quickly done. Meanwhile <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> became very popular and I thought it didn&#8217;t make sense to continue evolving my engine. But since I came so far, I needed to find out how to implement a few effects like <a href="http://www.nulldesign.de/exp/expviewer.php?file=3d_blur.swf&amp;width=800&amp;height=400">depth of field</a> or <a href="http://www.nulldesign.de/exp/expviewer.php?file=f9_3d_additive_cubes.swf&amp;width=800&amp;height=400">additive rendering</a> ;)</p>
<p style="text-align: center;"><img src="http://www.nulldesign.de/exp/3dengine_samples.jpg" alt="" width="472" height="473" /></p>
<p>My engine shouldn&#8217;t and doesn&#8217;t compete with <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> or <a href="http://www.flashsandy.org/blog/" target="_blank">Sandy3D</a>, nor it has a very user-friendly API, no stunning effects or animation support, but I learned a lot while building it, understanding 3D to 2D rendering, optimizing the code for a few ms of extra speed (AS3 rocks!) or challenge problems with 3D rotations like <a href="http://en.wikipedia.org/wiki/Gimbal_Lock" target="_blank">gimbal lock</a> and their solutions: <a href="http://en.wikipedia.org/wiki/Quaternion" target="_blank">quaternions</a>. It&#8217;s just another 3D flash engine, at least I can say: I made it! ;)</p>
<p>It&#8217;s undocumented, there&#8217;s still a lot of work to do and it doesn&#8217;t have a cool name , but if you want to play around with it or just take a look how I set up this and that, feel free to download the <a onclick="urchinTracker('3dengine_nulldesign.zip')" href="http://www.nulldesign.de/nd3d-as3-3d-engine/">sources</a> (yes, the <a href="http://www.nulldesign.de/exp/expviewer.php?file=3dribbon.swf&amp;width=700&amp;height=400">3D ribbon</a> example is included). And I&#8217;m always interested in what you think about it, so drop a comment or mail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>War of the fireflies</title>
		<link>http://www.nulldesign.de/2008/01/21/war-of-the-fireflies/</link>
		<comments>http://www.nulldesign.de/2008/01/21/war-of-the-fireflies/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 12:00:01 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Simulations]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2008/01/21/war-of-the-fireflies/</guid>
		<description><![CDATA[Derived from one of my older experiments: Three different populations of fireflies are fighting for their survival. If a firefly encounters an enemy fly, it tries to convert it to their tribe. The converted fly looses lifepoints and eventually dies during conversion. For the &#8220;collision logic&#8221;, I used a slightly modified version of Grant Skinners &#8230; <a href="http://www.nulldesign.de/2008/01/21/war-of-the-fireflies/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Derived from one of my <a href="http://www.nulldesign.de/2006/11/23/f9-particles/" target="_blank">older experiments:</a> Three different populations of fireflies are fighting for their survival. If a firefly encounters an enemy fly, it tries to convert it to their tribe. The converted fly looses lifepoints and eventually dies during conversion. For the &#8220;collision logic&#8221;, I used a slightly modified version of Grant Skinners <a href="http://www.gskinner.com/blog/archives/2008/01/proximitymanage.html" target="_blank">AS3 Proximitymanager.</a> You can download the source and play around with it <a href="http://www.nulldesign.de/exp/f9_particle2.zip" onclick="urchinTracker('f9_particle2.zip')">here</a> (but don&#8217;t expect beautiful code ;)).</p>
<p align="center"><a href="http://www.nulldesign.de/exp/expviewer.php?file=f9_particle2.swf&amp;width=500&amp;height=400" target="_blank"><img src="http://www.nulldesign.de/exp/f9_particle2.jpg" height="252" width="480" /><br />
</a>(Space = fullscreen, as usual)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/01/21/war-of-the-fireflies/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>F9 Particles</title>
		<link>http://www.nulldesign.de/2006/11/23/f9-particles/</link>
		<comments>http://www.nulldesign.de/2006/11/23/f9-particles/#comments</comments>
		<pubDate>Thu, 23 Nov 2006 15:40:24 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2006/11/23/f9-particles/</guid>
		<description><![CDATA[Sources available here. AS3 particle system. 5000 particles with random motion based on a noisemap (Press any key to view the map) Click to change to another random map. Launch!]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><img src="http://www.nulldesign.de/exp/f9_particle.jpg" height="270" width="480" /><br />Sources available <a href="http://www.nulldesign.de/exp/f9_particle.zip">here</a>.</p>
<p>AS3 particle system. 5000 particles with random motion based on a noisemap (Press any key to view the map) Click to change to another random map. <a href="http://www.nulldesign.de/exp/expviewer.php?file=f9_particle.swf&amp;width=600&amp;height=350" target="_blank">Launch!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2006/11/23/f9-particles/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

