<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Seb Lee-Delisle</title>
	
	<link>http://www.sebleedelisle.com</link>
	<description>Actionscript Games, Physics and Papervision3D</description>
	<lastBuildDate>Mon, 06 Jul 2009 13:26:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/sebleedelisle" type="application/rss+xml" /><item>
		<title>Papervision3D training at Flash on the Beach</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/m3LIHrUCGS4/</link>
		<comments>http://www.sebleedelisle.com/?p=471#comments</comments>
		<pubDate>Mon, 06 Jul 2009 13:26:37 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash 3D]]></category>
		<category><![CDATA[Flash on the Beach]]></category>
		<category><![CDATA[PaperVision3D]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=471</guid>
		<description><![CDATA[I&#8217;m very pleased to be running a Papervision workshop at Flash on the Beach this year! What better excuse to come to my home town and learn everything you need to know about getting up and running with Flash3D!?
I&#8217;ll also be showing you how to use FLARToolkit, RenderLayers, and loads more. I may even share [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m very pleased to be running a Papervision workshop at Flash on the Beach this year! What better excuse to come to my home town and learn everything you need to know about getting up and running with Flash3D!?</p>
<p>I&#8217;ll also be showing you how to use FLARToolkit, RenderLayers, and loads more. I may even share a few little tips and tricks from the epic <a href="http://www.sebleedelisle.com/?p=455">Big and Small project</a>! Read a full description of the <a href="http://flashonthebeach.com/sessions/index.php?pageid=2214">Papervision3D training course at Flash on the Beach</a>. </p>
<p>And I look forward to welcoming you to Brighton!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=471</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=471</feedburner:origLink></item>
		<item>
		<title>New Adobe MAX controversy</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/aVl2bMHJSj8/</link>
		<comments>http://www.sebleedelisle.com/?p=468#comments</comments>
		<pubDate>Tue, 23 Jun 2009 18:12:19 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=468</guid>
		<description><![CDATA[It&#8217;s about that time of year where a few of us Flash speakers get together and have a good old whinge about Adobe&#8217;s speaker expense policy. In fact it&#8217;s become somewhat of an annual tradition. 
But this year Adobe have ruined our fun by blatantly covering speakers full expenses including flights and hotel! 
Seriously though [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s about that time of year where a few of us Flash speakers get together and <a href="http://www.sebleedelisle.com/?p=229">have a good old whinge about Adobe&#8217;s speaker expense policy</a>. In fact it&#8217;s become <a href="http://aralbalkan.com/658">somewhat of an annual tradition</a>. </p>
<p>But this year Adobe have ruined our fun by blatantly covering speakers <strong><em>full expenses including flights and hotel</em></strong>! </p>
<p>Seriously though I think this is a major improvement. It sometimes feels like I only complain about Adobe and so this is a good opportunity to prove that I can be positive about them sometimes! I think it&#8217;s pretty much down to the efforts of <a href="http://www.onflex.org/">Ted Patrick</a> who I&#8217;m fairly certain has been beavering away in the background trying to make this happen. </p>
<p>I have no doubt that it&#8217;ll encourage speakers who have exciting work to share with the community and it sends a good message out to speakers that Adobe appreciate their contribution to their conference.</p>
<p>Of course the irony is that they haven&#8217;t invited me to speak this year. I won&#8217;t hold it against them. <img src='http://sebleedelisle.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=468</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=468</feedburner:origLink></item>
		<item>
		<title>Big big Papervision3D project for small people</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/CtF7R4DRz1U/</link>
		<comments>http://www.sebleedelisle.com/?p=455#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:53:09 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash 3D]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PaperVision3D]]></category>
		<category><![CDATA[Plug-in Media Website]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=455</guid>
		<description><![CDATA[
You may have noticed that I&#8217;ve been a little quieter than usual over the past few months. And for that, I&#8217;m sorry. But there&#8217;s a very good reason for that! Me and the my very talented colleagues at Plug-in Media have been hugely busy working on the biggest and most ambitious Papervision3D project we&#8217;ve ever [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/sebleedelisle/3584610897/" title="Big and Small by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3636/3584610897_2f9ee62e12.jpg" width="480"  alt="Big and Small Living room comp" /></a></p>
<p>You may have noticed that I&#8217;ve been a little quieter than usual over the past few months. And for that, I&#8217;m sorry. But there&#8217;s a very good reason for that! Me and the my very talented colleagues at Plug-in Media have been hugely busy working on the biggest and most ambitious Papervision3D project we&#8217;ve ever attempted; <a href="http://www.pluginmedia.net/clients/bigandsmall"><em>Big and Small</em></a>.</p>
<p><object width="485" height="279"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3157727&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3157727&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="485" height="279"></embed></object>
<p><a href="http://vimeo.com/3157727">Big and Small</a> from <a href="http://vimeo.com/user457592">Plug-in Media</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><em>Big and Small</em> is a comedy TV show for kids (3 to 6) about a big character (called <em>Big</em>) and a small character (called <em>Small</em>) who, despite their differences, are the very best of friends. </p>
<p>There are so many details that I want to share, I&#8217;m not sure where to start! There&#8217;s the close collaboration with the BBC and Kindle (the TV show&#8217;s production company). And then there&#8217;s the studio sessions with Lenny Henry (famous UK comedian) who provided the voices, and the recording of Dom&#8217;s (Plug-in&#8217;s creative director) band for the music game. Not to mention all the incredible artists, coders and producers at Plug-in who all did an amazing job of bringing it all together. </p>
<p>But as the head geek at Plug-in I&#8217;ll concentrate on the technology. <img src='http://sebleedelisle.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3580076568/" title="Big and Small website by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3563/3580076568_ffabbc7f91.jpg" width="480" alt="Big and Small website living room Small central" /></a></p>
<p>The first hurdle was to recreate the Big and Small house in Papervision3D; tricky, given the cluttered, busy and warm look that Dom came up with (our creative director). We spent about a month just getting the model for the living room to look right.  </p>
<p>Many things in the living room are point sprites; a 2D image of an object that looks the same no matter which way you look at it (like the flowers). We built our own PointSprite object that uses Papervision particles to render this. </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3580077528/" title="Big and Small website by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3327/3580077528_024e304a36.jpg" width="480" alt="Big and Small website, Big in Living room" /></a></p>
<p>Big looks 3D and changes as you move the camera around, but he&#8217;s also a 2D point sprite. Our animator Ben rendered him on the timeline spinning around, so we work out the angle of the camera and jump to the relevant frame. </p>
<p>We really wanted to make sure that any 2D graphics seamlessly fit in with the 3D world, not only stylistically but also technically. We created custom 3D mesh animation to make the bed spring up and down in reaction to a 2D Small jumping up and down. </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3589160262/" title="Big and Small by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3323/3589160262_34dd6a50de.jpg" width="480"  alt="Big and Small" /></a></p>
<p>There are many clever effects that took ages to program, and although you wouldn&#8217;t necessarily notice them, we like to think they add a certain quality to the project : </p>
<p>The mobile in the bedroom with a custom built verlet physics system:<br />
<a href="http://www.flickr.com/photos/sebleedelisle/3585417546/" title="Big and Small by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3380/3585417546_5ea0a401c3.jpg" width="480"  alt="Big and Small" /></a></p>
<p>A custom mesh animation system for the radio in the living room, allowing our designers to animate in 2D and apply it to a 3D mesh in real time. </p>
<p>The mirror in the bathroom with realtime reflections. </p>
<p>The toothpaste particles that collide with the walls and furniture.</p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3589160138/" title="Big and Small by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3410/3589160138_7d6cebf48b.jpg" width="480" alt="Big and Small" /></a></p>
<p>The lighting that changes in the bedroom when the blind is closed. </p>
<p>It was a massive project, and phase one alone was over 200 days of coding, not to mention the artwork, 3D modelling, sound design and music. </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3589255214/" title="Big and Small phase 2 by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3311/3589255214_0f21951226.jpg" width="480"  alt="Big and Small phase 2" /></a></p>
<p>And brilliantly, the BBC were so pleased that they&#8217;ve also commissioned phase 2 and we&#8217;re well underway with it. Phase 1 brought you into the house, but phase 2 takes you out into the garden, with magical plants, a reflective pond, and a Doom-style mysterious woods to explore! </p>
<p>You can see a little more in this (very rough cut) of a behind the scenes video, exploring the less geeky aspects of the project, including collaboration, concepting, and user testing. </p>
<p><object width="485" height="279"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4371629&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4371629&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="485" height="279"></embed></object>
<p><a href="http://vimeo.com/4371629">Making of Big and Small Rough cut</a> from <a href="http://vimeo.com/user457592">Plug-in Media</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>It&#8217;s been a brilliant experience, Rebecca at the BBC has been a joy to work with, and it&#8217;s been really exciting to stretch what is possible in Flash and Papervision3D. I&#8217;ll let you know when phase 2 is released. </p>
<p><a href="http://www.pluginmedia.net/clients/bigandsmall">Try out the site for yourself here. </a></p>
<p>And I really would like to give major kudos to everyone on the Plug-in team that worked on this, I&#8217;m very proud to work with such talented people : </p>
<p>Juliet Tzabar : Production Director<br />
Dominic Minns : Creative Director<br />
Alan Owen : Senior programmer<br />
Jack Lang : Programmer<br />
Sarah Bird : 3D Modeller<br />
Ben Mantle : Artist / Animator<br />
Cath Lloyd : Animator (lip synching)<br />
Lee Needham-Park : Project Manager<br />
Kate Fowler : Sound design / production assistant<br />
Kirsty, Ellie, Bruce (and Dom!) : Musicians</p>
<p>(Well done guys, you all rock!) And this project will be finished in a few weeks so we&#8217;ll be open for more projects! Can you use some Plug-in magic for your project? Need some Papervision3D expertise? Drop me a mail. seb@pluginmedia.net. </p>
<p>PS There&#8217;s an easter egg somewhere in the Big and Small website&#8230; can you find it? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=455</wfw:commentRss>
		<slash:comments>35</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=455</feedburner:origLink></item>
		<item>
		<title>Super fast triangle/rectangle intersection test</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/g_j0Bs1g3Gs/</link>
		<comments>http://www.sebleedelisle.com/?p=447#comments</comments>
		<pubDate>Sat, 30 May 2009 13:20:21 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash 3D]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PaperVision3D]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=447</guid>
		<description><![CDATA[
I&#8217;m always on the lookout for ways to speed up our project work and also some of the inner workings of Papervision3D, and I must admit, sometimes it reaches fairly obsessive levels, bordering on unhealthy. In fact sometimes the minor optimisations are so insignificant, it can just be an exercise in problem solving. Which let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/sebleedelisle/3578639736/" title="IMG_5997 by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3562/3578639736_9c2b5d0795.jpg" width="500" height="333" alt="IMG_5997" /></a></p>
<p>I&#8217;m always on the lookout for ways to speed up our project work and also some of the inner workings of Papervision3D, and I must admit, sometimes it reaches fairly obsessive levels, bordering on unhealthy. In fact sometimes the minor optimisations are so insignificant, it can just be an exercise in problem solving. Which let&#8217;s face it, we all do from time to time just for fun, right? <img src='http://sebleedelisle.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>The latest target for my obsessive compulsive attention is the triangle / rectangle intersection check that happens just before rendering. It&#8217;s way after any of the clever 3D stuff, we&#8217;re just literally looking at whether the 2D triangle we&#8217;re about to draw is within the rectangle that represents our screen. </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3578632924/" title="Triangle / AABB intersection Test by sebleedelisle, on Flickr"><img src="http://farm3.static.flickr.com/2458/3578632924_2ebd1110ab.jpg" width="500" height="334" alt="Triangle / AABB intersection Test" /></a></p>
<p>The current check is a simple bounding rectangle check. The bounding rectangle for the triangle is calculated and we use a simple intersect check for the two rectangles. Which is simple and fast. But it was bothering me that huge offscreen triangles were not getting culled because their bounding rectangle overlapped with the viewport rectangle. </p>
<p><a href="http://www.flickr.com/photos/sebleedelisle/3577830111/" title="Triangle / AABB intersection Test by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3611/3577830111_6d071b9015.jpg" width="500" height="324" alt="Triangle / AABB intersection Test" /></a></p>
<p>So how do you accurately check that a triangle is intersecting a rectangle? Here&#8217;s one way :<br />
<span id="more-447"></span><br />
1) Check if any of the triangle&#8217;s points are within the rectangle, if yes then intersection is true.<br />
2) Check if any of the triangle&#8217;s lines intersect any of the rectangle&#8217;s lines, if yes then intersection is true. </p>
<p>Check 1 is relatively simple, but if no points are within the rectangle, we have to move to check 2, and that means we have to check each of the 3 lines in the triangle with each of the 4 lines of the rectangle, 12 line intersection checks altogether. Which just felt a bit dirty to me. </p>
<p>But then I got to thinking, this rectangle is an AABB (or axis-aligned bounding box, which basically means that it&#8217;s not rotated), so that should make things a little easier. And I developed this little technique loosely based on existing systems but I haven&#8217;t seen anything exactly like this before. I&#8217;m not sure if it&#8217;s the best way but it seems fast and accurate to me! Here&#8217;s how it works : </p>
<p>1) take the first line of the triangle<br />
<a href="http://www.flickr.com/photos/sebleedelisle/3578633372/" title="Triangle / AABB intersection Test by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3372/3578633372_3522d923dc.jpg" width="500" height="334" alt="Triangle / AABB intersection Test" /></a></p>
<p>2) calculate its equation and then work out the y position that it intersects the left and right edges of the rectangle</p>
<p>3) take the maximum and minimum y bounds of those two intersection points and calculate the overlap between those and the max and min y values of the line.<br />
<a href="http://www.flickr.com/photos/sebleedelisle/3578633478/" title="Triangle / AABB intersection Test by sebleedelisle, on Flickr"><img src="http://farm3.static.flickr.com/2455/3578633478_19d6d0b8cc.jpg" width="500" height="357" alt="Triangle / AABB intersection Test" /></a></p>
<p>4) if these new overlapping min and max y values overlap the top and bottom of the rectangle then the line (and therefore the triangle) must intersect the rectangle, so return true.<br />
<a href="http://www.flickr.com/photos/sebleedelisle/3577830723/" title="Triangle / AABB intersection Test by sebleedelisle, on Flickr"><img src="http://farm4.static.flickr.com/3587/3577830723_eba2cea3d4.jpg" width="500" height="398" alt="Triangle / AABB intersection Test" /></a></p>
<p>5) Otherwise move on to the next line of the triangle and try again. </p>
<p>It seems to be much more accurate than the existing bounding rectangle check and for positives is 30% faster. For negatives it&#8217;s about the same or a tiny bit slower. The only innaccuracy I&#8217;ve found is if the triangle is entirely containing the rectangle it returns negative. And also I should put in a check for vertical lines and do a simpler check on those. </p>
<p>But my challenge to you! Can you get this to be slicker / faster? I&#8217;m sure there are some maths wizards out there. Full code below and you can even fork it and have a play at the rather awesome <a href="http://wonderfl.kayac.com/code/3ab954b6538d38e747c9d5405ca8a5a6b8dfaba8">Wonderfl</a></p>
<p>I realise that you could unroll the method call to triangleAABBIntersectionTest but I&#8217;m more interested in improvements to the maths/logic. </p>
<p>Good luck!</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Graphics</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Rectangle</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #0066CC;">getTimer</span>;
   <span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span>frameRate=<span style="color: #ff0000;">&quot;100&quot;</span>, <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;0x000000&quot;</span>, <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;500&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
   <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TriangleAABBSpeedTest <span style="color: #0066CC;">extends</span> Sprite
   <span style="color: #66cc66;">&#123;</span>
&nbsp;
&nbsp;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> outputText : <span style="color: #0066CC;">TextField</span>;
&nbsp;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TriangleAABBSpeedTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#123;</span>
         <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
         outputText = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
         x = y = <span style="color: #cc66cc;">250</span>; 
         outputText.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Arial&quot;</span><span style="color: #66cc66;">&#41;</span>; 
         outputText.<span style="color: #0066CC;">textColor</span> = 0xffffff; 
         outputText.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Click to start test&quot;</span>; 
         outputText.<span style="color: #006600;">x</span> = outputText.<span style="color: #006600;">y</span> = -<span style="color: #cc66cc;">250</span>; 
         outputText.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">500</span>; 
&nbsp;
         addChild<span style="color: #66cc66;">&#40;</span>outputText<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
         <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, startTest<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
      <span style="color: #808080; font-style: italic;">// I'm thinking that storing these values as properties rather than declaring them as local vars </span>
      <span style="color: #808080; font-style: italic;">// should be faster...</span>
&nbsp;
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> x0 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> y0 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> x1 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> y1 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> x2 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> y2 : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> l : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> r : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> t : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> b : <span style="color: #0066CC;">Number</span>; 
&nbsp;
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> top_intersection:<span style="color: #0066CC;">Number</span> ;
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> bottom_intersection : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> toptrianglepoint : <span style="color: #0066CC;">Number</span>; 
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> bottomtrianglepoint : <span style="color: #0066CC;">Number</span>; 
&nbsp;
      <span style="color: #0066CC;">private</span>  <span style="color: #000000; font-weight: bold;">var</span> m: <span style="color: #0066CC;">Number</span>;
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> c : <span style="color: #0066CC;">Number</span>   
&nbsp;
&nbsp;
      <span style="color: #808080; font-style: italic;">// THESE ARE THE TWO FUNCTIONS YOU CAN OPTIMISE. </span>
      <span style="color: #808080; font-style: italic;">// I realise that you could inline the lineRectangleIntersect method, but I'd rather not do that just yet... </span>
      <span style="color: #808080; font-style: italic;">// I'm looking for maths/logic improvements. </span>
&nbsp;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> triangleAABBIntersectionTest<span style="color: #66cc66;">&#40;</span>rect:Rectangle,  vertex0:Point, vertex1:Point, vertex2:Point <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Boolean</span>
      <span style="color: #66cc66;">&#123;</span>
         <span style="color: #808080; font-style: italic;">// YOU MUST LEAVE THESE DECLARATIONS; they simulate necessary data exchange within PV3D</span>
         l = rect.<span style="color: #0066CC;">left</span>; 
         r = rect.<span style="color: #0066CC;">right</span>; 
         t = rect.<span style="color: #006600;">top</span>; 
         b = rect.<span style="color: #006600;">bottom</span>; 
&nbsp;
         x0 = vertex0.<span style="color: #006600;">x</span>; 
         y0 = vertex0.<span style="color: #006600;">y</span>; 
         x1 = vertex1.<span style="color: #006600;">x</span>; 
         y1 = vertex1.<span style="color: #006600;">y</span>; 
         x2 = vertex2.<span style="color: #006600;">x</span>; 
         y2 = vertex2.<span style="color: #006600;">y</span>; 
&nbsp;
&nbsp;
         <span style="color: #b1b100;">return</span> lineRectangleIntersect<span style="color: #66cc66;">&#40;</span>x0,y0,x1,y1<span style="color: #66cc66;">&#41;</span> 
               <span style="color: #66cc66;">||</span>   lineRectangleIntersect<span style="color: #66cc66;">&#40;</span>x1,y1,x2,y2<span style="color: #66cc66;">&#41;</span> 
               <span style="color: #66cc66;">||</span>   lineRectangleIntersect<span style="color: #66cc66;">&#40;</span>x2,y2,x0,y0<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
&nbsp;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> lineRectangleIntersect<span style="color: #66cc66;">&#40;</span>x0: <span style="color: #0066CC;">Number</span>,y0: <span style="color: #0066CC;">Number</span>,x1: <span style="color: #0066CC;">Number</span>,y1: <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #808080; font-style: italic;">//, left:Number, right:Number, top:Number, bottom:Number) : Boolean</span>
      <span style="color: #66cc66;">&#123;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// Calculate m and c for the equation for the line (y = mx+c)</span>
            m = <span style="color: #66cc66;">&#40;</span>y1-y0<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #66cc66;">&#40;</span>x1-x0<span style="color: #66cc66;">&#41;</span>; 
            c = y0 -<span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">*</span>x0<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
            <span style="color: #808080; font-style: italic;">// if the line is going up from right to left then the top intersect point is on the left</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
               top_intersection = <span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">*</span>l  + c<span style="color: #66cc66;">&#41;</span>; 
               bottom_intersection = <span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">*</span>r  + c<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span> 
            <span style="color: #808080; font-style: italic;">// otherwise it's on the right</span>
            <span style="color: #b1b100;">else</span> 
            <span style="color: #66cc66;">&#123;</span>
               top_intersection = <span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">*</span>r  + c<span style="color: #66cc66;">&#41;</span>; 
               bottom_intersection = <span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">*</span>l  + c<span style="color: #66cc66;">&#41;</span>; 
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// work out the top and bottom extents for the triangle</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>y0<span style="color: #66cc66;">&lt;</span>y1<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
               toptrianglepoint = y0; 
               bottomtrianglepoint = y1; 
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">else</span>
            <span style="color: #66cc66;">&#123;</span>
               toptrianglepoint = y1; 
               bottomtrianglepoint = y0; 
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> topoverlap : <span style="color: #0066CC;">Number</span>; 
            <span style="color: #000000; font-weight: bold;">var</span> botoverlap : <span style="color: #0066CC;">Number</span>; 
&nbsp;
            <span style="color: #808080; font-style: italic;">// and calculate the overlap between those two bounds</span>
            topoverlap = top_intersection<span style="color: #66cc66;">&gt;</span>toptrianglepoint ? top_intersection : toptrianglepoint; 
            botoverlap = bottom_intersection<span style="color: #66cc66;">&lt;</span>bottomtrianglepoint ? bottom_intersection : bottomtrianglepoint; 
&nbsp;
            <span style="color: #808080; font-style: italic;">// (topoverlap&lt;botoverlap) : </span>
            <span style="color: #808080; font-style: italic;">// if the intersection isn't the right way up then we have no overlap</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// (!((botoverlap&lt;t) || (topoverlap&gt;b)) :</span>
            <span style="color: #808080; font-style: italic;">// If the bottom overlap is higher than the top of the rectangle or the top overlap is </span>
            <span style="color: #808080; font-style: italic;">// lower than the bottom of the rectangle we don't have intersection. So return the negative </span>
            <span style="color: #808080; font-style: italic;">// of that. Much faster than checking each of the points is within the bounds of the rectangle. </span>
            <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>topoverlap<span style="color: #66cc66;">&lt;</span>botoverlap<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>botoverlap<span style="color: #66cc66;">&lt;</span>t<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span>topoverlap<span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> startTest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
      <span style="color: #66cc66;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">var</span> g : Graphics = graphics; 
         g.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
         <span style="color: #000000; font-weight: bold;">var</span> cullingRect : Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;">100</span>,-<span style="color: #cc66cc;">75</span>,<span style="color: #cc66cc;">200</span>,<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
         <span style="color: #000000; font-weight: bold;">var</span> iterations : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">100000</span>; 
         <span style="color: #000000; font-weight: bold;">var</span> timerIntersecting : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span> ; 
         <span style="color: #000000; font-weight: bold;">var</span> timerNotIntersecting : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span> ; 
                        <span style="color: #000000; font-weight: bold;">var</span> intersectCount : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; 
&nbsp;
         <span style="color: #000000; font-weight: bold;">var</span> v0 : Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
         <span style="color: #000000; font-weight: bold;">var</span> v1 : Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
         <span style="color: #000000; font-weight: bold;">var</span> v2 : Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
         <span style="color: #000000; font-weight: bold;">var</span> i : <span style="color: #0066CC;">int</span> = iterations; 
&nbsp;
         <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>--i<span style="color: #66cc66;">&gt;</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#123;</span>
            v0.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">400</span> - <span style="color: #cc66cc;">200</span>; 
            v0.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">400</span> - <span style="color: #cc66cc;">200</span>; 
            v1.<span style="color: #006600;">x</span> = v0.<span style="color: #006600;">x</span>+ <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">300</span> -<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>; 
            v1.<span style="color: #006600;">y</span> = v0.<span style="color: #006600;">y</span>+ <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">300</span> -<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>; 
            v2.<span style="color: #006600;">x</span> = v0.<span style="color: #006600;">x</span>+ <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">300</span> -<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>; 
            v2.<span style="color: #006600;">y</span> = v0.<span style="color: #006600;">y</span>+ <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">300</span> -<span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>;             
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> startTimer : <span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
            <span style="color: #000000; font-weight: bold;">var</span> intersecting : <span style="color: #0066CC;">Boolean</span> = triangleAABBIntersectionTest<span style="color: #66cc66;">&#40;</span>cullingRect, v0, v1, v2<span style="color: #66cc66;">&#41;</span>; 
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>intersecting<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
               timerIntersecting += <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - startTimer<span style="color: #66cc66;">&#41;</span>;
               intersectCount++; 
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">else</span> 
            <span style="color: #66cc66;">&#123;</span>
               timerNotIntersecting += <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - startTimer<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
               g.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,0x000000<span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>intersecting ? 0x006600 : 0x660000,<span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span>x0,y0<span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span>x1,y1<span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span>x2,y2<span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span>x0,y0<span style="color: #66cc66;">&#41;</span>; 
               g.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
            <span style="color: #66cc66;">&#125;</span>
         <span style="color: #66cc66;">&#125;</span>
&nbsp;
         g.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,0xffffff,<span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>; 
         g.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span>cullingRect.<span style="color: #006600;">x</span>, cullingRect.<span style="color: #006600;">y</span>, cullingRect.<span style="color: #0066CC;">width</span>, cullingRect.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>; 
         outputText.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Average time per triangle : &quot;</span>+<span style="color: #66cc66;">&#40;</span>timerIntersecting+timerNotIntersecting<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>iterations; 
         outputText.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Average time per intersecting triangle : &quot;</span>+<span style="color: #66cc66;">&#40;</span>timerIntersecting<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>intersectCount<span style="color: #66cc66;">&#41;</span>; 
         outputText.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Average time per non-intersecting triangle : &quot;</span>+<span style="color: #66cc66;">&#40;</span>timerNotIntersecting<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>iterations-intersectCount<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=447</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=447</feedburner:origLink></item>
		<item>
		<title>Lunar Lander 3D in 5K</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/k4qw3Ul1Sk8/</link>
		<comments>http://www.sebleedelisle.com/?p=428#comments</comments>
		<pubDate>Sat, 25 Apr 2009 08:47:47 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash 3D]]></category>
		<category><![CDATA[Game programming]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=428</guid>
		<description><![CDATA[Remember Lunar Lander? One of the very first arcade games ever? Well, actually, if I&#8217;m honest I don&#8217;t really remember it when it came out in 1979 (I was only 7 at the time), but I do think it&#8217;s a very, very cool game. 

For starters, the display didn&#8217;t use scan lines like a normal [...]]]></description>
			<content:encoded><![CDATA[<p>Remember Lunar Lander? One of the very first arcade games ever? Well, actually, if I&#8217;m honest I don&#8217;t really remember it when it came out in 1979 (I was only 7 at the time), but I do think it&#8217;s a very, very cool game. </p>
<p><img src="http://sebleedelisle.com/wp-content/uploads/2009/04/lunarlander_i.jpg" alt="lunarlander original" title="lunarlander original" width="450" height="345" class="alignnone size-full wp-image-431" /></p>
<p>For starters, the display didn&#8217;t use scan lines like a normal telly, instead, the cathode ray moves around to make shapes, the same way that laseriums used to make pictures with lasers. (If you don&#8217;t remember the 80s you&#8217;ll probably have no idea what I&#8217;m talking about). </p>
<p>Secondly, it&#8217;s actually very, very difficult. So you feel a real sense of achievement when you actually land the thing safely! I was actually lucky enough to see an original vector based arcade cabinet, and the thing that immediately strikes you is how bright the screen is, and how beautiful those glowing lines are. </p>
<p>Sadly, Lunar Lander had a fairly limited life when it came out. It was quickly superceded by perhaps the most famous vector game ever, Asteroids. In fact most of the early Lunar Landers had their insides unceremoniously ripped out and were converted to Asteroids cabinets, so they&#8217;re pretty rare now. </p>
<p>A few years ago, as a tribute to the early pioneers of arcade gaming, I decided to recreate Lunar Lander in Flash, with painstaking attention to detail and accuracy! And what did I do to celebrate this great achievement? Did I shout about it from the rooftops? Did I post it on the internet for everyone to share and enjoy? Did I write a blog post about it? Well actually no, I just sat on it and it&#8217;s been laying there burning a hole on my hard drive all this time. </p>
<div id="attachment_432" class="wp-caption alignnone" style="width: 460px"><a href="http://sebleedelisle.com/games/moonlander"><img src="http://sebleedelisle.com/wp-content/uploads/2009/04/lunarlanderflash.png" alt="My flash Lunar Lander" title="lunarlanderflash" width="450" height="345" class="size-full wp-image-432" /></a><p class="wp-caption-text">My flash Lunar Lander</p></div>
<p>But don&#8217;t worry, <a href="http://sebleedelisle.com/games/moonlander">you can now play this online here</a> to your heart&#8217;s content. Use left and right arrows, and up arrow to thrust. It&#8217;ll take a little effort to get used to, but that&#8217;s half the joy. <img src='http://sebleedelisle.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>But that&#8217;s not what this post is about.  A local Brighton geek group, <a href="http://fivepoundapp.com/">£5App</a> decided to run a <a href="http://fivepoundapp.com/meetup/16/">5KApp</a> competition, where you could submit any program that was 5120 bytes or less. And you were allowed to use Flash, so I got going to see how if I could make a Lunar Lander clone within the file size limit. </p>
<p>I&#8217;d worked out how to use Perlin noise to create a 2D landscape and got pretty much all of the physics and collision detection working, but I&#8217;d only used about 3K. </p>
<p>So to make it a bit more interesting, I decided to add 3D! To create the landscape I used the same Perlin noise image to store all the data, and drew the landscape in strips from back to front, with a very basic 3D to 2D formula, and before I knew it I had 3D Lunar Lander!</p>
<div id="attachment_434" class="wp-caption alignnone" style="width: 490px"><a href="http://sebleedelisle.com/games/moonlander3d"><img src="http://sebleedelisle.com/wp-content/uploads/2009/04/lunarlander3d.png" alt="Lunar Lander 3D in only 5K" title="lunarlander3d" width="480" height="300" class="size-full wp-image-434" /></a><p class="wp-caption-text">Lunar Lander 3D in only 5K</p></div>
<p>My final submission was 5118 bytes, only 2 bytes under the limit! Interestingly, swfs seem to fluctuate by a few bytes every time you publish them. (My theory is that it embeds the time and date?). The one I&#8217;ve posted here on the site is exactly 5120 bytes!</p>
<p><object width="440" height="275"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4319384&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4319384&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="440" height="275"></embed></object><br /><a href="http://vimeo.com/4319384">Lunar Lander 3D</a> from <a href="http://vimeo.com/user457592">Plug-in Media</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Just like the original, it&#8217;s very, very difficult, use the arrow keys to move left, right, forward and back, and the space bar thrusts. Look out for flat landing pads of 4 lines, and head towards them. You need to go in really close, and you&#8217;ll know you&#8217;re over it as the land turns white when you&#8217;re directly over it. And you need to land right in the middle of the 4 lines, and very, very gently! See <a href="http://vimeo.com/4319384">the playthrough video</a> if you need more help. </p>
<p>Despite some stiff competition from the Brighton geek community, this was voted the winner! And the prize was exactly 5120 pence. So I went and bought everyone a drink with it. </p>
<p>It&#8217;s actually been really fun, and it&#8217;s given me a lot of ideas for future projects. I&#8217;ll post up the source with a bit of explanation soon, but for now you can <a href="http://sebleedelisle.com/games/moonlander3d">play the game here</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=428</wfw:commentRss>
		<slash:comments>42</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=428</feedburner:origLink></item>
		<item>
		<title>Papervision3D session with Carlos in London</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/qYUsacn1wDE/</link>
		<comments>http://www.sebleedelisle.com/?p=425#comments</comments>
		<pubDate>Wed, 22 Apr 2009 22:16:21 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PaperVision3D]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=425</guid>
		<description><![CDATA[I&#8217;ve been back from honeymoon for a couple of weeks, and I&#8217;m finally getting back into the swing of work! There have been a few developments, more of that soon, but first of all I just wanted to let you all know that myself and Carlos will be presenting at London&#8217;s LFPUG on 29th April. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been back from honeymoon for a couple of weeks, and I&#8217;m finally getting back into the swing of work! There have been a few developments, more of that soon, but first of all I just wanted to let you all know that myself and Carlos will be presenting at London&#8217;s <a href="http://www.lfpug.com/">LFPUG</a> on 29th April. </p>
<p>Believe it or not over 100 people have already signed up for it, but I&#8217;m sure <a href="http://tink.ws/blog/">Tink</a> and his friends will be able to fit you in. </p>
<p>I&#8217;ll be showing you how to get started in Papervision, and I expect I&#8217;ll also be talking you through our latest project for the BBC, Big and Small, which is such a huge project I feel like I should devote an entire blog post to it soon! </p>
<p>Papervision3D founder <a href="http://carlosulloa.com">Carlos Ulloa</a> will be headlining with an hour full of the tricks and techniques behind his new business venture <a href="http://helloenjoy.com">HelloEnjoy</a>.</p>
<blockquote><p>&#8220;The session will focus on the techniques, workflow and planning necessary to overcome the creative and technical challenges of real time 3D in Flash, giving an inside view of the entire creation process, from concept and planning, to development and art production.&#8221;</p></blockquote>
<p><a href="http://www.lfpug.com/30th-april-2009-30042009/">Get yourself over to LFPUG</a> and <a href="http://www.lfpug.com/30th-april-2009-30042009/">sign up</a> if you&#8217;re interested in coming!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=425</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=425</feedburner:origLink></item>
		<item>
		<title>Just married! :-)</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/K_Otu1mdnWo/</link>
		<comments>http://www.sebleedelisle.com/?p=406#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:33:30 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=406</guid>
		<description><![CDATA[
And what a amazing day it was! We had Dom (from Plug-in) playing the ukulele for us during the ceremony, and were greeted by a 70 piece choir (thanks Hullaballoo!) as we left the town hall! And later, our guests were &#8220;treated&#8221; to a song from Jenny and I along with a tap dance routine [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://sebleedelisle.com/wp-content/uploads/2009/03/2643_79072790870_710790870_2953185_7094400_n.jpg" alt="Seb and Jenny&#039;s wedding, 21st March 2009" title="Seb and Jenny&#039;s wedding, 21st March 2009" width="402" height="603" class="alignnone size-full wp-image-407" /></p>
<p>And what a amazing day it was! We had Dom (from <a href="http://pluginmedia.net">Plug-in</a>) playing the ukulele for us during the ceremony, and were greeted by a 70 piece choir (thanks <a href="http://www.hullabaloobrighton.org.uk/">Hullaballoo</a>!) as we left the town hall! And later, our guests were &#8220;treated&#8221; to a song from Jenny and I along with a tap dance routine (and yes I&#8217;m sure it&#8217;ll appear on youtube before too long&#8230;)</p>
<p>And what&#8217;s all this got to do with the world of Flash and Papervision3D? Well, nothing. Although I&#8217;m just flying out to Thailand for a couple of weeks so I expect I won&#8217;t be returning emails for a while. But I promise it&#8217;ll be business as usual when I get back, so I&#8217;ll catch up with you then!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=406</wfw:commentRss>
		<slash:comments>27</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=406</feedburner:origLink></item>
		<item>
		<title>How to change @author in your ASDocs</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/LV19UNkeqj4/</link>
		<comments>http://www.sebleedelisle.com/?p=404#comments</comments>
		<pubDate>Fri, 13 Mar 2009 11:51:40 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=404</guid>
		<description><![CDATA[For OSX at least&#8230; 
Step 1
Navigate to /Applications/Flex Builder 3/
Step2
Right click on the app, Flex Builder and select explore package contents. A new finder window should pop up with a folder called &#8220;Contents&#8221;
Step 3
Open the file Contents/MacOS/FlexBuilder.ini with a text editor of your choice. 
Step 4
Add the following line :
-Duser.name=Seb Lee-Delisle
Except obviously you&#8217;ll probably want [...]]]></description>
			<content:encoded><![CDATA[<p>For OSX at least&#8230; </p>
<p><strong>Step 1</strong><br />
Navigate to /Applications/Flex Builder 3/</p>
<p><strong>Step2</strong><br />
Right click on the app, Flex Builder and select explore package contents. A new finder window should pop up with a folder called &#8220;Contents&#8221;</p>
<p><strong>Step 3</strong><br />
Open the file Contents/MacOS/FlexBuilder.ini with a text editor of your choice. </p>
<p><strong>Step 4</strong><br />
Add the following line :<br />
<em>-Duser.name=Seb Lee-Delisle</em></p>
<p>Except obviously you&#8217;ll probably want to use your own name <img src='http://sebleedelisle.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p><strong>Step 5</strong><br />
Save the file and restart Flex Builder. Now your automatically generated comments will contain your full name after @author!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=404</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=404</feedburner:origLink></item>
		<item>
		<title>How to set up ASDoc in Flex Builder</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/7_bAfooJLk4/</link>
		<comments>http://www.sebleedelisle.com/?p=401#comments</comments>
		<pubDate>Thu, 12 Mar 2009 19:55:36 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=401</guid>
		<description><![CDATA[I&#8217;ve basically spent about a day working out how to use ASDoc, and all I can say is, what a nightmare! If I wanted this kind of unintuitive, problem-ridden, poorly-documented ridiculousness I&#8217;d be a Linux user! (no offense meant, but you Linux guys seem to thrive on this sort of thing!)
Excluding external libraries
Our project has [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve basically spent about a day working out how to use ASDoc, and all I can say is, what a nightmare! If I wanted this kind of unintuitive, problem-ridden, poorly-documented ridiculousness I&#8217;d be a Linux user! (no offense meant, but you Linux guys seem to thrive on this sort of thing!)</p>
<p><b>Excluding external libraries</b></p>
<p>Our project has loads of external classes in libraries (one is papervision, others are various Plug-in Media libs), and I really would rather it didn&#8217;t try to document them all in the same documentation. And I couldn&#8217;t figure out how to stop ASDocs from trying to compile the classes in these libraries. </p>
<p>And if you don&#8217;t include the libraries, ASDoc fails badly! So I could either include them in to the docs (which seemed to break anyway) or just exclude them. But is there a way to exclude them? </p>
<p>It turns out that there is, and that is to list every class that you want to exclude! Er yeah that&#8217;s probably about 2,000 classes so not going to happen!</p>
<p>Although there is a handy way to generate this HUGE list of classes using the <a href="http://mac.softpedia.com/get/Developer-Tools/DITA.shtml">AIR app Dita</a>. But I think I&#8217;ve kinda worked out how to use ASDocs now in a way that stops you needing to do that. </p>
<p><b>Adding external swcs</b></p>
<p>The big secret that no one seemed to be telling me! If you add a <strong>swc</strong> file it no longer fails to find the classes you&#8217;re referring to. But most importantly it <em>doesn&#8217;t try to write docs for them!</em></p>
<p>So here&#8217;s how we set it up :<br />
<span id="more-401"></span><br />
<strong>Step 1 :</strong> Set up an external tool in Flex. </p>
<p>Open Flex Builder (we&#8217;re using FB 3). See that little green play button with a suitcase on it? In the top left? Click on the down arrow next to it and then &#8220;Open external tools dialog&#8221;. </p>
<p><strong>Step 2 :</strong></p>
<p>Click on the &#8220;New Launch Configuration&#8221; Button. it&#8217;s the white sheet of paper with a &#8220;+&#8221; on it. </p>
<p><strong>Step 3 : </strong> Find your asdoc file.</p>
<p>Give it a name. Maybe ASDocs or something equally unimaginative. Then set up the Location field; click on Browse File System and find your ASDoc file in the Flex SDK. For me it was in /Applications/Flex Builder 3/sdks/4.0.0.4021/bin/asdoc. If you&#8217;re on a PC you should probably point to asdoc.exe. </p>
<p><strong>Step 4 : </strong> Point to the project folder.</p>
<p>In the &#8220;Working Directory&#8221; field, type <strong>${project_loc}</strong> &#8211; this will point to the project folder for whichever project you are currently in. </p>
<p><strong>Step 5 : </strong> Set up the arguments.</p>
<p>in the arguments field point to your source path with the following two arguments : </p>
<p>-source-path src<br />
-doc-sources src</p>
<p>This assumes that you set up your projects with the default source folder called src. So it&#8217;ll look into your project folder&#8217;s src to find all the classes to make docs for. </p>
<p>And then add arguments to point to the swcs for your library projects, for us it&#8217;s : </p>
<p>-external-library-path=/Users/seb/Documents/FBWorkspace/PluginLibs/bin<br />
-external-library-path=/Users/seb/Documents/FBWorkspace/PluginBrain/bin<br />
-external-library-path=/Users/seb/Documents/FBWorkspace/Papervision3D/bin</p>
<p>Of course this assumes that you use library projects in Flex Builder. I guess this will work as long as you have swcs for your code library. Either way you need to point at it. </p>
<p>I&#8217;m sure that this won&#8217;t work for all of you but I haven&#8217;t seen this approach documented anywhere so I thought it may help. And good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=401</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=401</feedburner:origLink></item>
		<item>
		<title>Papervision Simplified, at FITC Amsterdam</title>
		<link>http://feedproxy.google.com/~r/sebleedelisle/~3/W4NGI5D3Uag/</link>
		<comments>http://www.sebleedelisle.com/?p=398#comments</comments>
		<pubDate>Mon, 23 Feb 2009 13:35:43 +0000</pubDate>
		<dc:creator>Seb Lee-Delisle</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash 3D]]></category>
		<category><![CDATA[PaperVision3D]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://www.sebleedelisle.com/?p=398</guid>
		<description><![CDATA[I landed in Amsterdam this morning at 8.15am feeling a little achey and strange after running the Brighton half marathon yesterday! 
I&#8217;m just going over my presentation in my room, and I&#8217;ve just realised I haven&#8217;t actually uploaded the working files you&#8217;ll need to work along with me! 
But don&#8217;t worry you can download them [...]]]></description>
			<content:encoded><![CDATA[<p>I landed in Amsterdam this morning at 8.15am feeling a little achey and strange after running the Brighton half marathon yesterday! </p>
<p>I&#8217;m just going over my presentation in my room, and I&#8217;ve just realised I haven&#8217;t actually uploaded the working files you&#8217;ll need to work along with me! </p>
<p>But don&#8217;t worry you can <a href="http://sebleedelisle.com/uploads/FlexWorkspaceFITCAmsterdam09.zip">download them here</a>!</p>
<p>It&#8217;s a Flex workspace so just point your FlexBuilder 3 at it and you&#8217;ll get all the example files. </p>
<p>See you at 4pm!</p>
<p><a href="http://sebleedelisle.com/uploads/FlexWorkspaceFITCAmsterdam09.zip">Download the source files. </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebleedelisle.com/?feed=rss2&amp;p=398</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.sebleedelisle.com/?p=398</feedburner:origLink></item>
	</channel>
</rss>
