<?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>henry&#039;s blog</title>
	<atom:link href="http://prehensile.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://prehensile.co.uk/blog</link>
	<description></description>
	<lastBuildDate>Thu, 18 Feb 2010 18:01:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On Ebooks, the iPad and What Happens Next</title>
		<link>http://prehensile.co.uk/blog/?p=85</link>
		<comments>http://prehensile.co.uk/blog/?p=85#comments</comments>
		<pubDate>Thu, 18 Feb 2010 13:57:46 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[frotz]]></category>
		<category><![CDATA[interaction design]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[z-machine]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=85</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of work recently with a client who&#8217;s working with publishers on bringing their content to the iPhone. Naturally, with the recent announcement of the iPad, we&#8217;ve been having a lot of discussions about the possibilities raised by the device and what its arrival means for its surrounding marketplace and ourselves [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of work recently with a client who&#8217;s working with publishers on bringing their content to the iPhone. Naturally, with the recent announcement of the iPad, we&#8217;ve been having a lot of discussions about the possibilities raised by the device and what its arrival means for its surrounding marketplace and ourselves as iOS developers. This post is an attempt to nail down some of the ideas that have fallen out of those discussions.</p>
<p>I haven&#8217;t been a full-time iPhone developer for a long time (who has?), and an ebook developer for even less. Before that, I worked for a (primarily) online <a href="http://www.preloaded.com">agency</a> with a long and distinguished (and continuing!) history of creating interactive experiences with a very strong focus on narrative and story. Up until today, I didn&#8217;t think there was much common ground between the two: after all, a book is a book and a game is a game, right? However, in trying to map out the differences between the two, I&#8217;m starting to think that all the stuff I&#8217;ve learned about presentation, narrative flow and <em>appropriate</em> modes of interaction might actually come in useful when trying to figure out where to go next with ebooks on a device that has many more capabilities than a simple ebook reader.</p>
<p>My background as an interactive developer means that I tend to want to make stuff that&#8217;s as immersive and interactive as possible, playing with the available technology. When I&#8217;m making ebooks, however, I&#8217;m trying to make something that&#8217;s as much like a real book as possible, down to spending days over perfecting a page-turn effect. How to reconcile the two? Is it by making ebooks that make heavy use of <a href="http://en.wikipedia.org/wiki/Hypertext">hypertext</a>, breaking a book down into a non-linear, user-directed stream of fragments? Maybe with some whizzy graphical effects, flying from fragment to fragment (I&#8217;m pretty sure I remember some monstrosities along these lines spewing forth out of CD-ROMs back in the early-90s day)? Of course it isn&#8217;t. It does raise a few interesting questions though: once a book stops being a slab of dead tree and becomes a bitstream, how does it retain its &#8220;bookness&#8221;? How much can you meddle with the experience of reading a book before it stops <em>being</em> a book? Should we even be meddling at all? That pretty much all existing ebook readers have gone to great pains to emulate the physicality of real books, pages, page turns and all suggests that, at least for the moment, erring on the side of caution in this respect is very much the order of the day. I&#8217;d suggest, though, that perhaps this for similar reasons that (according to folklore, at least) early PCs were coloured the same beige as all other office equipment at the time: until people are used to a new, disruptive technology, dress it up like the familiar, old technology.</p>
<p>A big steer on the way I&#8217;ve been thinking about this is this wee snippet of a conversation on the always-excellent <a href="http://www.shiftrunstop.co.uk">Shift Run Stop</a> podcast with the author <a href="http://www.chriscleave.com/main/">Chris Cleave</a>. The episode can be downloaded <a href="http://shiftrunstop.co.uk/2010/01/28/episode-11-chris-cleave/">here</a>, but I&#8217;ll transcribe the relevant bit here for the impatient. You really should listen to the podcast though, it&#8217;s awesome.</p>
<blockquote><p>~33:11<br />
Cleave: &#8220;I don&#8217;t know how much the concept of authorship is relevant [in the environment of a game] where people can choose.&#8221;</p></blockquote>
<p><small><em>(Cleave then goes on to describe the kind of game he&#8217;d like to play with his audience, collaboratively buidling a novel which is super-interesting in itself, but probably best discussed another time).</em></small></p>
<p>Once you place control of the flow of a narrative in the hands of a player, you hand over at least part of the authorship of that narrative to the player. This is not a bad thing: a well crafted interactive narrative is an immensely satisfying thing to play, arguably <em>because</em> of the role you&#8217;re taking in authoring the ongoing story. <a href="http://www.valvesoftware.com/">Valve</a> are particularly good at this. However, it does mean that you can no longer claim that the resulting story has a single author, and here&#8217;s the crucial point: making a narrative interactive divides authorship duties between the original author and the player, fundamentally changing the way that it is experienced.</p>
<p>If we accept, then, that the essential defining characteristic of a book (e or otherwise) is the experience of reading a linear, authored text in the form into which it was painstakingly crafted by the original author, where does that leave us with expanding the ebook?</p>
<p>Firstly, it strikes me that at the very least, the capabilities of an iOS (or similar) device have great potential in being able to define the <em>context</em> in which that text is read. There are examples of books that have shipped or released in tandem with CDs. By listening to a custom soundtrack while you read the book, you&#8217;re getting a more immersive experience than reading the book alone, although that&#8217;s still the core act. Extra meaning and texture has <em>extended</em> the basic reading experience in a way that doesn&#8217;t interfere with the structure of the text and the authors intended meaning: preserving &#8220;bookness&#8221;.</p>
<p>Extending this train of thought, GPS data could be used to make certain portions of a text only visible in a specific spot, or kinds of spot (think: parks, bars, the top of a hill etc&#8230;) and I&#8217;m sure there&#8217;s many, many other ways a smart device can be used to enhance the context in which an ebook is read. This feels like a really exciting area to me.</p>
<p>Secondly, although I don&#8217;t really enjoy reading ebooks on an iPhone (more a personal foible than a fundamental flaw in the technology), I have been really enjoying playing through old (and not so old) <a href="http://en.wikipedia.org/wiki/Z-machine">Z-machine</a> games in <a href="http://itunes.apple.com/gb/app/frotz/id287653015?mt=8">Frotz</a>. In a nutshell, these are text-based adventures that you play by typing commands like &#8220;walk north&#8221;, &#8220;take lamp&#8221;, &#8220;kill troll&#8221; etc. Something about them feels &#8216;right&#8217; on the iPhone in a way that ebook readers don&#8217;t; while you&#8217;re still reading a lot of (in a lot of cases, very well-written) text, the <em>read / think / interact / read / &#8230; </em> rhythm feels more suited to an interactive device, rather than the artificial simulation of dead-tree book rhythm you get with an ebook reader (why are we still simulating pages on a device whose form factor is nothing at all like a page in a book?). With a bit of thought to adapting the flow of text to better suit the nature of the platform on which it&#8217;s being delivered, I think some truly <em>satisfying</em> ebooks can be produced which stand up as interesting works in their own right, rather than clumsy copies of traditional books. <a href="http://www.sixtostart.com/">Six To Start</a> and Penguin Books did some groundbreaking work in this area on the <a href="http://wetellstories.co.uk/">We Tell Stories</a> project in 2008.</p>
<hr width="50%"/>
<small><em>Although I&#8217;m leaving it a bit late to post this, I&#8217;ll be at <a href="http://thestory.org.uk/">The Story</a> tomorrow if anyone would like to discuss this with me face to face. Otherwise, I&#8217;d be really interested to see what people who actually know what they&#8217;re talking about have to say on this subject. Comments are open, and I can be found on Twitter: <a href="http://twitter.com/prehensile">@prehensile</a>.</em></small></p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=85</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 Albums of 2009</title>
		<link>http://prehensile.co.uk/blog/?p=81</link>
		<comments>http://prehensile.co.uk/blog/?p=81#comments</comments>
		<pubDate>Sun, 27 Dec 2009 16:49:26 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[chart]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=81</guid>
		<description><![CDATA[Not to be left off the bandwagon. In no particular order:
Jon Hopkins &#8211; Insides
Richard Hawley &#8211; Truelove&#8217;s Gutter
British Sea Power &#8211; Man of Aran
Health &#8211; Get Color
Grammatics &#8211; Grammatics
Fuck Buttons &#8211; Tarot Sport
Moderat &#8211; Moderat
Tim Exile &#8211;  Listening Tree
Mothertrucker &#8211; Dark Transmi55ions
Hudson Mohawke &#8211; Polyfolk Dance
]]></description>
			<content:encoded><![CDATA[<p>Not to be left off the bandwagon. In no particular order:</p>
<p>Jon Hopkins &#8211; Insides<br />
Richard Hawley &#8211; Truelove&#8217;s Gutter<br />
British Sea Power &#8211; Man of Aran<br />
Health &#8211; Get Color<br />
Grammatics &#8211; Grammatics<br />
Fuck Buttons &#8211; Tarot Sport<br />
Moderat &#8211; Moderat<br />
Tim Exile &#8211;  Listening Tree<br />
Mothertrucker &#8211; Dark Transmi55ions<br />
Hudson Mohawke &#8211; Polyfolk Dance</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Tyranny of Brown</title>
		<link>http://prehensile.co.uk/blog/?p=77</link>
		<comments>http://prehensile.co.uk/blog/?p=77#comments</comments>
		<pubDate>Wed, 30 Sep 2009 10:26:09 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[idle thoughts]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=77</guid>
		<description><![CDATA[Things that filter the information available to me based on similarity / algorithmic / social closeness to everything else I like are dull.
Back in the day, all the noise was about how everyone would have their own personalised media stream, tailored specifically to the needs and tastes of the individual. Now it&#8217;s here, it&#8217;s clear [...]]]></description>
			<content:encoded><![CDATA[<p>Things that filter the information available to me based on similarity / algorithmic / social closeness to everything else I like are dull.</p>
<p>Back in the day, all the noise was about how everyone would have their own personalised media stream, tailored specifically to the needs and tastes of the individual. Now it&#8217;s here, it&#8217;s clear that we&#8217;ve created devices for keeping us in the same old worn-out grooves, <a title="Wikipedia: Selective Exposure Theory" href="http://en.wikipedia.org/wiki/Selective_exposure_theory">selective exposure</a> raised to the <i>n</i>th degree.</p>
<p>Technology advances. We replaced our newspapers with RSS readers (already fairly effective partisan-mills) and then <a title="Twitter" href="http://www.twitter.com">Twitter</a>, an echo-chamber, mostly a closed loop for people with similar interests to share their similarity, create bubbles to inhabit. Things that allow similarity to glom together breed mediocrity, an average of everything: brown.</p>
<p>I want to be surprised. I want recommendation engines that recommend things from the very edges of my extended network, and outside of it. I don&#8217;t want 63% of people who bought <i>this</i> also bought <i>this</i>, I want to see the 1%, curve balls. <a title="last.fm" href="http://www.last.fm">Last.fm</a> is good for this: I can be listening to &#8220;<a title="last.fm link" href="http://www.last.fm/listen/artist/Aphex%2BTwin/similarartists">artists similar to Aphex Twin</a>&#8221; and get the occasional bit of Bach, or ELO, or Motown because someone, somewhere in the world creates those overlaps on the Venn diagram.</p>
<p>Let&#8217;s turn the algorithms inside-out. Let&#8217;s get them to throw out the brown bits in the middle, and find the spiky, technicolour bits around the edge. Let&#8217;s create tools for surprising ourselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=77</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>In Detail: Tricked Out Trucks</title>
		<link>http://prehensile.co.uk/blog/?p=67</link>
		<comments>http://prehensile.co.uk/blog/?p=67#comments</comments>
		<pubDate>Thu, 23 Jul 2009 11:19:53 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=67</guid>
		<description><![CDATA[In early 2008, Cadbury&#8217;s were launching a new TV advert and wanted a new online presence for their &#8220;Glass and a Half Full Productions&#8221; brand. This site would provide information about Cadbury&#8217;s and the adverts, and also house some fun interactive bits &#038; bobs inspired by these adverts.
We pitched for and won two interactive activities. [...]]]></description>
			<content:encoded><![CDATA[<p>In early 2008, Cadbury&#8217;s were launching a new TV advert and wanted a new online presence for their &#8220;Glass and a Half Full Productions&#8221; brand. This site would provide information about Cadbury&#8217;s and the adverts, and also house some fun interactive bits &#038; bobs inspired by these adverts.</p>
<p>We pitched for and won two interactive activities. The first of these activities, and the one which I&#8217;ll talk about in this post was named &#8216;Tricked Out Trucks&#8217;. The brief was simple enough: we were to create a tool which would allow visitors to the site to customise an airport truck in 3D. The creator of the best design (as picked by a panel of luminaries) would win that truck for real, all pimped out and delivered to their door. Apparently, the client had come to this concept without ever having seen <a href="http://www.cleoag.ru/">Den Ivanov</a> &#038; <a href="http://www.parkstudio.ru/">PARK Studio</a>&#8217;s <a href="http://blog.papervision3d.org/2007/06/08/brahma-bus/">Brahma Bus</a> in 2007, and were very surprised when we told them about it :)</p>
<p>We ended up differing from PARK Studio&#8217;s (pretty seminal) app in two ways. First, rather than allow freehand drawing, we assumed that most casual visitors to the site either wouldn&#8217;t have the artistic skills or inclination to draw an elaborate design, so we provided preset patterns which the user could customise to their liking and decals which they could transform and place freely. Second, we wanted to allow users to make modifications to the shape of the truck by adding body mods: spoilers, wheels and wing mirrors.</p>
<p><span id="more-67"></span></p>
<h3>The Process, Part I: 3D Models</h3>
<p>The first thing we needed were 3D models. After gathering a whole bunch of photos, we asked <a href="http://www.js3d.co.uk/">JS3D</a> to cast their minds back to Quake-era game modeling and provide us with low-polycount models of the truck and mods. We worked on a rule of thumb of 200 &#8211; 500 polys per model, which was pretty conservative; we could probably have got away with up to about 1000, but we were treading carefully in unknown territory (this was our first big 3D project), and I wanted to err on the side of caution in the interests of keeping the chances of encountering unpleasant surprises as low as possible. JS3D were really helpful here: they understood what we were trying to do straight away, and were great at suggesting optimisations I&#8217;d never have thought of, such as faking complex geometry by using transparent texture maps on simple planes (this is how the wing mirrors and spoilers were achieved). </p>
<p>They were also really helpful when we ran into that dreaded pitfall of Flash 3D engines: sketchy z-sorting. Working closely with JS3D, we identified the areas of the model which were most affected: areas where polygons overlapped, for example, or were in close proximity to each other, or inside the volume of other shapes, and tweaked the model to minimise those effects. At the time, I wasn&#8217;t aware of the alternative depth sorting options available in Papervision and Away3D; these would certainly have been helpful to us, but actually altering the geometry of a model is a fairly bullet-proof way of reducing z-sorting artifacts, and I&#8217;d recommend it to anyone who is having trouble with polygon-popup issues, especially given the extra processing overhead of the sorting methods.</p>
<h3>The Process, Part II: Decorating the truck</h3>
<p>The second big part of this project was working up a system which would allow us to redraw parts of the texture map on the fly, and have that update on the model in realtime. Conversely, for positioning decals, we needed to detect where the user was pointing on the model and accurately draw decals back onto the texture map, based on their state in the interface. We were lucky here in that the truck was a pretty simple, boxy shape, which made manipulating different parts of the texture map pretty easy: essentially, I treated the truck as a box, and the texture as a net of that box. I then created a set of masks corresponding to each side of the truck to allow me to isolate those sides in the texture bitmap, and a matching set of transforms that allowed me to composite new bitmaps in the correct place (and with with properly adjusted scale &#038; rotation) on that texture.</p>
<p>The texture drawn onto the truck model has five layers (in order, from the bottom up):</p>
<ol>
<li>paint</li>
<li>pattern</li>
<li>body details</li>
<li>decals</li>
<li>baked lightmap</li>
</ol>
<p>As the user makes changes in the interface, the layers for the relevant side are redrawn within their mask area, and the newly-recomposited texture is passed to the truck view, where the truck&#8217;s material is updated with the new bitmap. By redrawing the texture in specific areas only, the whole cycle could run quickly enough to update the truck view in realtime, most of the time ;)</p>
<p>Getting decals working correctly was quite tricky. In the interface, we presented the user with the option to drag &#038; transform decals across the view of the truck, which would then be added to the texture map. I eventually got this working with a bit of a hack: given that the truck view was being locked off at dead-on 90 angles while the user was positioning their decals, this meant that the view on screen corresponded fairly directly to one of the masked face areas in the texture map. Therefore, if I could get the mouse&#8217;s relative position on the truck view, I could translate that directly to a corresponding position on the texture. This position had to be a percentage of the distance from the top left of the view (e.g. (.3, .8) ) rather than absolute pixel values to allow for scale differences between the texture map on the onscreen rendering of the truck. </p>
<p>I later found that this is called UV mapping by proper 3D programmers, and the ability to get the mouse&#8217;s UV coordinates on a texture has been available in both PV &#038; Away for quite a while. Oh well; nothing like implementing something yourself for getting a proper understanding of it! </p>
<h3>Afterword: 3D in Flash</h3>
<p>At the beginning of the project, whilst still in the prototype stage, I created an abstract TruckView class and wrappers for Away3D and Papervision so I could switch back and forth between the two during the development process for actually rendering the thing. The following are my impressions of the two as I worked through the project. </p>
<p>I started out with Away3D, because (to my eye) it looked a bit better during my early tests. Then, as I tackled the finer points of interacting with the surface of the truck model, I switched to Papervision, as it seemed to have better interactive features, and better documentation on those features. Finally, however, I switched back to Away3D; in the final stages of the project, we were having some performance and z-sorting issues, and Away3D was hitting consistently higher framerates and looking better whilst doing it. It&#8217;s generally my impression that Papervision was a bit stronger at hardcore technical stuff and tends to implement new features more quickly, but Away3D had a nicer API and (crucially) looked nicer.</p>
<p>I should stress that this is just my opinion, and the observations that I made about the strenghths and weaknesses of the two could just as easily be down to my (mis)use of them as to any actual differences. Remember, I started this project as a n00b to both engines, and they make progress all the time; both will certainly be totally different beasts by now from their state last year. That said, we&#8217;re currently working on another 3D project which went through a similar evaluation process at the beginning of development, and again we settled with Away. The best recommendation I can make if you&#8217;re about to start a 3D project in Flash is to evaluate both and see which best meets your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=67</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In detail: Mathmos (Part II)</title>
		<link>http://prehensile.co.uk/blog/?p=31</link>
		<comments>http://prehensile.co.uk/blog/?p=31#comments</comments>
		<pubDate>Wed, 15 Jul 2009 17:03:19 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[shop]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[mathmos]]></category>
		<category><![CDATA[metaballs]]></category>
		<category><![CDATA[preloaded]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=31</guid>
		<description><![CDATA[
Last summer, Mathmos asked us if we fancied doing something for the 45th birthday of their iconic Astro Lamp. We felt that a natural fit for this would be a screen saver that simulated the lava lamp.
From a coder&#8217;s perspective, this project had two interesting problems to solve. Firstly, we had to consider the physics [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.prehensile.doesismagic.net/blog/wp-content/uploads/2009/07/mathmos-small-3.jpg" alt="mathmos-small-3" title="mathmos-small-3" width="450" height="100" class="alignnone size-full wp-image-61" /></p>
<p>Last summer, Mathmos asked us if we fancied doing something for the 45th birthday of their iconic Astro Lamp. We felt that a natural fit for this would be a screen saver that simulated the lava lamp.</p>
<p>From a coder&#8217;s perspective, this project had two interesting problems to solve. Firstly, we had to consider the physics at work inside a lava lamp in order to create a realistic simulation. Secondly, once you&#8217;ve figured out where your blobs are, their sizes and how they&#8217;re moving, you need to draw them in a satisfyingly blobby way.</p>
<p>This second post will cover how I went about drawing those blobs. You can read <a href="http://prehensile.co.uk/blog/?p=21">Part I</a> here.<br />
<span id="more-31"></span></p>
<h3>The Interesting Bit II: Drawing blobs</h3>
<p>Drawing blobby shapes on a screen is a well established area of computer graphics theory: they&#8217;re called <a href="http://en.wikipedia.org/wiki/Metaballs">metaballs</a> and the technique was invented by Jim Blinn in the early 1980s and popularised through the <a href="http://en.wikipedia.org/wiki/Demoscene">demoscene</a> in the 90s. As a side note, if you&#8217;re unfamiliar with said scene and even remotely interested in creative computing, you owe it to yourself to <a href="http://www.pouet.net/">get</a> <a href="http://tomaes.32x.de/text/faq.php">acquainted</a>. Here&#8217;s an example of a production particularly rich in metaballs:</p>
<p>
<embed src="http://www.demoscene.tv/mediaplayer.swf?id=3246_12476_14" width="512" height="404" allowfullscreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</p>
<p>Anyway, the general theory goes something like this:</p>
<p>If you&#8217;ve got a collection of centres of force (say, the blobs&#8217; centres of gravity), and a bunch of stuff attracted to those centres (say, wax), then you get shapes forming as the stuff collects around those centres. At a certain distance from any given centre, its attractive force isn&#8217;t enough to hold the stuff in place: this threshold is where the surface of your blobs form. In computer graphics, this is called an isosurface: it&#8217;s a surface which runs through space, tracing an edge where the attractive force is constant at a certain value.</p>
<p>If you only had one centre in a system, this method would end up drawing a perfect circle (the stuff is attracted to that single, lonely centre equally in all directions), but as you add more centres to a system, you get blobby shapes forming as the multiple attractive forces alter where in space that boundary falls.</p>
<p>There&#8217;s a number of different ways you can achieve this effect in Flash. By far the easiest is <a href="http://blog.szataniol.pl/?p=28">cheating it with BitmapFilters</a>, but this wasn&#8217;t going to work for our purposes; it&#8217;s fine when you&#8217;ve only got a small bitmap to render, but we needed to draw metaballs across the whole screen. For that matter, any <a href="http://www.gamedev.net/reference/programming/features/isometa2d/page2.asp">method</a> which involved drawing a bitmap of the blobs wasn&#8217;t suitable for that same reason.</p>
<p>That meant that I&#8217;d have to find a method that used vectors to trace the edges of the blob shapes. I started by looking at <a href="http://www.niksula.cs.hut.fi/~hkankaan/Homepages/metaballs.html">this method </a> and its <a href="http://toxicfork.com/projects/mb.php">AS3 port</a>, but still wasn&#8217;t getting the speed I needed (that, and the fact that I couldn&#8217;t even begin to understand the Clever Maths at work, so didn&#8217;t stand a chance at optimising the code and bending it to my will).</p>
<p>The next method I tried was <a href="http://en.wikipedia.org/wiki/Marching_squares">marching squares</a>. This method works by breaking down your drawable area into a grid of cells and sampling groups of four cells at a time. By calculating which of those cells fall inside of the isosurface, you can both draw an approximation of the shape of the surface across those four cells and figure out what direction your sample window should move in to continue to trace that surface.</p>
<p>You can see an example of the simulation running with a marching squares renderer <a href="http://prehensile.co.uk/stuff/mathmos/mathmosTest.html">here</a>. While it was pretty quick, it didn&#8217;t give us visuals of nearly a high enough resolution, and experiments fitting a curve through the points generated by the trace didn&#8217;t work very well. I decided to prototype my own method in <a href="http://processing.org/">Processing</a>.</p>
<p>
<a href="http://www.flickr.com/photos/prehensile/2591841255/in/set-72157605694243238/"><img src="http://www.prehensile.doesismagic.net/blog/wp-content/uploads/2009/07/mathmos-32.png" alt="mathmos-3" title="mathmos-3" width="450" height="100" class="alignnone size-full wp-image-58" /></a></p>
<p>The principle is pretty simple: start at a centre of mass, then work outwards until you hit the surface threshold. Once you&#8217;re at the surface, take a 90° turn and start to trace the edge of the surface by taking a step forward, then sweeping left and right until you hit the surface again. Repeat until you get back to where you started. I called this the &#8216;border patrol&#8217; method.</p>
<p>This worked pretty well to a point; it was very fast, and easy to understand. Unfortunately, it was also quite temperamental. Getting the method to recognise when it had got back to its starting point proved tricker than it had any right to be, and it wasn&#8217;t very good at turning around sharp, acute corners. </p>
<p>In the end, we simply ran out of time and ended up porting and modifying <a href="http://www.cleoag.ru/labs/flashmx/011/metaballs4.html">this method</a>, published by <a href="http://www.cleoag.ru/">Den Ivanov</a>, which I suspect is a clever variation on marching squares.</p>
<p>This is my biggest regret from the project; I&#8217;d really like to have continued to develop the border patrol method, get it bug-free and stable enough to use. However, sometimes you reach a sensible limit where you have to recognise that you&#8217;re sinking a disproportionate amount of time and effort into a problem and go with what works, even if it&#8217;s not exactly what you wanted.</p>
<p>That said, I&#8217;m still proud of the final product, the client were happy and it was a hugely educational project to work on. Maybe one day I&#8217;ll go back and finish off border patrol properly ;)</p>
<p>Download the screensaver yourself from <a href="http://virtualastro.mathmos.com/">virtualastro.mathmos.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In detail: Mathmos (Part I)</title>
		<link>http://prehensile.co.uk/blog/?p=21</link>
		<comments>http://prehensile.co.uk/blog/?p=21#comments</comments>
		<pubDate>Wed, 15 Jul 2009 16:15:39 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[mathmos]]></category>
		<category><![CDATA[metaballs]]></category>
		<category><![CDATA[preloaded]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=21</guid>
		<description><![CDATA[
Last summer, Mathmos asked us if we fancied doing something for the 45th birthday of their iconic Astro Lamp. We felt that a natural fit for this would be a screen saver that simulated the lava lamp.
From a coder&#8217;s perspective, this project had two interesting problems to solve. Firstly, we had to consider the physics [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.prehensile.doesismagic.net/blog/wp-content/uploads/2009/07/mathmos-small-1.jpg" alt="mathmos-small-1" title="mathmos-small-1" width="450" height="100" class="alignnone size-full wp-image-59" /></p>
<p>Last summer, <a href="http://www.mathmos.com">Mathmos</a> asked us if we fancied doing something for the 45th birthday of their iconic Astro Lamp. We felt that a natural fit for this would be a screen saver that simulated the lava lamp.</p>
<p>From a coder&#8217;s perspective, this project had two interesting problems to solve. Firstly, we had to consider the physics at work inside a lava lamp in order to create a realistic simulation. Secondly, once you&#8217;ve figured out where your blobs are, their sizes and how they&#8217;re moving, you need to draw them in a satisfyingly blobby way.</p>
<p>In this first post, I&#8217;m going to talk about the physical model we created to simulate the motion of blobs in a lava lamp. You can read <a href="http://prehensile.co.uk/blog/?p=31">Part II</a> here.<br />
<span id="more-21"></span></p>
<h3>The Interesting Bit I: Lava lamp physics</h3>
<p>When I was in secondary school, I ran across some instructions on the internet (at that point, it might even been on Gopher) on how to build a lava lamp. The recipe called for blobs of vegetable oil suspended in methylated spirits. I built it with my science teacher; it failed. But I&#8217;d learned a lot about how they work along the way.</p>
<p>In the base of the lamp, there&#8217;s a light bulb which illuminates the lamp and heats the liquid. This causes the blobs to rise to the top where they cool and sink back down again &#8211; a textbook example of heat convection. While they&#8217;re doing this rising and falling, they&#8217;re colliding with one another and glomming together to form new blobs, or breaking smaller blobs off as some regions of a large blob change temperature more rapidly than others.</p>
<p>To simulate this process, I started with a simple setup in <a href="http://www.cove.org/ape/">APE</a>: gravity, a few circle particles and box to hold them in. I then wrapped the basic particle class to give me particles that could have a certain amount of heat, which the system uses to apply an upwards force to each particle. The strength of that upwards force is dictated by a particle&#8217;s heat, which is increased while the particle is near the bottom of the system, but gradually cools over time to the point where gravity becomes stronger than the upwards force and the particle starts to sink.</p>
<p>That gave me masses which would rise and fall inside my simulated lamp, and half of my physical simulation.</p>
<p>The second step was to simulate the glomming together / breaking apart behaviour of the blobs. This is achieved by spawning springs between particles when they get within a certain distance of each other to make them drift together. These springs are quite loose, so as to create gentle motion, and also have a breaking point. The breaking point is important, as it allows particles to unstick from one another as gravity and heat force them in opposite directions.</p>
<p>This worked pretty well, and, once the spawning and breaking points and spring stiffness had been juggled sufficiently, we ended up with a system where nice blobby shapes formed from groups of particles coming together as they drifted past each other on their way up and down.</p>
<p>For extra bonus points, I added a stage where connected particles exchange mass downhill along their springs; this simulates an effect I noticed in lava lamps where blobs appear to flow into one another, and fuels the breaking off effect as the lower blobs become heavier and slow down relative to their rapidly shrinking conjoined siblings. This little touch made the simulation feel that much more realistic, and I&#8217;m particularly chuffed with the way it turned out.</p>
<p>Continue reading in <a href="http://prehensile.co.uk/blog/?p=31">Part II</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding mx.* libraries to FDT</title>
		<link>http://prehensile.co.uk/blog/?p=12</link>
		<comments>http://prehensile.co.uk/blog/?p=12#comments</comments>
		<pubDate>Wed, 27 May 2009 12:07:08 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[fdt]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=12</guid>
		<description><![CDATA[For my most recent AS3 project, I&#8217;ve settled on developing in Eclipse/FDT and have set up the Flex compiler for building. In general, this works great, but every so often you run across a snag, as the FDT/Flex setup has its quirks.
Today, I added a SWF asset to my main class, like so:

[Embed(source="../../assets/frame.swf")]
[Bindable]
public var Frame:Class;

but [...]]]></description>
			<content:encoded><![CDATA[<p>For my most recent AS3 project, I&#8217;ve settled on developing in Eclipse/FDT and have set up the Flex compiler for building. In general, this works great, but every so often you run across a snag, as the FDT/Flex setup has its quirks.</p>
<p>Today, I added a SWF asset to my main class, like so:<br />
<code><br />
[Embed(source="../../assets/frame.swf")]<br />
[Bindable]<br />
public var Frame:Class;<br />
</code><br />
but upon compiling, mxmlc threw the following error:<br />
<code><br />
Error: The definition of base class MovieClipLoaderAsset was not found.<br />
</code><br />
It would appear that using the <code>[Embed]</code> metatag requires the presence of some classes you&#8217;re not going to get by default. </p>
<p>A quick Spotlight search later revealed <code>MovieClipLoaderAsset.as</code> in the following location:<br />
<code>{Flex SDK}/frameworks/projects/framework/src/mx/core</code></p>
<p>Adding the framework source folder:<br />
<code>{Flex SDK}/frameworks/projects/framework/src</code<br />
 to my project as a new linked library solved the problem and the compiler was happy again.</p>
<p>I leave this note here in the hope that it proves useful to someone else one day ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gmail Last.fm Signature Greasemonkey script released</title>
		<link>http://prehensile.co.uk/blog/?p=10</link>
		<comments>http://prehensile.co.uk/blog/?p=10#comments</comments>
		<pubDate>Tue, 20 May 2008 16:37:12 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[gmaillastfmsig]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=10</guid>
		<description><![CDATA[Available from userscripts.org.
This has been knocking around in my head for a while, but I&#8217;ve finally got around to doing it: it&#8217;s a Greasemonkey script that fetches recently played information from last.fm, injects it into a sig file containing certain tokens (%artist% and %track% for now, example here) and inserts the whole lot as a [...]]]></description>
			<content:encoded><![CDATA[<p>Available from <a href="http://userscripts.org/scripts/show/26911">userscripts.org</a>.</p>
<p>This has been knocking around in my head for a while, but I&#8217;ve finally got around to doing it: it&#8217;s a Greasemonkey script that fetches recently played information from <a href="http://www.last.fm">last.fm</a>, injects it into a sig file containing certain tokens (%artist% and %track% for now, example <a href="http://www.prehensile.co.uk/greasemonkey/lastfmsig.txt">here</a>) and inserts the whole lot as a signature when you start composing a new Gmail message.</p>
<p>It&#8217;s pretty classic scratch-itch-ware, in that it does something that I wanted done in a way fairly specific to my needs &#8211; there&#8217;s no way to input your sigs directly and store on the local machine, for instance, because I wanted it to work across all the computers I use regularly and therefore use a remote sig. Likewise, because I don&#8217;t use Gmail&#8217;s rich formatting, I haven&#8217;t tested it in that context, though I doubt it&#8217;ll work there.</p>
<p>I&#8217;m setting it loose in the wild in the hope that it&#8217;ll prove useful  to people other than me, and the missing functionality can get added by people who need it!</p>
<p>First Greasemonkey script, and in fact the first relatively complex Javascript I&#8217;ve done for a while. I&#8217;m pretty happy with the way it turned out, and learnt a fair bit about JS while doing it. That said, I&#8217;m sure that there&#8217;s a lot wrong with it to the experienced eye; it is a bit of a collection of hacks ;)</p>
<p>Based on <a href="http://www.kryogenix.org/days/2006/07/11/gmail-random-signatures">Gmail: Random Signature Remote 1.0</a> by Stuart Langridge and <a href="http://blankcanvasweb.com/gmail2_html_sigs">Gmail HTML Signatures 1.07</a> by Jerome Dane.</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launchball</title>
		<link>http://prehensile.co.uk/blog/?p=9</link>
		<comments>http://prehensile.co.uk/blog/?p=9#comments</comments>
		<pubDate>Mon, 08 Oct 2007 16:09:20 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[launchball]]></category>
		<category><![CDATA[shop]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=9</guid>
		<description><![CDATA[So it&#8217;s been a while since I posted anything here &#8211; largely, my interest has been directed elsewhere. However, I&#8217;ve decided to keep this blog for professional stuff, and it&#8217;s with that in mind that I&#8217;m posting today.
I&#8217;ve just finished my latest project at Preloaded, a physics-based game in the mould of classics like The [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s been a while since I posted anything here &#8211; largely, my interest has been <a href="http://www.prehensile.co.uk/biscuit/">directed</a> <a href="http://www.prehensile.co.uk/thingstothinkabout/">elsewhere</a>. However, I&#8217;ve decided to keep this blog for professional stuff, and it&#8217;s with that in mind that I&#8217;m posting today.</p>
<p>I&#8217;ve just finished my latest <a href="http://www.sciencemuseum.org.uk/launchpad/launchball/">project</a> at <a href="http://www.preloaded.com">Preloaded</a>, a physics-based game in the mould of classics like <a href="http://en.wikipedia.org/wiki/The_Incredible_Machine">The Incredible Machine</a>: challenge the player to build a Heath Robinson contraption to get from Point A to Point B. The project was for the <a href="http://www.sciencemuseum.org.uk/">Science Museum</a> to support the relaunch of their <a href="http://www.sciencemuseum.org.uk/launchpad/">Launchpad</a> exhibition, which made it an interesting challenge: we had to reflect the hands-on experience of visitors to the gallery, keep the physics accurate enough that we wouldn&#8217;t be giving out any bad, counter-educational messages and keep the thing fun enough to keep people entertained while they&#8217;re absorbing <em>the science</em>.</p>
<p>One of the first big decisions we made was to use a third party physics (or, more specifically, dynamics) engine. The reasoning here was that I could either have spent most of the project time busting my heed over the finer points of vector integration and rigid body dynamics, or we could use one of the fine open source engines out there and I could spend the time making the damn thing fun instead. Practicalities aside, I&#8217;m very much into the idea of pushing an open source agenda at Preloaded anyway; I think we could make a really good contribution to the community and get a lot back if we managed it properly. <a href="http://www.cove.org/flade/">Flade</a> was the obvious choice (at least, while we&#8217;re still an AS2 house), and Alec Cove has my undying gratitude for making such a great engine and being cool with our using it.</p>
<p>The next decision, then, was what blocks we should include in the game. Bearing in mind the point about realism, this ruled out a lot of stuff like transporter beams, cannon, lasers etc. The eventual set we ended up with were the result of a lot of back-and-forth with the Science Museum staff, based on discussions with their content team and, in some part, on National Curriculum Key Stages 3 &amp; 4. I then spent a month implementing the decisions we&#8217;d made, tweaking the physics like a madman all along the way. This was precisely the point all that stuff I&#8217;d ever been taught about both science and object-oriented programming came in very handy indeed, and let to some interesting points where I&#8217;d start having thoughts like &#8220;this magnet will always be affecting the ball in some way. Does that mean every magnet in the universe affects every metal thing in some minute way?&#8221; and have to step away from the computer and have a nice cup of tea and a little rest.</p>
<p>Outside of the game engine itself, we had a lot to think about in terms of user experience. As the game&#8217;s aimed (mainly) at children, we had to make sure that the UI was clear and easy to use, which we refined in collaboration with Science Museum staff over many iterations. Additionally, we decided fairly early on that an important part of the game would involve giving players the chance to build and share their own levels. This meant we were going to need a pretty involved backend, handling user accounts, sending out share emails and, most importantly, managing both in-game and created levels. <a href="http://ultramagnus.org/default.aspx">Stephen Pope</a> at <a href="http://www.eduserv.org.uk/">Eduserv</a> did an amazing job building a webservice to provide all the functionality we needed and fielding increasingly frenzied IM conversations during crunch points. The client/server interactions we&#8217;re doing with the game could swallow a blog post by themselves (and are the reason we couldn&#8217;t host it elsewhere, Digg trolls ;) ), but I&#8217;ll save that for a rainy day&#8230;</p>
<p>I didn&#8217;t have much involvement with the level creation process, outside of making the sandbox editor usable enough to make it possible, but <a href="http://www.peterandall.com/">three</a> <a href="http://www.pigeonmilk.com/jon/">evil</a> <a href="http://www.jonmallinson.co.uk/">geniuses</a> on the Preloaded staff came together and did a brilliant job of it &#8211; seeing stuff done with the engine I&#8217;d built that I had no idea was possible was a big grin moment. Jon (the last of the three geniuses in that list) was the design ninja behind the whole thing and also possesses an admirably geeky brain which frequently made stuff clear that I couldn&#8217;t see for looking. Frankie Roberto, one of the team at the Science Museum did some good work too, providing some of the more surreal levels and helping us out with the CMS.</p>
<p>I&#8217;m incredibly proud of the end result, even though at times it made me feel like quitting Actionscript entirely, buying a lathe and moving to the country to make furniture in a barn. It&#8217;s certainly the most ambitious and fun thing I&#8217;ve done to date, and <a href="http://jayisgames.com/archives/2007/09/launchball.php">early</a> <a href="http://f5vmj.com/2007/10/06/launchball/">indications</a> would seem to <a href="http://www.freegamesnews.com/en/?p=2498">show</a> that the internet <a href="http://www.rockpapershotgun.com/?p=327#more-327">digs</a> it too: when an early version got <a href="http://www.digg.com/playable_web_games/Launchball_More_addictive_than_crack_And_it_s_educational">posted</a> to Digg, it generated enough traffic to kill the Science Museum&#8217;s server (good news for us, bad news for the poor guys at Eduserv who were probably quite surprised when one of their boxen started to do its best impersonation of an Aga).</p>
<p>Big fat thankyous to the Science Museum for being supportive and helpful clients, especially Frankie and Daniel Evans, and dirty great manhugs also to <a href="http://www.prehensile.co.uk/biscuit/?author=4">Barnaby Sheeran</a>, <a href="http://www.handcircus.com">Simon Oliver</a> and <a href="http://www.proalias.com/newBlog/">Alias Cummins</a>, Brothers of the Curly Bracket who all helped me out of sticky points of one sort or another. Respectful nods to Phil and Rob, my bosses at Preloaded who kept the whole thing shiny, and Jason and Sarah who kept the project running, despite my increasing crankiness.</p>
<p>So what&#8217;s next? Being at an agency means I&#8217;m kind of at the mercy of the work that comes through the door, but game wise, I&#8217;ve been really inspired recently by tangible interfaces, especially the <a href="http://mtg.upf.es/reactable/?software">reACTivision</a>; it&#8217;d be awesome to build something which had a bit of a physical presence. A nice, well crafted platformer with a really neat core mechanic would be nice, too. The idea of trying to develop something for a console also appeals: the Wii/Flash stuff is starting to look enticing, as are the possibilities made available by the DS homebrew scene, and <a href="http://creators.xna.com/">XNA Game Studio</a> hasn&#8217;t escaped my beady eye either: it&#8217;s starting to look like an interesting little ecosystem is starting to breathe on Xbox Live Arcade.</p>
<p>But first, a week with my criminally neglected, saintlikely-patienced girlfriend in the sun, as far away from computers as possible ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=9</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mindblowing interview with Rudy Rucker</title>
		<link>http://prehensile.co.uk/blog/?p=8</link>
		<comments>http://prehensile.co.uk/blog/?p=8#comments</comments>
		<pubDate>Wed, 07 Mar 2007 11:58:35 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[linkery]]></category>
		<category><![CDATA[podcast]]></category>

		<guid isPermaLink="false">http://prehensile.co.uk/blog/?p=8</guid>
		<description><![CDATA[I&#8217;m a big fan of the MondoGlobo podcasts, and there&#8217;s been a cracking two-part interview  with Rudy Rucker recently in the Neofiles strand. The first time that I&#8217;ve had to do the podcast equivalent of skipping back a few pages in order to listen again to a particularly interesting bit. Top stuff!
Part One
Part Two
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of the <a href="http://www.mondoblobo.net">MondoGlobo </a>podcasts, and there&#8217;s been a cracking two-part interview  with <a href="http://www.rudyrucker.com/blog/">Rudy Rucker</a> recently in the <a href="http://mondoglobo.net/neofiles/">Neofiles</a> strand. The first time that I&#8217;ve had to do the podcast equivalent of skipping back a few pages in order to listen again to a particularly interesting bit. Top stuff!</p>
<p><a href="http://mondoglobo.net/neofiles/show-71-rudy-rucker-on-math-love-rock-n-roll/">Part One</a></p>
<p><a href="http://mondoglobo.net/neofiles/show-72-rudy-rucker-on-flurb-subdimensional-telepathy/">Part Two</a></p>
]]></content:encoded>
			<wfw:commentRss>http://prehensile.co.uk/blog/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
