<?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>Manuel&#039;s Coding Blog &#187; as3</title>
	<atom:link href="http://manuel.bit-fire.com/category/dev/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://manuel.bit-fire.com</link>
	<description></description>
	<lastBuildDate>Sun, 27 Jun 2010 12:35:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Compiz-like wobbling windows in AS3</title>
		<link>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/</link>
		<comments>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 19:01:09 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[hydra]]></category>
		<category><![CDATA[compiz]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[wobble]]></category>
		<category><![CDATA[wobbling]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/?p=128</guid>
		<description><![CDATA[This code was intended to be released back in October last year, but i never managed to do it since it needed some refactoring, some changes and had to be quite decent to present: then in November i got the chance to work with some very talented guys over at Jooce, in Paris, so i]]></description>
			<content:encoded><![CDATA[<p>This code was intended to be released back in October last year, but i never managed to do it since it needed some refactoring, some changes and had to be quite decent to present: then in November i got the chance to work with some very talented guys over at <a title="Jooce! Try it, it's seriously cool!" href="http://jooce.com/">Jooce</a>, in Paris, so i never got back to write something about it.<br />
<em> Btw, if you never tried Jooce then give it a try, it really deserves it!</em><br />
<span id="more-128"></span><br />
While there, i used portions of this code to derive something from it and while working on that for some time i realized some key points for optimizations but i&#8217;m not going to share more details with you about that, since the NDA i agreed to sign doesn&#8217;t allow me to do that: i&#8217;ve to say this version is therefore unoptimized and proof-of-concept, especially for the real window drawings: in fact, i just did some cleanup before packaging it, but since i don&#8217;t plan to put some time on it sooner, better i publish it as-is, or it will lie on my disk for the next few months for sure.</p>
<p>The idea was to build the foundation for a fancy, compositing-based windowing system: beside the actual implementation that&#8217;s basically just <em>wobbling</em> the current target, i&#8217;m sure you&#8217;ll be able to come up with other effects as well, but that&#8217;s not the real point.<br />
Setting aside the concrete animator implementation that would be better to be used as a base to derive some more abstract definitions from it, the architecture is quite open to new approaches and ideas, especially for the ultra-simple opengl-like interface i chosen for the rasterizer that let&#8217;s you prototype things quite fast:</p>
<pre>
<pre class="brush: cpp;">
package rasterizer
{
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import rasterizer.data.*;

	/**
	 * OpenGL-like interface for a generic rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer
	{
		function glTexture( tex: BitmapData, forceRecreate: Boolean = false, smooth: Boolean = false ): void;
		function glSetTarget( aTarget: Sprite ): void;

		function glBegin( rasterMode: int ): void;
		function glEnd(): void;

		function glPresent( aTarget: Sprite = null ): void;
	}

	/**
	 * OpenGL-like interface for a generic 2D rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer2D extends IRasterizer
	{
		function glVertex( vertex: Vertex2, uv: Vertex2 ): void;
	}

	/**
	 * OpenGL-like interface for a generic 3D rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer3D extends IRasterizer
	{
		function glVertex( vertex: Vertex3, uv: Vertex2 ): void;
	}
}
</pre>
</pre>
<p>Portions of the actual wobble animator took inspiration from the previous <a href="http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/">Magic Carpet</a> demo and some stuff i found on the net: if you come up with some other effects let me know, i&#8217;ll be happy to link back to them!<br />
Here you can play with a basic demo i setup to try it out or get the <a title="AS3 Wobbling windows demo" href="http://manuel.bit-fire.com/code/wobble_webdemo.zip">source code</a> to do your own experiments:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_wobble_demo_1369581032"
			class="flashmovie"
			width="100%"
			height="480">
	<param name="movie" value="http://manuel.bit-fire.com/code/wobble_demo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://manuel.bit-fire.com/code/wobble_demo.swf"
			name="fm_wobble_demo_1369581032"
			width="100%"
			height="480">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>An AS3 profiler</title>
		<link>http://manuel.bit-fire.com/2007/10/17/an-as3-profiler/</link>
		<comments>http://manuel.bit-fire.com/2007/10/17/an-as3-profiler/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 20:14:50 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiler]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/?p=72</guid>
		<description><![CDATA[NOTE This post has been previously published on 2007/Oct/17: due to my move to another server i&#8217;m now in the process to manually recover the comments for this article. Fixed! I&#8217;m currently working on an early-stage, more of a proof-of-concept thing, but i needed to know more about the code performances: googling for an ActionScript]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: line-through;"><em><strong>NOTE</strong><br />
This post has been previously published on 2007/Oct/17: due to my move to another server i&#8217;m now in the process to manually recover the comments for this article.</em></span><em> Fixed!</em></p>
<p>I&#8217;m currently working on an early-stage, more of a proof-of-concept thing, but i needed to know more about the code performances: googling for an ActionScript profiler just showed up <a title="ASProf" href="http://www.nochump.com/asprof/">ASProf</a>, an AS2 profiler. So i decided to port to AS3 the C++ profiler i wrote for Aqua, the cross-platform framework i was working on until April: the original C++ implementation has been developed after being inspired by an article of <a title="Steve Rabin" href="http://www.aiwisdom.com/home_webmaster.html">Steve Rabin</a> in the <a title="GPG#1" href="http://www.gameprogramminggems.com/">Game Programming Gems 1</a> book, that&#8217;s a nice one to have on the shelf together with some other great books of which i could post something about them later.<br />
It is always wise to remember that if you are serious about code profiling, you&#8217;ll be better to search for some professional tools: in the C++ arena my choice would be <a title="Compuware DevPartner" href="http://www.compuware.com/products/devpartner/visualc.htm">this one</a>, but if you plan to have lunch and dinner for the next couple of months give <a title="GlowCode" href="http://www.glowcode.com/summary.htm">Eletric&#8217;s one</a> a try, it really deserves a look.<br />
Unfortunately for the AS3 world, i just haven&#8217;t found anything really usable for it up to now, so i just thought to release it under a zlib/png license and some hints on how it works here.</p>
<pre class="brush: cpp;">
ProfilerConfig.Width = stage.stageWidth;
ProfilerConfig.ShowMinMax = true;
prof = new Profiler( 32 );
addChild( prof );
</pre>
<p><span id="more-72"></span></p>
<p>Setup some custom configuration parameters and then create a Profiler and don&#8217;t forget to add it to your local render queue: the Profiler its a Sprite and it will render the results right there, all you have to do now is to profile some code:</p>
<pre class="brush: cpp;">
var i: int = 0;
var it: int = 1000000;

prof.beginProfiling();

i = it;
prof.begin( &quot;fadd&quot; );
while( i-- ) { fRes += 1.; }
prof.end( &quot;fadd&quot; );

i = it;
prof.begin( &quot;iadd&quot; );
while( i-- ) { iRes += 1; }
prof.end( &quot;iadd&quot; );

i = it;
prof.begin( &quot;fsub&quot; );
while( i-- ) { fRes -= 1.; }
prof.end( &quot;fsub&quot; );

i = it;
prof.begin( &quot;isub&quot; );
while( i-- ) { iRes -= 1; }
prof.end( &quot;isub&quot; );

prof.endProfiling();
</pre>
<p>With another couple of lines of code you&#8217;ll end up with something like this:</p>
<p><a href="http://manuel.bit-fire.com/wp-content/uploads/2008/09/profiler.png"><img class="alignnone size-medium wp-image-73" title="profiler" src="http://manuel.bit-fire.com/wp-content/uploads/2008/09/profiler.png" alt="" width="498" height="246" /></a></p>
<p>Cool graphing for your function-timing needs ;)<br />
And this is it!<br />
A thing i may point out is that you can always group code fragments belonging to your most logical schema by wrapping the same ProfileNode around the different fragments; here i&#8217;m grouping math operations by their type, just to keep the call-graph a little bit organized:</p>
<pre class="brush: cpp;">
var i: int = 0;
var it: int = 1000000;

prof.beginProfiling();

i = it;
prof.begin( &quot;float&quot;, true );
prof.begin( &quot;fadd&quot; );
while( i-- ) { fRes += 1.; }
prof.end( &quot;fadd&quot; );
prof.end( &quot;float&quot; );

i = it;
prof.begin( &quot;int&quot;, true );
prof.begin( &quot;iadd&quot; );
while( i-- ) { iRes += 1; }
prof.end( &quot;iadd&quot; );
prof.end( &quot;int&quot; );

i = it;
prof.begin( &quot;float&quot;, true );
prof.begin( &quot;fsub&quot; );
while( i-- ) { fRes -= 1.; }
prof.end( &quot;fsub&quot; );
prof.end( &quot;float&quot; );

i = it;
prof.begin( &quot;int&quot;, true );
prof.begin( &quot;isub&quot; );
while( i-- ) { iRes -= 1; }
prof.end( &quot;isub&quot; );
prof.end( &quot;int&quot; );

prof.endProfiling();
</pre>
<p><a href="http://manuel.bit-fire.com/wp-content/uploads/2008/09/profiler_grouped.png"><img class="alignnone size-full wp-image-74" title="profiler_grouped" src="http://manuel.bit-fire.com/wp-content/uploads/2008/09/profiler_grouped.png" alt="" width="498" height="246" /></a></p>
<p>That&#8217;s all there is to it, hope it will be useful!<br />
Grab the Profiler <a href="http://manuel.bit-fire.com/code/as3_profiler.zip">here</a> and take a look at the <a href="http://manuel.bit-fire.com/code/as3_profiler_demo.as">demo code</a> used for this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/10/17/an-as3-profiler/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Hydra considerations</title>
		<link>http://manuel.bit-fire.com/2007/10/03/hydra-considerations/</link>
		<comments>http://manuel.bit-fire.com/2007/10/03/hydra-considerations/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 15:32:44 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[hydra]]></category>
		<category><![CDATA[astro]]></category>
		<category><![CDATA[kernel filters]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/10/03/hydra-considerations/</guid>
		<description><![CDATA[While experimenting with the AIF toolkit i noticed some glitches that could be taken into consideration by the AIF team before going final with the release: it seems that image-type function parameters are bound to the selected images according to their alphabetical order, instead of the natural user-defined one: for instance, create a new kernel]]></description>
			<content:encoded><![CDATA[<p>While experimenting with the AIF toolkit i noticed some glitches that could be taken into consideration by the AIF team before going final with the release:</p>
<ul>
<li> it seems that image-type function parameters are bound to the selected images according to their alphabetical order, instead of the natural user-defined one: for instance, create a new kernel as <a href="http://manuel.bit-fire.com/code/testfilter.hydra">here</a>, select two images and refresh; you should be now looking at the image you loaded via &#8220;Load Image 2&#8230;&#8221;: now rename &#8220;in image4 srca&#8221; to be &#8220;in image4 srcc&#8221; and refresh. Wrongly, you are now looking at the first image</li>
<li>the GUI doesn&#8217;t release cpu/gpu resources while minimized in order to relieve the machine from the rendering process</li>
</ul>
<p>Aside that, i&#8217;m looking forward to try all this cool stuff with <a href="http://labs.adobe.com/wiki/index.php/Astro">Astro</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/10/03/hydra-considerations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Player v9.0.60.184</title>
		<link>http://manuel.bit-fire.com/2007/08/21/flash-player-v9060184/</link>
		<comments>http://manuel.bit-fire.com/2007/08/21/flash-player-v9060184/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 21:15:48 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/08/21/flash-player-v9060184/</guid>
		<description><![CDATA[It seems that with the r60.184 version the vertical bar thing went away, anyway still remains that very new singularity ;)]]></description>
			<content:encoded><![CDATA[<p>It seems that with the r60.184 version the vertical bar thing went away, anyway still remains <a href="http://manuel.bit-fire.com/2007/08/20/noticeable-difference/">that very new</a> singularity ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/08/21/flash-player-v9060184/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Noticeable difference</title>
		<link>http://manuel.bit-fire.com/2007/08/20/noticeable-difference/</link>
		<comments>http://manuel.bit-fire.com/2007/08/20/noticeable-difference/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 22:42:09 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[flash player problem]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/08/20/noticeable-difference/</guid>
		<description><![CDATA[I haven&#8217;t had much time to test things out, but i managed to put together an ultra simple example on how 9.0.47 and 9.0.60.120 perform differently. This is the original image i&#8217;ve used to setup things: Here is the difference in rendering between Flash Player versions (image): I have no way to tell if it]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t had much time to test things out, but i managed to put together an ultra simple example on how 9.0.47 and 9.0.60.120 perform differently. This is the original image i&#8217;ve used to setup things:</p>
<p><a title="Original image" href="http://manuel.bit-fire.com/wp-content/uploads/2007/08/f4f.jpg"><img src="http://manuel.bit-fire.com/wp-content/uploads/2007/08/f4f.jpg" alt="Original image" /></a></p>
<p><span id="more-51"></span>Here is the difference in rendering between Flash Player versions (image):</p>
<p><a title="Differences" href="http://manuel.bit-fire.com/wp-content/uploads/2007/08/vm_diff.png"><img src="http://manuel.bit-fire.com/wp-content/uploads/2007/08/vm_diff.png" alt="Differences" /></a></p>
<p>I have no way to tell if it is the cause of the singularities i talked about in my previous posts (vertical bar / mid-height correct), nevertheless they perform differently.<br />
Anyone can confirm me this behavior?</p>
<p>Demo (swf):</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bmptest_354900466"
			class="flashmovie"
			width="150"
			height="120">
	<param name="movie" value="http://manuel.bit-fire.com/wp-content/uploads/2007/08/bmptest.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://manuel.bit-fire.com/wp-content/uploads/2007/08/bmptest.swf"
			name="fm_bmptest_354900466"
			width="150"
			height="120">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><a title="Bitmap test" href="http://manuel.bit-fire.com/wp-content/uploads/2007/08/bmptest.zip">Sources</a></p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/08/20/noticeable-difference/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Player v9.0.60.120 issues</title>
		<link>http://manuel.bit-fire.com/2007/08/14/flash-player-v9060120-issues/</link>
		<comments>http://manuel.bit-fire.com/2007/08/14/flash-player-v9060120-issues/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 21:18:49 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/08/14/flash-player-v9060120-issues/</guid>
		<description><![CDATA[I&#8217;m trying to get a clue of that vertical bar and it just seems very closely related to how the BitmapData&#8217;s draw() method internally works: for instance, if you have the source at hand, at line 67 of the PostProcessor.as file there is the line: ppbmpData.draw( source, new Matrix( .5, 0, 0, .5 ), null,]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to get a clue of that vertical bar and it just seems very closely related to how the BitmapData&#8217;s <em>draw()</em> method internally works: for instance, if you have the source at hand, at line 67 of the PostProcessor.as file there is the line:</p>
<pre class="brush: cpp;">
ppbmpData.draw( source, new Matrix( .5, 0, 0, .5 ), null, BlendMode.NORMAL );
</pre>
<p>The <em>ppMatrix</em> is the precomputed transformation matrix and, by changing that with the following, the bar will go away and it won&#8217;t crash the VM anymore:</p>
<pre class="brush: cpp;">
ppbmpData.draw( source, new Matrix( .501, 0, 0, .501 ), null, BlendMode.NORMAL );
</pre>
<p>Since i do not think a mere transformation operation can be SO wrong, i&#8217;m trying to extrapolate the smallest context into which the problem can be reproduced: so far i also noticed i can get very different results between Flash Player v9.0.47 and v9.0.60.120 by changing the code in order to produce a predictable result.<br />
In other words, i got the expected result in v9.0.47 but only the top-most <em>output_height / 2</em> portion is correct in v9.0.60.120: i&#8217;m not sure if that can be related to multi-threaded optimizations in the Flash Player since by changing the process&#8217; affinity mask seems to affect framerate and flickering only&#8230; bah! I have to dig some more&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/08/14/flash-player-v9060120-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Carpet&#8217;s sources</title>
		<link>http://manuel.bit-fire.com/2007/08/11/carpets-sources/</link>
		<comments>http://manuel.bit-fire.com/2007/08/11/carpets-sources/#comments</comments>
		<pubDate>Sat, 11 Aug 2007 15:20:48 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[bitmapfilter]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[flash 9]]></category>
		<category><![CDATA[mouseevent]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/08/11/carpets-sources/</guid>
		<description><![CDATA[Here is the source code for the Magic Carpet demo, just unpack it in your project directory of choice and import the project in Flex Builder, making sure to resolve the dependancies as it makes use of the following packages: PaperVision3D in its head revision; ASWing in its 1.0 A3 Flex compiler release; APE in]]></description>
			<content:encoded><![CDATA[<p>Here is the source code for the Magic Carpet demo, just unpack it in your project directory of choice and import the project in Flex Builder, making sure to resolve the dependancies as it makes use of the following packages:</p>
<ul>
<li>PaperVision3D in its <a href="http://papervision3d.googlecode.com/svn/trunk">head revision</a>;</li>
<li>ASWing in its <a href="http://code.google.com/p/aswing/downloads/list">1.0 A3 Flex compiler</a> release;</li>
<li><a href="http://www.cove.org/ape/">APE</a> in its v0.45 alpha release (provided w/ modifications);</li>
</ul>
<p>Let me explain the modifications in APE: i just wanted the engine to perform the timestep in a fixed fashion, so i initially modified it to accept a value, expressed in Hz, that represents the integrator&#8217;s timestep to be used, this way no matter if different machines have different framerates, animating will be the same everywhere.<br />
<span id="more-48"></span><br />
Then i was in need to rebuild the mesh at runtime since i wanted to be able to define tesselation and spacing directly from the UI: by trying to modify the values i got huge slowdowns and hangs that i have no clue of what that was, until later on i realized that APE was creating and attaching hundred of Sprite objects to its container. I tried to use a NullSprite object since i thought it would be ok to provide a reference to a common null-painter object, but that won&#8217;t did the trick, so i just settled things once and for all and removed most of the &#8220;presentation&#8221; logic in it as also i really had no need to have Sprite objects instanced and added for every particle and spring.</p>
<p>Download <a title="Magic Carpet v1.0b5 src" href="http://manuel.bit-fire.com/wp-content/uploads/2007/08/magiccarpet_v10b5.zip">Magic Carpet v1.0b5 src</a></p>
<p>*UPDATE*<br />
I uploaded a video on YouTube if you just want to take a look at it:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_HUtjKIuauMk_607919876"
			class="flashmovie"
			width="410"
			height="330">
	<param name="movie" value="http://www.youtube.com/v/HUtjKIuauMk" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.youtube.com/v/HUtjKIuauMk"
			name="fm_HUtjKIuauMk_607919876"
			width="410"
			height="330">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/08/11/carpets-sources/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>The Magic Carpet</title>
		<link>http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/</link>
		<comments>http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 18:26:59 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[bitmapfilter]]></category>
		<category><![CDATA[carpet]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[flash 9]]></category>
		<category><![CDATA[magic]]></category>
		<category><![CDATA[mouseevent]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/</guid>
		<description><![CDATA[&#62;&#62; Looking for the source code? Just go the next post here&#60;&#60; I managed to have some time to put together the simulation i was talking about last week: roughly based on a &#8220;Flade&#8221; (now APE) demo of that time, it makes use of APE for the physics and Papervision3D for the rasterization process. Actually,]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">&gt;&gt; Looking for the source code? Just go the next post <a href="http://manuel.bit-fire.com/2007/08/11/carpets-sources/">here</a>&lt;&lt;</span></p>
<p>I managed to have some time to put together the simulation i was talking about last week: roughly based on a &#8220;Flade&#8221; (now <a title="Actionscript Physics Engine" href="http://www.cove.org/ape/">APE</a>) demo of that time, it makes use of APE for the physics and <a title="Papervision 3D" href="http://www.papervision3d.org/">Papervision3D</a> for the rasterization process.<br />
Actually, using PV3D for merely rasterizing polygons its obviously an ugly solution if you, like me, don&#8217;t need all the scene management and just need to stretch bitmaps around: the real reason behind that choice is simply i was curious to see (1) how PV3D performed in a similar situation and (2) how to be able to bind APE and PV3D together.<br />
Anyway, just modelling and simulating the carpet wasn&#8217;t enough: the motion were great and performing quite well, but it was lacking completely the sense and taste of realism one would expect from such a scene and the particular type of motion one can interact with.<br />
I started by adding a (really) fake shadow that i&#8217;m too lazy to change and, since then, i liked the idea and adding a reflection was the next logical step for that context: it was still lacking some motion &#8220;feeling&#8221; so i also tried to mimic a directional blur simply by programmatically reducing the amount of blur on the slowest x-y direction.</p>
<p><span id="more-46"></span> I stopped experimenting with the blur thing, but i think it could be somewhat enhanced: i was thinking about a 3&#215;3 / 5&#215;5 kernel convolution filter in order to enhance angular motion, but i really have no time to try this out&#8230; do you know if this has been already attempted before?<br />
Anyway, beside having a carpet pinned in a void chamber, although funny and nice to interact with, the scene lighting and colors weren&#8217;t so exciting, so i decided to play with bitmaps and filters with realtime compositing and post-processing in mind, eventually ending up with a bloom-like filter that seems to be able to enhance the imagery quite well.</p>
<p>The UI will permit to adjust the values of the simulation, output, effects and post-processing: since the computations can be really heavy and stopping the VM from working, an automatic adjustment of the physics integration timestep is enabled by default and it will look green/red when working for you, meaning respectively it&#8217;s raising/lowering the timestep.</p>
<p>During the development i&#8217;ve tried different versions of the Flash Player and here are the results:</p>
<p>- <strong>9.0.45</strong> &#8211; <strong>9.0.47</strong>: on my machine i got something like 50fps with the default settings, some glitches can occur when changing the &#8220;Simulation&#8221; tab&#8217;s settings and i rarely got a Flash Player crash;</p>
<p>- <strong>9.0.60.120</strong>: i got 60/65fps with default settings, no glitches occurs while modifying &#8220;Simulation&#8221; values and no crashes directly correlated with this have occured. There is a really odd behavior of the Flash Player btw, where a vertical band on the left can be seen when playing with the carpet smashing it from right to left: the vertical band&#8217;s width seems to be related to the position of the carpet but i&#8217;m still investigating that; playing with the carpet on the vertical band DOES hang the Flash Player. Hope to be able to tell more info on that: in the meantime, turning off the post-processing will prevent the problems from happening.</p>
<p>As a final note, i highly recommend to install the <a href="http://labs.adobe.com/downloads/flashplayer9.html">latest beta</a> of the Flash Player since the performance really got a boost.</p>
<p>Let me know how it works for you: also, i plan to release the source code for both the demo and my modified version of APE (to let it to work with a fixed timestep expressed in Hz) so i&#8217;ll update these pages pretty soon.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_magiccarpet_1350132343"
			class="flashmovie"
			width="400"
			height="600">
	<param name="movie" value="http://manuel.bit-fire.com/wp-content/uploads/2007/08/magiccarpet.swf" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://manuel.bit-fire.com/wp-content/uploads/2007/08/magiccarpet.swf"
			name="fm_magiccarpet_1350132343"
			width="400"
			height="600">
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
	</channel>
</rss>
