<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>carlosulloa.com &#187; Making Of</title>
	<atom:link href="http://blog.carlosulloa.com/category/making-of/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.carlosulloa.com</link>
	<description>Interactive Director</description>
	<lastBuildDate>Sat, 23 Jan 2010 13:31:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.carlosulloa.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b18879555bd59522eccc655dd13d6132?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>carlosulloa.com &#187; Making Of</title>
		<link>http://blog.carlosulloa.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.carlosulloa.com/osd.xml" title="carlosulloa.com" />
	<atom:link rel='hub' href='http://blog.carlosulloa.com/?pushpress=hub'/>
		<item>
		<title>Playing with cubes</title>
		<link>http://blog.carlosulloa.com/2008/04/24/playing-with-cubes/</link>
		<comments>http://blog.carlosulloa.com/2008/04/24/playing-with-cubes/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 10:04:15 +0000</pubDate>
		<dc:creator>C4RL05</dc:creator>
				<category><![CDATA[IAAW]]></category>
		<category><![CDATA[Making Of]]></category>

		<guid isPermaLink="false">http://carlosulloa.wordpress.com/?p=25</guid>
		<description><![CDATA[During the development of the Realized Visions section of In an ABSOLUT World, we faced creative and technical challenges in bringing the cubes to life on screen. Our solutions included some clever 3D math, the usual Flash trickery and help from the Open Source community, but mostly lateral thinking. 3D + 2D The idea of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.carlosulloa.com&amp;blog=1055330&amp;post=25&amp;subd=carlosulloa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.absolut.com/iaaw" target="_blank"><img src="http://www.carlosulloa.com/blog/jpg/iaaw_physics.jpg" alt="" width="400" height="400" /></a></p>
<p>During the development of the Realized Visions section of <a href="http://www.absolut.com/iaaw" target="_blank"><strong>In an ABSOLUT World</strong></a>, we faced creative  and technical challenges in bringing the cubes to life on screen.</p>
<p>Our solutions included some clever 3D math, the usual Flash trickery and help from the Open Source community, but mostly lateral thinking.</p>
<p><span id="more-25"></span></p>
<h3>3D + 2D</h3>
<p><span style="text-align:center; display: block;"><a href="http://blog.carlosulloa.com/2008/04/24/playing-with-cubes/"><img src="http://img.youtube.com/vi/SKNsvIH4Zhg/2.jpg" alt="" /></a></span></p>
<p>The idea of mixing 3D graphics with 2D physics comes from this early trailer of <a href="http://en.wikipedia.org/wiki/LittleBigPlanet" target="_blank"><strong>Little Big Planet</strong></a>. The game not only looks amazing, but for an interactive designer, even the preview videos are an excellent source of inspiration.</p>
<p>To calculate the physics between the cubes, we chose <a href="http://box2dflash.sourceforge.net" target="_blank"><strong>Box2DFlashAS3</strong></a>, a port of Box2D v1.4.3 to AS3 made by   				 					<strong>Matt Bush</strong> aka skatehead.</p>
<p><strong><a href="http://www.box2d.org/" target="_blank"><strong>Box2D</strong></a></strong> is an Open Source 2D rigid body physics engine for games, written in C++ by <a href="http://www.gphysics.com/" target="_self"><strong>Erin Catto</strong></a>, a very talented physics programmer at <strong>Blizzard Entertainment</strong>. Other Box2D based engines for Flash worth checking out are <a href="http://lab.polygonal.de/motor_physics/" target="_blank"><strong>motor2</strong></a> and <a href="http://blog.haxe.org/entry/33" target="_blank"><strong>Physaxe</strong></a> for <a href="http://en.wikipedia.org/wiki/Haxe" target="_blank"><strong>haXe</strong></a>.</p>
<p>Version 1.9 of <a href="http://www.papervision3d.org" target="_blank"><strong>Papervision3D</strong></a> handles the 3D rendering, while our application takes care of updating the 3D objects according to their 2D counterparts in the physics engine.</p>
<p>Scene depth is achieved by combining separate layers of 2D physics. The cubes still live in a 2D world that&#8217;s placed at a specific depth. To avoid the overhead of running multiple instances of the physics engine, we create our layers from horizontal segments of the 2D world. Sometimes, this might produce poltergeist phenomena between layers.</p>
<h3>Geometry</h3>
<p><img src="http://www.carlosulloa.com/blog/jpg/iaaw_cube.gif" alt="" width="367" height="241" /></p>
<p>Our cubes are actually a group of separate planes. This allows for great flexibility in working with individual cube faces and the entire cube at the same time.</p>
<p>To be able to open the box, we also added a hinge node to those faces that rotate around their edge. To open a face we rotate it&#8217;s hinge.</p>
<p>The outline shows the final hierarchy, with a root cube node, four hinge nodes and six face planes.</p>
<p>Working with planes and 2D interaction, let us apply simple 2D logic to some 3D problems. Our application implements custom shading  and sorting optimized for our scene setup.</p>
<h3>Shading</h3>
<p>To maximize performance, we render each face plane on a separate container, and choose between two shading modes depending on the cube&#8217;s behaviour.</p>
<p>When the cube is awake, under the control of the physics engine, we dynamically shade the container of each plane on every frame. Since the rendered output is much smaller than the original material texture, this approach is much faster than shading the material directly.</p>
<p>But for still cubes, with physics disabled or asleep, we only need to update the shading once. Baking the dynamic shading into the material isn&#8217;t particularly fast, but if done once, instead of on every frame, distributed among frames, it produces a faster to render scene.</p>
<h3>Reflections</h3>
<p>Cube reflections are mirrored versions of the original objects. The shading is darker and they are rendered on a layer with <strong>Add</strong> blend mode.</p>
<p>To mirror the textures without creating a new material, we invert the UV mapping of the faces of the object. This is the actual code used, were you specify the axis to rotate as <strong>&#8216;u&#8217;</strong> or <strong>&#8216;v&#8217;</strong>.</p>
<pre class="brush: jscript;">
function flipTexture( obj:DisplayObject3D, axis:String='v' ):void
{
  var faces:Array  = obj.geometry.faces;

  for each( var face:Face3D in faces )
  {
    face.uv[0][axis] = 1 - face.uv[0][axis];
    face.uv[1][axis] = 1 - face.uv[1][axis];
    face.uv[2][axis] = 1 - face.uv[2][axis];
  }
}
</pre>
<h3>Camera</h3>
<p>The movement of the camera is calculated by combining the result of different functions.</p>
<p>We start with <a href="http://code.google.com/p/tweener/" target="_blank"><strong>Tweener</strong></a> for the transitions, then we add user interaction so the point of view follows the mouse and the camera rolls accordingly.</p>
<p>A steadicam function keeps the scene alive even when still. The camera also follows and zooms in a box when it&#8217;s being dragged.</p>
<h3>Optimization</h3>
<p>In low poly PV3D pieces most of the performance is taken by the Flash Player screen rendering. In our case, making extensive use of colour transformations, the situation is even more delicate.</p>
<p>We constantly adjust stage quality and material smooth settings to achieve the best balance between performance and image quality.</p>
<p>The application switches between <strong>MEDIUM</strong> and <strong>LOW</strong> <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/StageQuality.html" target="_blank"><strong>stage quality</strong></a> settings as needed. Falling back to the faster mode if frame time drops. You can disable this by selecting the corresponding quality mode in the RMB context menu. We use readability antialias to avoid text pixelation.</p>
<p>Intro and video player default to H.264 MPEG if supported by the player, else plays an FLV version.</p>
<p>At the end of the day, extensive experimentation and tweaking is always needed to achieve the effects you have in mind. Sometimes it means rewriting it all, but it&#8217;s definitely worth it.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/carlosulloa.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/carlosulloa.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/carlosulloa.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/carlosulloa.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/carlosulloa.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.carlosulloa.com&amp;blog=1055330&amp;post=25&amp;subd=carlosulloa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.carlosulloa.com/2008/04/24/playing-with-cubes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a0629c3f75d6cfdce6653c3989f4c50a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">noventaynueve</media:title>
		</media:content>

		<media:content url="http://www.carlosulloa.com/blog/jpg/iaaw_physics.jpg" medium="image" />

		<media:content url="http://img.youtube.com/vi/SKNsvIH4Zhg/2.jpg" medium="image" />

		<media:content url="http://www.carlosulloa.com/blog/jpg/iaaw_cube.gif" medium="image" />
	</item>
	</channel>
</rss>