<?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>*drawlogic &#187; ALGORITHM</title>
	<atom:link href="http://drawlogic.com/category/algorithm/feed/" rel="self" type="application/rss+xml" />
	<link>http://drawlogic.com</link>
	<description>interactive and game development technologies for the web - flash, flex, unity3d, silverlight, javascript</description>
	<lastBuildDate>Thu, 22 Dec 2011 21:55:20 +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>AS3 Augmented Reality in Flash and Papervision 3D and FLARToolKit</title>
		<link>http://drawlogic.com/2008/11/17/as3-augmented-reality-in-flash-and-papervision-3d-flartoolkit/</link>
		<comments>http://drawlogic.com/2008/11/17/as3-augmented-reality-in-flash-and-papervision-3d-flartoolkit/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 20:50:29 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[EFFECTS]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[MOTION]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PAPERVISION]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[VIDEO]]></category>
		<category><![CDATA[VISUALIZATION]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[ar]]></category>
		<category><![CDATA[augmented]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[reality]]></category>

		<guid isPermaLink="false">http://drawlogic.com/?p=277</guid>
		<description><![CDATA[Augmented reality is a very cool technology.  It is the star wars holograms that we always want, it is playing a game that maps out the physical world mixed with virtual assets, it is straight up cool. The FLARToolKit is doing some of this cool in Flash.  This little toolkit is pretty sweet mapping points [...]]]></description>
			<content:encoded><![CDATA[<p>Augmented reality is a very cool technology.  It is the star wars holograms that we always want, it is playing a game that maps out the physical world mixed with virtual assets, it is straight up cool.</p>
<p>The <a title="FLARToolKit" href="http://www.libspark.org/wiki/saqoosha/FLARToolKit" target="_blank">FLARToolKit</a> is doing some of this cool in Flash.  This little toolkit is pretty sweet mapping points and sets of points to patterns, colors or other visual queues that technology can latch onto.  Combine this with a webcam and you have some pretty cool AR.</p>
<p><span id="more-277"></span></p>
<p><object width="540" height="405" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=1634128&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed width="540" height="405" type="application/x-shockwave-flash" src="http://vimeo.com/moogaloop.swf?clip_id=1634128&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowfullscreen="true" allowscriptaccess="always" /></object></p>
<p><a href="http://vimeo.com/1634128">Desktop Fireworks</a> from <a href="http://vimeo.com/saqoosha">Saqoosha</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Found via <a href="http://www.todayandtomorrow.net/2008/09/01/desktop-fireworks/" target="_blank">today and tomorrow</a>:</p>
<blockquote><p>I’ve been following the development of <a title="FLARToolKit" href="http://www.libspark.org/wiki/saqoosha/FLARToolKit" target="_blank">FLARToolKit</a> for some time now and it’s getting more interesting day by day. What it is? FLARToolKit is a Flash Actionscript port of <a title="ARToolKit" href="http://www.hitl.washington.edu/artoolkit/" target="_blank">ARToolKit</a>, a software library for building Augmented Reality applications. Huh? Maybe you’ve seen some really cool <a title="Augmented Reality @ YouTube" href="http://www.youtube.com/results?search_query=augmented+reality&amp;search_type=&amp;aq=0&amp;oq=augmented+r" target="_blank">Augmented Reality videos</a> before. The FLARToolKit will bring all of this to your webbrowser when you have a webcam and a recent Flash Player.</p>
<p>This is one of the most exciting Flash things I’ve seen for a while now. <a title="Saqoosha" href="http://saqoosha.net/" target="_blank">Saqoosha</a>, a Japanese Flash developer, made this little demo: <a title="Desktop Fireworks by Saqoosha" href="http://translate.google.com/translate?hl=en&amp;sl=ja&amp;u=http://saqoosha.net/2008/08/31/1221/" target="_blank">Desktop Fireworks</a>. You will need a the Flash Player 9, a webcam and you’ll need to print out <a title="Hanabi Marker" href="http://saqoosha.net/lab/fireworks/hanabi-marker.pdf" target="_blank">this marker</a>. I’ve already did some tests together with Papervision3D and I can say we’ll probably see more of this soon. This is Flash at it’s best baby!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/11/17/as3-augmented-reality-in-flash-and-papervision-3d-flartoolkit/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Google Tech Talk: Simple interactive 3D modeling for all &#8211; VideoTrace</title>
		<link>http://drawlogic.com/2008/06/21/google-tech-talk-simple-interactive-3d-modeling-for-all/</link>
		<comments>http://drawlogic.com/2008/06/21/google-tech-talk-simple-interactive-3d-modeling-for-all/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 04:02:50 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[3D ENGINES]]></category>
		<category><![CDATA[3DSMAX]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[DYNAMIC]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[INTERACTIVE]]></category>
		<category><![CDATA[INTERFACE]]></category>
		<category><![CDATA[MARKET]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[VIDEO]]></category>
		<category><![CDATA[VISUALIZATION]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[real]]></category>
		<category><![CDATA[trace]]></category>
		<category><![CDATA[tracker]]></category>
		<category><![CDATA[VideoTrace]]></category>
		<category><![CDATA[virtual]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=215</guid>
		<description><![CDATA[[youtube]http://www.youtube.com/watch?v=YEM-XAeY4K0[/youtube] 3D models from basic video&#8230; This can be huge in all sorts of ways.  For exponential growth you need to go virtual. This is a technology called VideoTrace from Australia The Siggraph paper describing VideoTrace is available here (pdf 6MB) Larger videos available here, with a more compressed version here.]]></description>
			<content:encoded><![CDATA[<p>[youtube]http://www.youtube.com/watch?v=YEM-XAeY4K0[/youtube]</p>
<p>3D models from basic video&#8230; This can be huge in all sorts of ways.  For exponential growth you need to go virtual.</p>
<ul>
<li>This is a technology called <strong><a href="http://www.acvt.com.au/research/videotrace/" target="_blank">VideoTrace from Australia</a> </strong></li>
<li>The Siggraph paper describing VideoTrace is available <a href="http://www.acvt.com.au/research/videotrace/Siggraph07-van_den_hengel.pdf">here</a> <span class="linkinfo">(pdf 6MB)</span></li>
<li>Larger videos available <a href="http://www.adelaide.edu.au/static/acvt/VideoTrace2_msmpeg4v2.avi">here</a>, with a more compressed version <a href="http://www.adelaide.edu.au/static/acvt/VideoTrace2_smallmsmpeg4v2.avi">here</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/06/21/google-tech-talk-simple-interactive-3d-modeling-for-all/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.adelaide.edu.au/static/acvt/VideoTrace2_smallmsmpeg4v2.avi" length="21874598" type="video/x-msvideo" />
<enclosure url="http://www.adelaide.edu.au/static/acvt/VideoTrace2_msmpeg4v2.avi" length="79055142" type="video/x-msvideo" />
		</item>
		<item>
		<title>as3Query &#8211; Actionscript Port of jQuery</title>
		<link>http://drawlogic.com/2008/04/24/as3query-actionscript-port-of-jquery/</link>
		<comments>http://drawlogic.com/2008/04/24/as3query-actionscript-port-of-jquery/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 01:11:56 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[BEST OF]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[FUNCTIONAL]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[iteration]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=201</guid>
		<description><![CDATA[This is older, from january, somehow I missed it but&#8230; nitoyon has created an AS3 port of jQuery. jQuery is my favorite javascript tool besides javascript itself. Mootools, prototype, and others like mochikit are all great but jQuery was the first to do lambda chain decorating and others followed suit. But having this power in [...]]]></description>
			<content:encoded><![CDATA[<p>This is older, from january, somehow I missed it but&#8230; <a href="http://tech.nitoyon.com/blog/2008/01/as3query_alpha.html" target="_blank">nitoyon </a>has created an <a href="http://tech.nitoyon.com/blog/2008/01/as3query_alpha.html" target="_blank">AS3 port of jQuery</a>.  <a href="http://jquery.com/" target="_blank">jQuery</a> is my favorite javascript tool besides javascript itself. Mootools, prototype, and others like mochikit are all great but jQuery was the first to do <a href="http://www.learningjquery.com/2006/09/sacrificial-lambda" target="_blank">lambda chain decorating </a>and others followed suit.</p>
<p><strong>But<a href="http://tech.nitoyon.com/blog/2008/01/as3query_alpha.html" target="_blank"> having this power in as3</a> is a great thing! </strong><a href="http://www.libspark.org/svn/as3/as3Query/src/com/nitoyon/as3query/$.as" target="_blank">$ selectors</a>, common access methods to properties, methods, etc.  All good stuff. Again this shows the fun in as3 or ES4 based languages like Actionscript because people are porting all sorts of libraries to it. If this performs I may just start using it daily TODAY!</p>
<p>For instance setting the stage align for use in full screen:</p>

<div class="wp_syntax"><div class="code"><pre class="jscript" style="font-family:monospace;">$(stage).attr({scaleMode: &quot;noScale&quot;, align: &quot;TL&quot;});</pre></div></div>

<p>That is too fun&#8230; The only thing not cool about this is all the spam at <a href="http://tech.nitoyon.com/blog/2008/01/as3query_alpha.html" target="_blank">nitoyon</a>&#8216;s blog : )</p>
<p>How about a functional Tweener call:</p>

<div class="wp_syntax"><div class="code"><pre class="jscript" style="font-family:monospace;">function animate(f:Boolean):void {
				// Select 'RoundRect' elements using CSS selector
				$(&quot;RoundRect:&quot; + (f ? &quot;odd&quot; : &quot;even&quot;))
					.addTween({
						rotation: 90,
						scaleX: 0.5,
						scaleY: 0.5,
						time: 0.6,
						delay: 0.3,
						transition: &quot;easeOutCubic&quot;
					})
					.addTween({
						scaleX: 1,
						scaleY: 1,
						time: 0.5,
						delay: 0.9,
						transition: &quot;easeOutElastic&quot;,
						onComplete: function():void {
							// restore the rotation and call again.
							this.rotation = 0;
							animate(!f);
						}
					});
			}
			animate(false);</pre></div></div>

<p><strong>Stuff to see and try</strong></p>
<ul>
<li>CSS Selector Demo <a href="http://snippets.libspark.org/trac/browser/as3/as3Query/samples/CssSelectorDemo.as">Source code</a> <a href="http://snippets.libspark.org/svn/as3/as3Query/samples/CssSelectorDemo.as">plain text</a></li>
<li>25 boxes and Tweener <a href="http://snippets.libspark.org/trac/browser/as3/as3Query/samples/Box25withTweener.as">Source code</a> <a href="http://snippets.libspark.org/svn/as3/as3Query/samples/Box25withTweener.as">plain text</a></li>
<li>SVN: <a href="http://snippets.libspark.org/svn/as3/as3Query/">http://snippets.libspark.org/svn/as3/as3Query/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/04/24/as3query-actionscript-port-of-jquery/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>AS3 Flash 3D Engine SWFZ Source Code Goes Open Source</title>
		<link>http://drawlogic.com/2008/04/11/as3-swfz-source-code-goes-open-source/</link>
		<comments>http://drawlogic.com/2008/04/11/as3-swfz-source-code-goes-open-source/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 12:42:47 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[3D ENGINES]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AWAY3D]]></category>
		<category><![CDATA[BEST OF]]></category>
		<category><![CDATA[DESIGN]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[EFFECTS]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[INTERFACE]]></category>
		<category><![CDATA[LIBRARIES]]></category>
		<category><![CDATA[MOTION]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PAPERVISION]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PIXEL]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[SWFZ]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[bsp]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[md2]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[quake]]></category>
		<category><![CDATA[randering]]></category>
		<category><![CDATA[renderer]]></category>
		<category><![CDATA[sandy3d]]></category>
		<category><![CDATA[scanline]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=182</guid>
		<description><![CDATA[Jono is giving SWFZ to science and the open source devices. The SWFZ engine is one Flash 3D engine that took a different approach. It is a bit early in its technique used but the author at custom:media Jono has decided to float the source code out there in ghost mode (no active development but [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.custommedia.co.nz/2008/04/01/im-giving-swfz-away/" target="_blank"><strong>Jono is giving SWFZ to science</strong> </a>and the open source devices.</p>
<p>The SWFZ engine is one Flash 3D engine that took a different approach.  It is a bit early in its technique used but the author at <a href="http://www.custommedia.co.nz/" target="_blank">custom:media</a> Jono has <a href="http://www.custommedia.co.nz/2008/04/01/swfz-unfinished-projects/" target="_blank">decided to float the source code out there </a>in ghost mode (no active development but not dead). It is just ready to branch and others to run with it. He is floating the source but I think in 1-2 years this will be the preferred method if processors and multicore parallel usage is optimized.  We shall see.</p>
<p><strong>The implementation method and difference with SWFZ engine in Flash for 3d is that is is a pixel based renderer or scanline. </strong> It is based on a really fun game engine called Irrlicht which has been pretty active for the last few years but is a C++ DirectX and OpenGL engine.  Since SWFZ has to run in Flash and it is a pixel renderer/scanline it has some limitations currently in Flash. <strong> Games and renders have to be fast to pull this off and Flash is limited by the software renderer</strong> but as computers get multiple processors and flash player gets better at this then this will be a viable option (it is the same thing that <a href="http://www.abrahamjoffe.com.au/ben/canvascape/" target="_blank">limits Canvas based renderers right now</a>).  One main problem with this is you can&#8217;t go too full screen the biggest sizes that perform well are smaller windows 320&#215;240 etc. But if the processors can handle it it is actually more efficient when it removes overlap, extra triangle drawing and painters algorithm like problems dont&#8217; pop up (triangle overlap when on same plane). This method draws pixel by pixel but fast enough flash engines like Papervision, Sandy3D and Away3D draw overlaps due to the drawing technique, back to front.</p>
<p><strong>But SWFZ still manages to pull off some amazing feats such as these demos</strong></p>
<p><a href="http://www.swfzlab.com/swfz/demo2/" target="_blank"><strong>Quake Demo</strong></a></p>
<p><a href="http://www.swfzlab.com/swfz/demo2/" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/swfz2.png" alt="" width="316" height="237" /></a></p>
<p><a href="http://www.swfzlab.com/swfz/terrain/" target="_blank"><strong>Terrain Demo</strong></a></p>
<p><a href="http://www.swfzlab.com/swfz/terrain/" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/swf3.png" alt="" width="316" height="237" /></a></p>
<p><a href="http://www.custommedia.co.nz/swfz/" target="_blank">Yoshis Hip Hop Couzin</a></p>
<p><a href="http://www.custommedia.co.nz/swfz/" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/swfz.png" alt="" width="319" height="236" /></a></p>
<p>Jono has put some great classes into SWFZ engine such as bsp parsers, quake md2 parsers, animated mesh, and lots of great examples in porting C++ Irrlicht to AS3.  This was a very early example of how AS3 was fun for programmers to port stuff from C or C++ into Flash.  AS3 is just fun. Also <a href="http://www.custommedia.co.nz/2008/04/01/im-giving-swfz-away/" target="_blank">be sure to check the site for more samples</a> like an FPS game, some basic ai etc.</p>
<p>Jono has been working on 3d in Flash for a while and <a href="http://www.custommedia.co.nz/2006/12/13/3d-in-flash/" target="_blank">actually this message is what shows the difference betweeen this approach and other flash engines</a> the way Papervision, Sandy and Away3D (pv3d derivative) make 3d in flash fast enough (Painter&#8217;s Algorithm and drawing skewed movieclips and textures.</p>
<p>Demos</p>
<ul>
<li><a href="http://www.custommedia.co.nz/2008/04/01/im-giving-swfz-away/" target="_blank">Post on Open Sourcing of Code</a></li>
<li><a href="http://www.custommedia.co.nz/2008/04/01/swfz-unfinished-projects/" target="_blank">Post on Some Unfinished Work to Build On</a></li>
<li><a href="http://www.swfzlab.com/swfz/demo2/" target="_blank">Demo Quake Prototype</a></li>
<li><a href="http://www.swfzlab.com/swfz/terrain/" target="_blank">Demo Terrain</a></li>
<li><a href="http://www.swfzlab.com/swfz/SWFZ_source.zip" target="_blank">Download Source SWFZ</a></li>
<li><a href="http://www.swfzlab.com/swfz/FileSystem_source.zip" target="_blank">Download Source Dependency (FileSystem)</a></li>
</ul>
<p><strong>More about the Engine Some Notes</strong></p>
<blockquote><p>The SWFZ engine.</p>
<p>Overview:</p>
<p>SWFZ engine is the result of four years of me messing with 3D in Flash.</p>
<p>I was a complete newbie to 3D, so a lot of learning has happened to get to here.</p>
<p>If you’re interested in 3D engines check out the resource links at the bottom of the page:</p>
<p>The Demo:</p>
<p>Model</p>
<ul>
<li>.md2 format from ID’s Quake2.</li>
<li>Uses frame based animation</li>
<li>Textured with jpeg</li>
<li>No lighting, No Gouraud Shading, just plain texture</li>
</ul>
<p>Skybox</p>
<ul>
<li>Textures are just jpegs.</li>
</ul>
<p>Boxes</p>
<ul>
<li>Rendering – Textured Gouraud , Textured Gouraud with Alpha, Textured Gouraud with Quick Alpha, Gouraud Shaded, and the large box is just Textured.</li>
<li>Star Texture – Targa (.tga) file format.</li>
</ul>
<p>AS3 classes</p>
<ul>
<li>171 classes and interfaces</li>
</ul>
<p>Scene</p>
<ul>
<li>No lighting</li>
<li>No collision detection</li>
</ul>
<p>SWFZ engine technology:</p>
<p class="MsoNormal">The demo only shows a small part of the capabilities of the engine. In the coming weeks I will get <a href="http://www.custommedia.co.nz/">www.custommedia.co.nz</a> up and running and start to post more info then.</p>
<p><!--[if !supportLineBreakNewLine]--> <!--[endif]--></p>
<p>Currently implement stuff:</p>
<p>New file formats supported</p>
<ul>
<li>.tga – Targa Image</li>
<li>.bmp – Bitmap Image</li>
<li>.3ds – 3D Studio Max</li>
<li>.bsp – Quake3 levels</li>
<li>.md2 – Quake2 models</li>
<li>.obj – Wavefront 3d object (static)</li>
<li>.zip – Read from a zip archive (all in Flash, no server side scripts)</li>
</ul>
<p>3D Rendering</p>
<ul>
<li><!--[if !supportLists]-->mipmaps<!--[endif]--></li>
<li><!--[if !supportLists]-->perspective correct texturing + affine texturing<!--[endif]--></li>
<li><!--[if !supportLists]-->Flat shading<!--[endif]--></li>
<li>Gouraud<!--[endif]--></li>
<li>Textured Gouraud<!--[endif]--></li>
<li><!--[if !supportLists]-->Textured Flat<!--[endif]--></li>
<li>Textured Two Layers<!--[endif]--></li>
<li><!--[if !supportLists]-->Gouraud Alpha<!--[endif]--></li>
<li><!--[if !supportLists]-->Textured Flat Alpha<!--[endif]--></li>
<li>Textured Gouraud Alpha<!--[endif]--></li>
</ul>
<p>3D Scene</p>
<ul>
<li><!--[if !supportLists]-->Billboards<!--[endif]--></li>
<li><!--[if !supportLists]-->Parent, Child scene nodes<!--[endif]--></li>
<li><!--[if !supportLists]-->OctTree<!--[endif]--></li>
<li><!--[if !supportLists]-->Skybox<!--[endif]--></li>
<li><!--[if !supportLists]-->Static Meshes<!--[endif]--></li>
<li><!--[if !supportLists]-->Animated Meshes<!--[endif]--></li>
<li>Basic collision detection<!--[endif]--></li>
<li> <!--[if !supportLists]-->Scene node animators</li>
</ul>
</blockquote>
<p>If any code is useful to you maybe drop him a donation or what would be nice if this was all setup at google code and used to be integrated into other engines.  Irrlicht ports are fun and there is a future in this method when processors catch up I think.</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/04/11/as3-swfz-source-code-goes-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Physaxe 2D Flash Physics Kit for haXe and List of Flash Flex Actionscript Physics Engines for AS3</title>
		<link>http://drawlogic.com/2008/04/06/physaxe-2d-flash-physics-kit-for-haxe-and-list-of-flash-flex-actionscript-physics-engines-for-as3/</link>
		<comments>http://drawlogic.com/2008/04/06/physaxe-2d-flash-physics-kit-for-haxe-and-list-of-flash-flex-actionscript-physics-engines-for-as3/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 06:43:06 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DYNAMIC]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[HAXE]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PHYSICS]]></category>
		<category><![CDATA[PIXEL]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[VISUALIZATION]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[box2dflashas3]]></category>
		<category><![CDATA[foam]]></category>
		<category><![CDATA[glade]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[motor2]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=181</guid>
		<description><![CDATA[Nicolas Cannasse, a virtual machine genius (maker of MTASC compiler, Neko and haXe (haXe compiles to target flash 6-9 but really only flash 9 is used anymore unless you are making banners)) released the Physaxe 2D Physics kit for haXe today. It is heavily based on Glaze (demos) and Box2D which the Motor2, Glaze and [...]]]></description>
			<content:encoded><![CDATA[<p><span class="author"><a href="http://blog.haxe.org/user/1">Nicolas Cannasse</a>, </span>a virtual machine genius (maker of MTASC compiler, Neko and haXe (haXe compiles to target flash 6-9 but really only flash 9 is used anymore unless you are making banners)) <a href="http://blog.haxe.org/entry/33" target="_blank"><strong>released the Physaxe 2D Physics kit for haXe today</strong></a>.</p>
<p>It is heavily based on <a href="http://code.google.com/p/glaze/" target="_blank">Glaze</a> (<a href="http://home.planet.nl/%7Eborst595/glaze.html" target="_blank">demos</a>) and  <a href="http://www.box2d.org/" target="_blank">Box2D </a>which the <a href="http://lab.polygonal.de/motor_physics/" target="_blank">Motor2</a>, <a href="http://code.google.com/p/glaze/" target="_blank">Glaze </a>and <a href="http://box2dflash.sourceforge.net/" target="_blank">Box2DFlashAS3 </a>physics kits are all based on.  Box2D is a great C++ 2D physics engine, it is simple which lended itself to being ported to AS3 quite easily.  It is also a testament to AS3 that C++ kits are being ported into the language, not once, but many times. Also C ports like <a rel="nofollow" href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmunk</a> and other signs point to ==  AS3 is of fun.</p>
<p>Physaxe is quite amazing you must see the <a href="http://blog.haxe.org/entry/33" target="_blank">demos</a> (very similar to <a href="http://home.planet.nl/%7Eborst595/glaze.html" target="_blank">Glade demos</a>), it will get the inspirational wheels turning in your idea machines.</p>
<p>2D Physics in Flash and AS3 are extremely hot and can be used for many, many things from game development to promotions to simulations to user interface or visualizations and even modeling natural systems. It is nice to have a port of Box2D and similar to glade capabilities with <a rel="nofollow" href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmunk</a> like Glade has.</p>
<blockquote><p>A game and physics engine for Flash including:</p>
<ul>
<li>Rigid Body Dynamics</li>
<li>Scene management</li>
<li>Line of sight</li>
<li>User Input</li>
<li>Scrolling</li>
<li>AI</li>
</ul>
<p>Core parts of the physics solver and collision system are based on the C physics engine <a rel="nofollow" href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmunk</a></p></blockquote>
<p><a href="http://blog.haxe.org/entry/33" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/physaxe1.png" alt="" width="480" height="339" /></a></p>
<p><a href="http://blog.haxe.org/entry/33" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/physaxe2.png" alt="" width="480" height="339" /></a></p>
<p><strong>Notes about Physaxe:</strong></p>
<p>Physaxe is a 2D Rigid Body Library written in haXe. It&#8217;s been highly optimized for the Flash 9 Player, with the best optimizations available.</p>
<blockquote><p>Physaxe is based on several existing physics engines, mainly :</p>
<ul>
<li><a rel="nofollow" href="http://box2d.org/">Box2D</a>, the reference open source physics engine</li>
<li><a href="http://groups.google.com/group/glaze-engine/browse_thread/thread/7f4503fda8dc2726" target="_blank">Glaze</a>, an AS3 engine which is a port of <a rel="nofollow" href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmunk</a>, itself based on Box2D</li>
</ul>
<p>Physaxe features are :</p>
<ul>
<li>rigid body consisting in several shapes</li>
<li>shapes supported are circles, segments (with rounded edges) and arbitrary convex polygons</li>
<li>customizable broadphase (currently bruteforce and y-sorted list are available)</li>
<li>island resolution and sleeping (allow ~0 CPU to be spent when groups are sleeping)</li>
<li>constraint solver based on Box2D sequential impulses</li>
<li>customizable body properties, such as linear/angular friction and maximized motion</li>
</ul>
</blockquote>
<ul>
<li><a href="http://physaxe.googlecode.com/files/phxdemo.swf" target="_blank">Demo</a></li>
<li><a href="http://blog.haxe.org/entry/33" target="_blank">Post about the release</a></li>
<li><a href="http://code.google.com/p/physaxe/" target="_blank">Physaxe haXe Kit on Google Code</a></li>
</ul>
<p>Updated list of physics engines are like this:</p>
<p><strong>AS3 3D Physics Engines (Open Source)</strong><a href="http://www.cove.org/ape/index.htm"></a></p>
<ul>
<li><a href="http://seraf.mediabox.fr/wow-engine/" target="_blank">WOW-Engine</a></li>
</ul>
<p><strong>AS3 2D Physics Engines (Open Source)</strong></p>
<ul>
<li><a href="http://www.cove.org/ape/index.htm">APE (Actionscript Physics Engine)</a></li>
<li><a href="http://box2dflash.sourceforge.net/">Box2DFlashAS3</a></li>
<li><a href="http://blog.generalrelativity.org/?p=17">FOAM</a></li>
<li><a href="http://code.google.com/p/glaze/">Glaze</a></li>
<li><a href="http://lab.polygonal.de/motor_physics/">Motor2</a></li>
</ul>
<p><strong>haXe 2D Physics Engines</strong></p>
<ul>
<li><a href="http://blog.haxe.org/entry/33" target="_blank">Physaxe</a></li>
</ul>
<p>Get your game on! It is best to get them out early and often.  I need to take my own advice.</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/04/06/physaxe-2d-flash-physics-kit-for-haxe-and-list-of-flash-flex-actionscript-physics-engines-for-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Flash Isometric Game Engine Released &#8211; FFilmation 1.0</title>
		<link>http://drawlogic.com/2008/03/31/as3-flash-isometric-game-engine-released/</link>
		<comments>http://drawlogic.com/2008/03/31/as3-flash-isometric-game-engine-released/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 01:48:27 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[isometric]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[ffilmation]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=178</guid>
		<description><![CDATA[The FFilmation AS3 Flash Isometric Engine has been released into the wild.  Jordi Ministral has been generous to watch his creation grow and evolve with the help of the open source community and the flash community is one of the best open source communities out there even though the core (adobe flash) is still closed. [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.ffilmation.org/website/2008/03/30/ffilmation-10-released/" target="_blank">FFilmation AS3 Flash Isometric Engine has been released</a> into the wild.  Jordi Ministral has been generous to watch his creation grow and evolve with the help of the open source community and the flash community is one of the best open source communities out there even though the core (adobe flash) is still closed. Open sourcing is one of the best ways to market test your skills really and this engine has much anyone can learn in making isometric engines for flash. You can <a href="http://drawlogic.com/2008/03/11/as3-isometric-engine/" target="_blank">see our first post on this great engine here</a>.</p>
<ul>
<li><a href="http://www.ffilmation.org/website/2008/03/30/ffilmation-10-released/" target="_blank">Post on the release</a></li>
<li><a href="http://www.ffilmation.org/website/downloads/" target="_blank">Download the code</a></li>
<li><a href="http://www.ffilmation.org/docs/api/1.0/" target="_blank">API Reference (asdoc)</a></li>
</ul>
<p><a href="http://www.ffilmation.org/website/demos/example-1/" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/ff1.png" height="357" width="500" /></a></p>
<p>Here&#8217;s a peek at the classes in the <a href="http://www.ffilmation.org/docs/api/1.0/class-summary.html" target="_blank">API</a>:</p>
<p>http://www.ffilmation.org/docs/api/1.0/class-summary.html</p>
<h3> <a href="http://www.ffilmation.org/docs/api/1.0/class-summary.html" target="classFrame">All Classes</a></h3>
<table cellpadding="0" cellspacing="0">
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/BumpMap.html">BumpMap</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fAiContainer.html">fAiContainer</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fCamera.html">fCamera</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/elements/fCharacter.html">fCharacter</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fCollideEvent.html">fCollideEvent</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fElement.html">fElement</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fEngine.html">fEngine</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/interfaces/fEngineMaterial.html"><i>fEngineMaterial</i></a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/interfaces/fEngineSceneRetriever.html"><i>fEngineSceneRetriever</i></a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fEventIn.html">fEventIn</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fEventOut.html">fEventOut</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/elements/fFloor.html">fFloor</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fGlobalLight.html">fGlobalLight</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fLight.html">fLight</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fMaterial.html">fMaterial</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fMoveEvent.html">fMoveEvent</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/elements/fObject.html">fObject</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/elements/fOmniLight.html">fOmniLight</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fPlane.html">fPlane</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fProcessEvent.html">fProcessEvent</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fRenderableElement.html">fRenderableElement</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/core/fScene.html">fScene</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/scenes/fSceneLoader.html">fSceneLoader</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/events/fWalkoverEvent.html">fWalkoverEvent</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/engine/elements/fWall.html">fWall</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/line.html">line</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/mathUtils.html">mathUtils</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/movieClipUtils.html">movieClipUtils</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/polygonProjection.html">polygonProjection</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/polygonUtils.html">polygonUtils</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/Vector.html">Vector</a></td>
</tr>
<tr>
<td><a href="http://www.ffilmation.org/docs/api/1.0/org/ffilmation/utils/vport.html">vport</a></td>
</tr>
</table>
<p>Get your game on!</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/03/31/as3-flash-isometric-game-engine-released/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>AS3 Extruding Pixels to 3D with Papervision 3D</title>
		<link>http://drawlogic.com/2008/03/22/as3-extruding-pixels-to-3d-with-papervision-3d/</link>
		<comments>http://drawlogic.com/2008/03/22/as3-extruding-pixels-to-3d-with-papervision-3d/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 23:57:30 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[3D ENGINES]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PAPERVISION]]></category>
		<category><![CDATA[PIXEL]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[extrude]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=174</guid>
		<description><![CDATA[Den Ivanov scored another &#8220;why didn&#8217;t I think of that&#8221; flash demos with extruding pixels into 3d with papervision.  He has some great samples and demos on his site about it.  Den Ivanov is a long time flasher and recent scores with Brahma bus (one of the coolest first papervision commercial projects) and the terrain [...]]]></description>
			<content:encoded><![CDATA[<p>Den Ivanov scored another &#8220;why didn&#8217;t I think of that&#8221; flash demos with <a href="http://www.cleoag.ru/2008/03/18/extrudeimage-png-to-papervision3d-object-convertor-classes/#comments" target="_blank">extruding pixels into 3d with papervision</a>.  He has some great samples and demos on his site about it.  Den Ivanov is a long time flasher and recent scores with <a href="http://blog.papervision3d.org/2007/06/08/brahma-bus/" target="_blank">Brahma bus</a> (one of the coolest first papervision commercial projects) and the <a href="http://www.cleoag.ru/2007/03/31/sources-for-papervision3d-terrain/" target="_blank">terrain generator</a>.</p>
<p><a href="http://www.cleoag.ru/2008/03/18/extrudeimage-png-to-papervision3d-object-convertor-classes/#comments" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/extrude.png" height="408" width="450" /></a></p>
<p>This uses ExtrudeImage which does exactly what the class says.</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/03/22/as3-extruding-pixels-to-3d-with-papervision-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Real-Time Raytracing</title>
		<link>http://drawlogic.com/2008/03/22/as3-real-time-raytracing/</link>
		<comments>http://drawlogic.com/2008/03/22/as3-real-time-raytracing/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 22:36:39 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[AIF]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ANIMATION]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[EFFECTS]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PIXEL]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RENDERING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[VISUALIZATION]]></category>
		<category><![CDATA[INTERFACE]]></category>
		<category><![CDATA[raytrace]]></category>
		<category><![CDATA[render]]></category>

		<guid isPermaLink="false">http://drawlogic.com/?p=172</guid>
		<description><![CDATA[Forrest Briggs throwing down with a real-time raytracer in AS3. Also a C++ OpenGL version sample on the page. Real-time pixel manipulation in flash is getting faster, but is still probably going to have to be faked in AS3, maybe AS4 will provide us per pixel speeds that Andre Michelle has been harping on since [...]]]></description>
			<content:encoded><![CDATA[<p>Forrest Briggs throwing down with a <a href="http://www.laserpirate.com/as3raytracer/" target="_blank">real-time raytracer in AS3</a>.  Also a C++ <a href="http://www.laserpirate.com/as3raytracer/" target="_blank">OpenGL version sample on the page</a>.</p>
<p>Real-time pixel manipulation in flash is getting faster, but is still probably going to have to be faked in AS3, maybe AS4 will provide us per pixel speeds that Andre Michelle has been harping on since flash 8.5. Native operations can be much faster in that area. AIF might look to change some of that but that is Flash 10.</p>
<p><a href="http://www.laserpirate.com/as3raytracer/" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/raytracer.png" height="304" width="420" /></a></p>
<p>Here is the code for the as3 raytracer.  Read more at <a href="http://www.laserpirate.com/as3raytracer/" target="_blank">laserpirate</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">Sprite</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">Bitmap</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">BitmapData</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">Event</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">utils</span>.<span style="color: #660066;">getTimer</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">MouseEvent</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextField</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextFormat</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> RayTracer <span style="color: #003366; font-weight: bold;">extends</span> Sprite
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> t<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> dt<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> .01<span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> frameTimeTxt<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> static <span style="color: #003366; font-weight: bold;">const</span> BUFFER_WIDTH<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> <span style="color: #CC0000;">160</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> static <span style="color: #003366; font-weight: bold;">const</span> BUFFER_HEIGHT<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> <span style="color: #CC0000;">120</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> static <span style="color: #003366; font-weight: bold;">const</span> BUFFER_SCALEDDOWN<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> <span style="color: #CC0000;">320</span> <span style="color: #339933;">/</span> BUFFER_WIDTH<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> static <span style="color: #003366; font-weight: bold;">const</span> HALF_BUFFER_WIDTH<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> BUFFER_WIDTH <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> static <span style="color: #003366; font-weight: bold;">const</span> HALF_BUFFER_HEIGHT<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> BUFFER_HEIGHT <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> outputBitmapData<span style="color: #339933;">:</span>BitmapData<span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> outputBitmap<span style="color: #339933;">:</span>Bitmap<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> FOV<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereCenterX<span style="color: #339933;">:</span>Array 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>	<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 		<span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereCenterY<span style="color: #339933;">:</span>Array 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>.2<span style="color: #339933;">,</span>	.4<span style="color: #339933;">,</span> 		<span style="color: #CC0000;">100.5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereCenterZ<span style="color: #339933;">:</span>Array 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> 	<span style="color: #CC0000;">4</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> 		<span style="color: #CC0000;">10</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereRadius<span style="color: #339933;">:</span>Array 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>.35<span style="color: #339933;">,</span> .35<span style="color: #339933;">,</span>	.25<span style="color: #339933;">,</span> 	<span style="color: #CC0000;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereR<span style="color: #339933;">:</span>Array 		<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">255</span><span style="color: #339933;">,</span>	<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">20</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereG<span style="color: #339933;">:</span>Array 		<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 	<span style="color: #CC0000;">150</span><span style="color: #339933;">,</span>	<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">20</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereB<span style="color: #339933;">:</span>Array 		<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 	<span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>		<span style="color: #CC0000;">255</span><span style="color: #339933;">,</span>	<span style="color: #CC0000;">20</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereReflects<span style="color: #339933;">:</span>Array <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphereReflectiveness<span style="color: #339933;">:</span>Array <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>.3<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphere2dX<span style="color: #339933;">:</span>Array <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>sphereCenterX.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphere2dY<span style="color: #339933;">:</span>Array <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>sphereCenterX.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> sphere2dR<span style="color: #339933;">:</span>Array <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>sphereCenterX.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> numSpheres <span style="color: #339933;">=</span> sphereCenterX.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> skyR<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span>  <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> skyG<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span>  <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> skyB<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span>  <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> skyColor<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>skyR<span style="color: #339933;">&lt;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>skyG<span style="color: #339933;">&lt;&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> skyB<span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> ambientIllumination<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> .1<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> canvas<span style="color: #339933;">:</span>BlankClip<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> theta<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> mouseIsDown<span style="color: #339933;">:</span>Boolean <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> mouseDownTheta<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> mouseDownX<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> RayTracer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 	outputBitmapData <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> BitmapData<span style="color: #009900;">&#40;</span>BUFFER_WIDTH<span style="color: #339933;">,</span> BUFFER_HEIGHT<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	outputBitmap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Bitmap<span style="color: #009900;">&#40;</span>outputBitmapData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	addChild<span style="color: #009900;">&#40;</span>outputBitmap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #006600; font-style: italic;">//outputBitmap.smoothing = true;</span>
&nbsp;
		outputBitmap.<span style="color: #660066;">width</span><span style="color: #339933;">=</span> <span style="color: #CC0000;">320</span><span style="color: #339933;">;</span>
 	outputBitmap.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">;</span>
&nbsp;
		canvas <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> BlankClip<span style="color: #339933;">;</span>
 	addChild<span style="color: #009900;">&#40;</span>canvas<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	canvas.<span style="color: #660066;">buttonMode</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
 	canvas.<span style="color: #660066;">useHandCursor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
		frameTimeTxt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">defaultTextFormat</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextFormat<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Arial&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">640</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">textColor</span> <span style="color: #339933;">=</span> 0xFFFFFF<span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">selectable</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 	addChild<span style="color: #009900;">&#40;</span>frameTimeTxt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		t <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
 	addEventListener<span style="color: #009900;">&#40;</span>Event.<span style="color: #660066;">ENTER_FRAME</span><span style="color: #339933;">,</span> update<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		canvas.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">MOUSE_DOWN</span><span style="color: #339933;">,</span> mouseDownHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	canvas.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">MOUSE_UP</span><span style="color: #339933;">,</span> mouseUpHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> mouseDownHandler<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
 <span style="color: #009900;">&#123;</span>
 	mouseIsDown <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
 	mouseDownX <span style="color: #339933;">=</span> stage.<span style="color: #660066;">mouseX</span><span style="color: #339933;">;</span>
 	mouseDownTheta <span style="color: #339933;">=</span> theta<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> mouseUpHandler<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
 <span style="color: #009900;">&#123;</span>
 	mouseIsDown <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:*</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 	<span style="color: #006600; font-style: italic;">// start frame timer and update global time</span>
 	<span style="color: #003366; font-weight: bold;">var</span> timer<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> getTimer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	t <span style="color: #339933;">+=</span> dt<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// handle mouse rotation</span>
 	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> mouseIsDown <span style="color: #009900;">&#41;</span> theta <span style="color: #339933;">=</span> mouseDownTheta <span style="color: #339933;">-</span> .0015 <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>stage.<span style="color: #660066;">mouseX</span> <span style="color: #339933;">-</span> mouseDownX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	theta <span style="color: #339933;">+=</span> dt<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// do some funky animation</span>
 	sphereCenterX<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	sphereCenterZ<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">+</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		sphereCenterX<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">*</span> Math.<span style="color: #660066;">PI</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	sphereCenterZ<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">+</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">*</span> Math.<span style="color: #660066;">PI</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		sphereCenterX<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">4</span> <span style="color: #339933;">*</span> Math.<span style="color: #660066;">PI</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	sphereCenterZ<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">+</span> .5<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>theta<span style="color: #339933;">*</span><span style="color: #CC0000;">5</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">4</span> <span style="color: #339933;">*</span> Math.<span style="color: #660066;">PI</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// reused variables</span>
 	<span style="color: #003366; font-weight: bold;">var</span> x<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> y<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> j<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> r<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> g<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> b<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> dx<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> dy<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> rayDirX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> rayDirY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> rayDirZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> rayDirMag<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> reflectRayDirX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectRayDirY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectRayDirZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> intersectionX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> intersectionY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> intersectionZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> reflectIntersectionX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectIntersectionY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectIntersectionZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> rayToSphereCenterX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> rayToSphereCenterY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> rayToSphereCenterZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> lengthRTSC2<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> closestApproach<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> halfCord2<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> dist<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> normalX<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> normalY<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> normalZ<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> normalMag<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> illumination<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectIllumination<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> reflectR<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectG<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectB<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// setup light dir</span>
 	<span style="color: #003366; font-weight: bold;">var</span> lightDirX<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> .3<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> lightDirY<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> lightDirZ<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>.5<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> lightDirMag<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">/</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>lightDirX<span style="color: #339933;">*</span>lightDirX <span style="color: #339933;">+</span>lightDirY<span style="color: #339933;">*</span>lightDirY <span style="color: #339933;">+</span>lightDirZ<span style="color: #339933;">*</span>lightDirZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	lightDirX <span style="color: #339933;">*=</span> lightDirMag<span style="color: #339933;">;</span>
 	lightDirY <span style="color: #339933;">*=</span> lightDirMag<span style="color: #339933;">;</span>
 	lightDirZ <span style="color: #339933;">*=</span> lightDirMag<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// vars used to in intersection tests</span>
 	<span style="color: #003366; font-weight: bold;">var</span> closestIntersectionDist<span style="color: #339933;">:</span>Number<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> closestSphereIndex<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> reflectClosestSphereIndex<span style="color: #339933;">:</span>int<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// compute screen space bounding circles</span>
 	<span style="color: #006600; font-style: italic;">//canvas.graphics.clear();</span>
 	<span style="color: #006600; font-style: italic;">//canvas.graphics.lineStyle(1, 0xFF0000, .25);</span>
 	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> numSpheres<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span>
 	<span style="color: #009900;">&#123;</span>
 		sphere2dX<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BUFFER_WIDTH <span style="color: #009966; font-style: italic;">/ 2 + FOV * sphereCenterX[i] /</span> sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 		sphere2dY<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BUFFER_HEIGHT <span style="color: #009966; font-style: italic;">/2 + FOV * sphereCenterY[i] /</span> sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 		sphere2dR<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">3</span> <span style="color: #339933;">*</span> FOV <span style="color: #339933;">*</span> sphereRadius<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">/</span> sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 		<span style="color: #006600; font-style: italic;">//canvas.graphics.drawCircle(sphere2dX[i]*BUFFER_SCALEDDOWN, sphere2dY[i]*BUFFER_SCALEDDOWN, sphere2dR[i]*BUFFER_SCALEDDOWN);</span>
 		sphere2dR<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*=</span> sphere2dR<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// store the squared value</span>
 	<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// write to each pixel</span>
 	outputBitmapData.<span style="color: #660066;">lock</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>y <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> y <span style="color: #339933;">&lt;</span> BUFFER_HEIGHT<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>y<span style="color: #009900;">&#41;</span>
 	<span style="color: #009900;">&#123;</span>
 		<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>x <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> x <span style="color: #339933;">&lt;</span> BUFFER_WIDTH<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>x<span style="color: #009900;">&#41;</span>
 		<span style="color: #009900;">&#123;</span>
 			<span style="color: #006600; font-style: italic;">// compute ray direction</span>
 			rayDirX <span style="color: #339933;">=</span> x <span style="color: #339933;">-</span> HALF_BUFFER_WIDTH<span style="color: #339933;">;</span>
 			rayDirY <span style="color: #339933;">=</span> y <span style="color: #339933;">-</span> HALF_BUFFER_HEIGHT<span style="color: #339933;">;</span>
 			rayDirZ <span style="color: #339933;">=</span> FOV<span style="color: #339933;">;</span>
&nbsp;
				rayDirMag <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">/</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>rayDirX <span style="color: #339933;">*</span> rayDirX <span style="color: #339933;">+</span> rayDirY <span style="color: #339933;">*</span> rayDirY <span style="color: #339933;">+</span>rayDirZ <span style="color: #339933;">*</span> rayDirZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 			rayDirX <span style="color: #339933;">*=</span> rayDirMag<span style="color: #339933;">;</span>
 			rayDirY <span style="color: #339933;">*=</span> rayDirMag<span style="color: #339933;">;</span>
 			rayDirZ <span style="color: #339933;">*=</span> rayDirMag<span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">/// trace the primary ray ///</span>
 			closestIntersectionDist <span style="color: #339933;">=</span> Number.<span style="color: #660066;">POSITIVE_INFINITY</span><span style="color: #339933;">;</span>
 			closestSphereIndex <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span>
 			<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> numSpheres<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span>
 			<span style="color: #009900;">&#123;</span>
 				<span style="color: #006600; font-style: italic;">// check against screen space bounding circle</span>
 				dx <span style="color: #339933;">=</span> x <span style="color: #339933;">-</span> sphere2dX<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				dy <span style="color: #339933;">=</span> y <span style="color: #339933;">-</span> sphere2dY<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> dx <span style="color: #339933;">*</span> dx <span style="color: #339933;">+</span> dy <span style="color: #339933;">*</span> dy <span style="color: #339933;">&gt;</span> sphere2dR<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// begin actual ray tracing if its inside the bounding circle</span>
&nbsp;
					lengthRTSC2 <span style="color: #339933;">=</span> 		sphereCenterX<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereCenterX<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span>
 									sphereCenterY<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereCenterY<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span>
 									sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
					closestApproach <span style="color: #339933;">=</span>	sphereCenterX<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> rayDirX <span style="color: #339933;">+</span>
 									sphereCenterY<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> rayDirY <span style="color: #339933;">+</span>
 									sphereCenterZ<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> rayDirZ<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> closestApproach <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// intersection behind the origin</span>
 					<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
					halfCord2 <span style="color: #339933;">=</span> sphereRadius<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereRadius<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> lengthRTSC2 <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>closestApproach <span style="color: #339933;">*</span> closestApproach<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> halfCord2 <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// ray misses the sphere</span>
 					<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// ray hits the sphere</span>
 				dist <span style="color: #339933;">=</span> closestApproach <span style="color: #339933;">-</span> Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>halfCord2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> dist <span style="color: #339933;">&lt;</span> closestIntersectionDist <span style="color: #009900;">&#41;</span>
 				<span style="color: #009900;">&#123;</span>
 					closestIntersectionDist <span style="color: #339933;">=</span> dist<span style="color: #339933;">;</span>
 					closestSphereIndex<span style="color: #339933;">=</span>i<span style="color: #339933;">;</span>
 				<span style="color: #009900;">&#125;</span>
 			<span style="color: #009900;">&#125;</span>
 			<span style="color: #006600; font-style: italic;">/// end of trace primary ray ///</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// primary ray doesn't hit anything</span>
 			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> closestSphereIndex <span style="color: #339933;">==</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
 			<span style="color: #009900;">&#123;</span>
 				outputBitmapData.<span style="color: #660066;">setPixel</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span> y<span style="color: #339933;">,</span> skyColor<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 			<span style="color: #009900;">&#125;</span>
 			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #006600; font-style: italic;">// primary ray hits a sphere.. calculate shading, shadow and reflection</span>
 			<span style="color: #009900;">&#123;</span>
 				<span style="color: #006600; font-style: italic;">// location of ray-sphere intersection</span>
 				intersectionX <span style="color: #339933;">=</span> rayDirX <span style="color: #339933;">*</span> closestIntersectionDist<span style="color: #339933;">;</span>
 				intersectionY <span style="color: #339933;">=</span> rayDirY <span style="color: #339933;">*</span> closestIntersectionDist<span style="color: #339933;">;</span>
 				intersectionZ <span style="color: #339933;">=</span> rayDirZ <span style="color: #339933;">*</span> closestIntersectionDist<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// sphere normal at intersection point</span>
 				normalX <span style="color: #339933;">=</span> intersectionX <span style="color: #339933;">-</span> sphereCenterX<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				normalY <span style="color: #339933;">=</span> intersectionY <span style="color: #339933;">-</span> sphereCenterY<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				normalZ <span style="color: #339933;">=</span> intersectionZ <span style="color: #339933;">-</span> sphereCenterZ<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				normalX <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// could be multiply by precacluated 1/rad</span>
 				normalY <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 				normalZ <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// diffuse illumination coef</span>
 				illumination <span style="color: #339933;">=</span> 	normalX <span style="color: #339933;">*</span> lightDirX <span style="color: #339933;">+</span>
 								normalY <span style="color: #339933;">*</span> lightDirY <span style="color: #339933;">+</span>
 								normalZ <span style="color: #339933;">*</span> lightDirZ<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> illumination <span style="color: #339933;">&lt;</span> ambientIllumination <span style="color: #009900;">&#41;</span>
 					illumination <span style="color: #339933;">=</span> ambientIllumination<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">/// trace a shadow ray ///</span>
 				<span style="color: #003366; font-weight: bold;">var</span> isInShadow<span style="color: #339933;">:</span>Boolean <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 				<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> numSpheres<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span>
 				<span style="color: #009900;">&#123;</span>
 					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> j <span style="color: #339933;">==</span> closestSphereIndex <span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
						rayToSphereCenterX <span style="color: #339933;">=</span> sphereCenterX<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionX<span style="color: #339933;">;</span>
 					rayToSphereCenterY <span style="color: #339933;">=</span> sphereCenterY<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionY<span style="color: #339933;">;</span>
 					rayToSphereCenterZ <span style="color: #339933;">=</span> sphereCenterZ<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionZ<span style="color: #339933;">;</span>
&nbsp;
						lengthRTSC2 <span style="color: #339933;">=</span> 		rayToSphereCenterX <span style="color: #339933;">*</span> rayToSphereCenterX <span style="color: #339933;">+</span>
 										rayToSphereCenterY <span style="color: #339933;">*</span> rayToSphereCenterY <span style="color: #339933;">+</span>
 										rayToSphereCenterZ <span style="color: #339933;">*</span> rayToSphereCenterZ<span style="color: #339933;">;</span>
&nbsp;
						closestApproach <span style="color: #339933;">=</span>	rayToSphereCenterX <span style="color: #339933;">*</span> lightDirX <span style="color: #339933;">+</span>
 										rayToSphereCenterY <span style="color: #339933;">*</span> lightDirY <span style="color: #339933;">+</span>
 										rayToSphereCenterZ <span style="color: #339933;">*</span> lightDirZ<span style="color: #339933;">;</span>
 					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> closestApproach <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// intersection behind the origin</span>
 						<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
						halfCord2 <span style="color: #339933;">=</span> sphereRadius<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereRadius<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> lengthRTSC2 <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>closestApproach <span style="color: #339933;">*</span> closestApproach<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> halfCord2 <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// ray misses the sphere</span>
 						<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
						isInShadow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
 					<span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">/// end of shadow ray ///</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> isInShadow <span style="color: #009900;">&#41;</span> illumination <span style="color: #339933;">*=</span> .5<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">/// trace reflected ray ///</span>
 				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> sphereReflects<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
 				<span style="color: #009900;">&#123;</span>
 					<span style="color: #006600; font-style: italic;">// calculate reflected ray direction</span>
 					<span style="color: #003366; font-weight: bold;">var</span> reflectCoef<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>rayDirX <span style="color: #339933;">*</span> normalX <span style="color: #339933;">+</span> rayDirY <span style="color: #339933;">*</span> normalY <span style="color: #339933;">+</span> rayDirZ <span style="color: #339933;">*</span> normalZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 					reflectRayDirX <span style="color: #339933;">=</span> rayDirX <span style="color: #339933;">-</span> normalX <span style="color: #339933;">*</span> reflectCoef<span style="color: #339933;">;</span>
 					reflectRayDirY <span style="color: #339933;">=</span> rayDirY <span style="color: #339933;">-</span> normalY <span style="color: #339933;">*</span> reflectCoef<span style="color: #339933;">;</span>
 					reflectRayDirZ <span style="color: #339933;">=</span> rayDirZ <span style="color: #339933;">-</span> normalZ <span style="color: #339933;">*</span> reflectCoef<span style="color: #339933;">;</span>
&nbsp;
						closestIntersectionDist <span style="color: #339933;">=</span> Number.<span style="color: #660066;">POSITIVE_INFINITY</span><span style="color: #339933;">;</span>
 					reflectClosestSphereIndex <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span>
 					<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> numSpheres<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span>
 					<span style="color: #009900;">&#123;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> j <span style="color: #339933;">==</span> closestSphereIndex <span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
							rayToSphereCenterX <span style="color: #339933;">=</span> sphereCenterX<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionX<span style="color: #339933;">;</span>
 						rayToSphereCenterY <span style="color: #339933;">=</span> sphereCenterY<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionY<span style="color: #339933;">;</span>
 						rayToSphereCenterZ <span style="color: #339933;">=</span> sphereCenterZ<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> intersectionZ<span style="color: #339933;">;</span>
&nbsp;
							lengthRTSC2 <span style="color: #339933;">=</span> 		rayToSphereCenterX <span style="color: #339933;">*</span> rayToSphereCenterX <span style="color: #339933;">+</span>
 											rayToSphereCenterY <span style="color: #339933;">*</span> rayToSphereCenterY <span style="color: #339933;">+</span>
 											rayToSphereCenterZ <span style="color: #339933;">*</span> rayToSphereCenterZ<span style="color: #339933;">;</span>
&nbsp;
							closestApproach <span style="color: #339933;">=</span> 	rayToSphereCenterX <span style="color: #339933;">*</span> reflectRayDirX <span style="color: #339933;">+</span>
 											rayToSphereCenterY <span style="color: #339933;">*</span> reflectRayDirY <span style="color: #339933;">+</span>
 											rayToSphereCenterZ <span style="color: #339933;">*</span> reflectRayDirZ<span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> closestApproach <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// intersection behind the origin</span>
 							<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
							halfCord2 <span style="color: #339933;">=</span> sphereRadius<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> sphereRadius<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> lengthRTSC2 <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>closestApproach <span style="color: #339933;">*</span> closestApproach<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> halfCord2 <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// ray misses the sphere</span>
 							<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #006600; font-style: italic;">// ray hits the sphere</span>
 						dist <span style="color: #339933;">=</span> closestApproach <span style="color: #339933;">-</span> Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>halfCord2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> dist <span style="color: #339933;">&lt;</span> closestIntersectionDist <span style="color: #009900;">&#41;</span>
 						<span style="color: #009900;">&#123;</span>
 							closestIntersectionDist <span style="color: #339933;">=</span> dist<span style="color: #339933;">;</span>
 							reflectClosestSphereIndex<span style="color: #339933;">=</span>j<span style="color: #339933;">;</span>
 						<span style="color: #009900;">&#125;</span>
 					<span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// end loop through spheres for reflect ray</span>
&nbsp;
						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> reflectClosestSphereIndex <span style="color: #339933;">==</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// reflected ray misses</span>
 					<span style="color: #009900;">&#123;</span>
 						r <span style="color: #339933;">=</span> sphereR<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
 						g <span style="color: #339933;">=</span> sphereG<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
 						b <span style="color: #339933;">=</span> sphereB<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #009900;">&#125;</span>
 					<span style="color: #000066; font-weight: bold;">else</span>
 					<span style="color: #009900;">&#123;</span>
 						<span style="color: #006600; font-style: italic;">//trace(&quot;ref hit&quot;);</span>
 						<span style="color: #006600; font-style: italic;">// location of ray-sphere intersection</span>
 						reflectIntersectionX <span style="color: #339933;">=</span> reflectRayDirX <span style="color: #339933;">*</span> closestIntersectionDist <span style="color: #339933;">+</span> intersectionX<span style="color: #339933;">;</span>
 						reflectIntersectionY <span style="color: #339933;">=</span> reflectRayDirY <span style="color: #339933;">*</span> closestIntersectionDist <span style="color: #339933;">+</span> intersectionY<span style="color: #339933;">;</span>
 						reflectIntersectionZ <span style="color: #339933;">=</span> reflectRayDirZ <span style="color: #339933;">*</span> closestIntersectionDist <span style="color: #339933;">+</span> intersectionZ<span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #006600; font-style: italic;">// sphere normal at intersection point</span>
 						normalX <span style="color: #339933;">=</span> reflectIntersectionX <span style="color: #339933;">-</span> sphereCenterX<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 						normalY <span style="color: #339933;">=</span> reflectIntersectionY <span style="color: #339933;">-</span> sphereCenterY<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 						normalZ <span style="color: #339933;">=</span> reflectIntersectionZ <span style="color: #339933;">-</span> sphereCenterZ<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
							normalX <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// could be multiply by precacluated 1/rad</span>
 						normalY <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 						normalZ <span style="color: #339933;">/=</span> sphereRadius<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #006600; font-style: italic;">// diffuse illumination coef</span>
 						reflectIllumination <span style="color: #339933;">=</span> 	normalX <span style="color: #339933;">*</span> lightDirX <span style="color: #339933;">+</span>
 												normalY <span style="color: #339933;">*</span> lightDirY <span style="color: #339933;">+</span>
 												normalZ <span style="color: #339933;">*</span> lightDirZ<span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> reflectIllumination <span style="color: #339933;">&lt;</span> ambientIllumination <span style="color: #009900;">&#41;</span>
 							reflectIllumination <span style="color: #339933;">=</span> ambientIllumination<span style="color: #339933;">;</span>
&nbsp;
							r <span style="color: #339933;">=</span> sphereR<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination <span style="color: #339933;">+</span> .5 <span style="color: #339933;">*</span> sphereR<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> reflectIllumination<span style="color: #339933;">;</span>
 						g <span style="color: #339933;">=</span> sphereG<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination <span style="color: #339933;">+</span> .5 <span style="color: #339933;">*</span> sphereG<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> reflectIllumination<span style="color: #339933;">;</span>
 						b <span style="color: #339933;">=</span> sphereB<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination <span style="color: #339933;">+</span> .5 <span style="color: #339933;">*</span> sphereB<span style="color: #009900;">&#91;</span>reflectClosestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> reflectIllumination<span style="color: #339933;">;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> r <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">255</span> <span style="color: #009900;">&#41;</span> r <span style="color: #339933;">=</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> g <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">255</span> <span style="color: #009900;">&#41;</span> g <span style="color: #339933;">=</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">;</span>
 						<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> b <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">255</span> <span style="color: #009900;">&#41;</span> b <span style="color: #339933;">=</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #009900;">&#125;</span>  <span style="color: #006600; font-style: italic;">// end if reflected ray hits</span>
&nbsp;
					<span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">/// end if reflects</span>
 				<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #006600; font-style: italic;">// primary ray doesn't reflect</span>
 				<span style="color: #009900;">&#123;</span>
 					r <span style="color: #339933;">=</span> sphereR<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
 					g <span style="color: #339933;">=</span> sphereG<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
 					b <span style="color: #339933;">=</span> sphereB<span style="color: #009900;">&#91;</span>closestSphereIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> illumination<span style="color: #339933;">;</span>
 				<span style="color: #009900;">&#125;</span>
&nbsp;
					outputBitmapData.<span style="color: #660066;">setPixel</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span> y<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>r<span style="color: #339933;">&lt;&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>g<span style="color: #339933;">&lt;&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// end if primary ray hit</span>
 		<span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// end x loop</span>
 	<span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// end y loop</span>
 	outputBitmapData.<span style="color: #660066;">unlock</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// compute FPS</span>
 	<span style="color: #003366; font-weight: bold;">var</span> fps<span style="color: #339933;">:</span>Number <span style="color: #339933;">=</span> <span style="color: #CC0000;">1.0</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>getTimer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> timer<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">1000.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	frameTimeTxt.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Drag to rotate. FPS: &quot;</span> <span style="color: #339933;">+</span> int<span style="color: #009900;">&#40;</span>fps<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/03/22/as3-real-time-raytracing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Cryptography and Hashing Libraries for Encryption and Security (crypto)</title>
		<link>http://drawlogic.com/2008/02/18/as3-cryptography-libraries/</link>
		<comments>http://drawlogic.com/2008/02/18/as3-cryptography-libraries/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 08:59:22 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[BENCHMARK]]></category>
		<category><![CDATA[BEST OF]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[CRYPTO]]></category>
		<category><![CDATA[DATA]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[LIBRARIES]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[SECURITY]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[hashing]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/?p=160</guid>
		<description><![CDATA[AS3 libraries for crypto are pretty robust from the new RAW POWER in the AVM2 virtual machine that runs flash9/as3, cryptography, like compression, is very processor intensive and needs a fair amount of power to be worth the time (usually a balancing mechanism). I am working on a few security apps in AIR and Flash9 [...]]]></description>
			<content:encoded><![CDATA[<p>AS3 libraries for crypto are pretty robust from the new RAW POWER in the AVM2 virtual machine that runs flash9/as3, cryptography, like compression, is very processor intensive and needs a fair amount of power to be worth the time (usually a balancing mechanism). I am working on a few security apps in AIR and Flash9 for a project and a product so this is the best of what I have found to share. I will be sure to post here when these projects are complete.</p>
<p>There are two that are pretty good as3 kits that have decent support for crypto and hashing, actually as3crypto is quite broad in their support or most common crypto algorithms, even hashing support up to SHA-256 and ciphers 3DES, AES, RC4.</p>
<p>This is not really a comparison just some kits that have tools you might need.  as3crypto is definitely the way to go for more heavy ecryption with common ciphers, but if you are just hashing some text as3corelib might work for your project. as3corelib is a more broad toolkit that is made or sponsored by Adobe that has JSON, RSS, support and other tools.  It is a great core lib, but not as deep in the encryption area.  I am actually using both in the stuff I am working on, as3corelib for some other uses (JSON,RSS) and as3crypto for all encryption and hashing.</p>
<p><b> The two are:</b></p>
<ul>
<li><a href="http://code.google.com/p/as3corelib/" target="_blank">as3corelib </a>
<ul>
<li>Open source</li>
<li>Support for hashing algorithms only.</li>
<li><a href="http://as3corelib.googlecode.com/svn/trunk/src/com/adobe/" target="_blank">Browse source</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="http://crypto.hurlant.com/" target="_blank">as3crypto </a>
<ul>
<li>Robust, broad encryption and security support</li>
<li>Open source</li>
<li><a href="http://crypto.hurlant.com/demo/srcview/" target="_blank">Demo</a></li>
<li><a href="http://crypto.hurlant.com/demo/srcview/" target="_blank">Browse source</a></li>
<li> Broad support of algorithms
<ul>
<li>
<div class="level2">
<ul>
<li class="level1">
<div class="li"> TLS 1.0 support, exposed through TLSSocket and TLSEngine classes</div>
</li>
<li class="level1">
<div class="li"> X.509 Certificate support, including parsing, and validation</div>
</li>
<li class="level1">
<div class="li"> built-in list of common root Certificate Authorities</div>
</li>
<li class="level1">
<div class="li"> symmetric ciphers: AES, Blowfish, DES, 3DES, XTEA, RC4</div>
</li>
<li class="level1">
<div class="li"> confidentiality modes: CTR, CBC, CFB, CFB-8, OFB, ECB</div>
</li>
<li class="level1">
<div class="li"> public key crypto: RSA (encryption, decryption, signing, verifying and key generation)</div>
</li>
<li class="level1">
<div class="li"> padding: PKCS#1 (type 1 and 2), PKCS#5</div>
</li>
<li class="level1">
<div class="li"> BigInteger <span class="search_hit">library</span></div>
</li>
<li class="level1">
<div class="li"> hashing function: SHA-256, SHA-224, SHA-1, MD5, MD2</div>
</li>
<li class="level1">
<div class="li"> HMAC support</div>
</li>
<li class="level1">
<div class="li"> prng: TLSPRF and stream-cypher-based PRNG.</div>
</li>
<li class="level1">
<div class="li"> minimal ASN-1/DER support for PEM key parsing and X-509 cert parsing</div>
</li>
<li class="level1">
<div class="li"> Crypto &#8211; Shortcut class to access many classes above.</div>
</li>
<li class="level1">
<div class="li"> Hex, Base64 &#8211; Static methods to convert binary data to and from text formats</div>
</li>
</ul>
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="level1">
<blockquote><p>  As3 Crypto is a cryptography <span class="search_hit">library</span> written in Actionscript 3 that provides several common algorithms, as well as TLS 1.0 support. The <span class="search_hit">library</span> is offered under the BSD license, and include several derivative works from Java, C and javascript sources.</p></blockquote>
<ul>
<li>
<ul>
<li class="level1">
<div class="li"> <a href="http://crypto.hurlant.com/" class="urlextern" title="http://crypto.hurlant.com/" rel="nofollow">AS3 Crypto <span class="search_hit">Library</span> Page</a></div>
</li>
<li class="level1">
<div class="li"> <a href="http://crypto.hurlant.com/demo/" class="urlextern" title="http://crypto.hurlant.com/demo/" rel="nofollow">Actionscript Cryptography Demo Page </a></div>
</li>
</ul>
</li>
</ul>
</div>
<blockquote><p>Here&#8217;s some numbers from as3Crypto home page that show the speed, note it has not been optimized just yet (since most of this is client side and only one user would be using it this is not an issue &#8211; server side is where this can have scale problems from parallel execution but flash is rarely server side if it is too slow, but it is quite fast)</p>
<pre>The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
md2                  1.01k        3.64k       15.08k       53.89k      171.76k
md5                221.85k      447.32k      739.54k      893.72k      905.82k
sha1                82.28k      184.78k      286.76k      336.03k      345.41k
sha224              60.84k      125.67k      200.27k      234.28k      247.58k
sha256              60.52k      126.30k      199.19k      234.04k      246.01k
hmac-md5            48.37k      159.37k      282.87k      295.15k      341.21k
hmac-sha1           18.29k       64.82k      165.72k      277.60k      342.52k
hmac-sha224          5.75k       24.84k      125.71k      204.35k      256.36k
hmac-sha256         15.10k       49.33k      123.71k      206.17k      249.08k
rc4                117.24k      381.34k      878.93k     1315.01k     1539.44k
xtea-cbc             2.49k        6.48k       12.80k       33.00k       44.48k
aes128-cbc           1.61k        4.01k       22.97k       78.55k      205.01k
aes192-cbc           1.34k        5.13k       20.91k       69.45k      172.43k
aes256-cbc           1.48k        5.63k       18.87k       63.45k      150.39k
blowfish-cbc         2.77k       10.81k       42.28k      140.27k      343.05k
des-cbc              2.53k        9.73k       35.20k      124.84k      624.88k
3des-cbc             2.50k        9.72k       35.61k      115.21k      253.42k</pre>
<p>The library has not been optimized for speed, and those numbers could probably be improved.</p></blockquote>
<p>They both have minimal or none ASN.1 support which I will need but I can port much of this from my favorite Java/C# crypto kit from the <a href="http://www.bouncycastle.org/" target="_blank">legion of the bouncy castle</a> of which I was happy to find was a substantial base for this kit.</p>
<p>Whatever you do don&#8217;t send any type of message from your crypto kits with aes 256 cipher and sha-256 hashing to Iran from the US.  <img src='http://drawlogic.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/02/18/as3-cryptography-libraries/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AS3 APE Line Golf &#8211; Game Kits Making Their Way Into Commercial</title>
		<link>http://drawlogic.com/2008/01/20/as3-ape-line-golf-game-kits-making-their-way-into-commercial/</link>
		<comments>http://drawlogic.com/2008/01/20/as3-ape-line-golf-game-kits-making-their-way-into-commercial/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 21:43:31 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[ENGINE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[MARKET]]></category>
		<category><![CDATA[MOTION]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<category><![CDATA[PHYSICS]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>

		<guid isPermaLink="false">http://drawlogic.com/2008/01/20/as3-ape-line-golf-game-kits-making-their-way-into-commercial/</guid>
		<description><![CDATA[Here is a well done game based on the popular Line Rider phenomenon, only this one is Line Golf and it is using the APE AS3 2D Flash Physics Engine. I am sure game sites are just as excited as game developers like myself about the prospects of games that are more dynamic and fun [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a well done game based on the popular <a href="http://fsk.deviantart.com/art/Line-Rider-beta-40255643" target="_blank">Line Rider phenomenon</a>, only this one is Line Golf and it is using the <a href="http://drawlogic.com/2007/07/18/as3-ape-physics-engine-recently-updated-new-license-mit-and-new-demo/" target="_blank">APE AS3 2D Flash Physics Engine</a>. I am sure game sites are just as excited as game developers like myself about the prospects of games that are more dynamic and fun and even 3d with the flash kits of today all thanks to the power of AS3.</p>
<p><a href="http://www.candystand.com/play.do?id=18253" target="_blank">Play Line Golf at Candy Stand</a></p>
<div style="text-align:center;"><a href="http://www.candystand.com/play.do?id=18253" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/linegolf.jpg" border="0" height="234" width="294" /></a></div>
<p>This was posted on the <a href="http://groups.google.com/group/ape-general/browse_thread/thread/66edfeb686f4ce00" target="_blank">APE Google Group</a> where onedayitwillmakeit explains more on how he modified APE for use in the game.</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/01/20/as3-ape-line-golf-game-kits-making-their-way-into-commercial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

