<?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>Everyday 3D</title>
	
	<link>http://www.everyday3d.com/blog</link>
	<description>3D user experience on the web. Design, technology news. A blog by Bartek Drozdz.</description>
	<lastBuildDate>Tue, 20 Jul 2010 15:14:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/EverydayFlash" /><feedburner:info uri="everydayflash" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Format journey</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/cd82ThxoxI8/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/07/20/format-journey/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 15:14:45 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[magdalena festival]]></category>
		<category><![CDATA[maribor]]></category>
		<category><![CDATA[shading]]></category>

		<guid isPermaLink="false">http://www.everyday3d.com/blog/?p=1428</guid>
		<description><![CDATA[A few months ago, I had the pleasure to work with Luciano Foglia and Anrick Bregman on a visual experiment called Format Journey. The installation uses data &#8211; a series of images and a sound file &#8211; to modify the texture and the shape of a 3D object. Combined with a slight randomization it gives [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I had the pleasure to work with <a href="http://www.lucianofoglia.com" target="_blank">Luciano Foglia</a> and <a href="http://www.anrick.com" target="_blank">Anrick Bregman</a> on a visual experiment called <strong>Format Journey</strong>. The installation uses data &#8211; a series of images and a sound file &#8211; to modify the texture and the shape of a 3D object. Combined with a slight randomization it gives very nice and unpredictable results. </p>
<p><a href="http://www.everyday3d.com/works/installation/colors/"><img src="http://www.everyday3d.com/blog-assets/installation/ins03.jpg" height="381" width="520" border="0"/></a></p>
<p>When we first talked about the project, the idea was to use either <strong>Flash</strong> or <strong>Processing</strong>, but I though that it&#8217;s a good occasion to try <strong>Unity3D</strong> (of course&#8230; :) To achieve the desired visual effect I needed a shader system that&#8217;s fast, flexible that and works with 3D. Unity&#8217;s <strong>ShaderLab</strong> seemed like a good option. </p>
<p>The material on the shape is transparent and is composed of a blurred version of an image applied as regular texture and the image itself applied as reflection. The images change over time, and are animated by scrolling UVs.  </p>
<p><img src="http://www.everyday3d.com/blog-assets/installation/ins01.jpg" height="290" width="520"/></p>
<p>All the data for the installation is <strong>loaded dynamically</strong>, the application itself is just composed of some scripts that make it run, so <strong>the file is only 55KB</strong>! It&#8217;s controlled by an external configuration file that allows to define the source images and sounds. There are also quite a few other settings to tweak they way it works, ex. how transparent or how reflective the material should be.</p>
<p><img src="http://www.everyday3d.com/blog-assets/installation/ins02.jpg" height="359" width="520"/></p>
<p>One particular challenge was to <strong>make the shape react to the sound</strong>. To make this happen I needed to read the spectrum and Unity3D doesn&#8217;t offer access to sound data on the code level. One possible solution was to write a plugin that does that, the downside however is that it wouldn&#8217;t run in the web player.</p>
<p>I solved the problem by pre-processing the sound in a small Flash app. It dumps the spectrum data to a text file which is then loaded to Unity3D. When the application plays the sound file, it uses this data to check the values of the spectrum at any position in time. Simple, but does the job.</p>
<p><img src="http://www.everyday3d.com/blog-assets/installation/ins04.jpg" height="282" width="520"/></p>
<p>The installation is part of a project called <strong><a href="http://www.tangoandhawaii.com/">Tango and Hawaii</a> created by Anrick and Luciano</strong>. Be sure to check the <strong><a href="http://www.everyday3d.com/works/installation/colors/">live demo</a></strong>. It was originally presented at the <strong><a href="http://www.magdalena.org/en/event/program/49728/event.html">Magdalena Festival</a></strong> in Maribor, Slovenia.</p>
<p>It was a <strong>new experience for me</strong> to work on an art piece was. It was very inspiring to see what Anrick and Luciano did with a tool I helped them to create. Thank you guys!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=cd82ThxoxI8:Zv_fPv5qUYQ:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=cd82ThxoxI8:Zv_fPv5qUYQ:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=cd82ThxoxI8:Zv_fPv5qUYQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/cd82ThxoxI8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/07/20/format-journey/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/07/20/format-journey/</feedburner:origLink></item>
		<item>
		<title>What can you do with Unity3d? FITC San Francisco</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/YEk6yhuhrwo/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/05/28/fitc-san-francisco-2010/#comments</comments>
		<pubDate>Fri, 28 May 2010 11:22:34 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[august 2010]]></category>
		<category><![CDATA[california]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[fitc]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[san francisco]]></category>

		<guid isPermaLink="false">http://www.everyday3d.com/blog/?p=1418</guid>
		<description><![CDATA[I&#8217;m happy to announce that I will be speaking at FITC San Francisco in August. I have been speaking at FITC events twice this year, and both times it was a fantastic experience. I&#8217;m looking forward for this one, and what really thrills me about it, is the amazing speaker lineup! There are of course [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fitc.ca/events/about/?event=110"><img src="http://www.everyday3d.com/blog-assets/sanfran_fitc.jpg" border="0" height="327" width="520"></a></p>
<p>I&#8217;m happy to announce that I will be speaking at <a href="http://www.fitc.ca/events/about/?event=110">FITC San Francisco</a> in August. I have been speaking at FITC events twice this year, and both times it was a fantastic experience. I&#8217;m looking forward for this one, and what really thrills me about it, is the amazing <strong>speaker lineup</strong>! </p>
<p>There are of course all the usual suspects like <a href="http://blog.je2050.de/">Joa</a>, <a href="http://unitzeroone.com/">Ralph</a>, <a href="http://www.andre-michelle.com/">Andre</a>, <a href="http://www.quasimondo.com/">Mario</a> and <a href="http://sebleedelisle.com/">Seb</a> plus many more great speakers form the community &#8211; you don&#8217;t want to miss any of them. Here&#8217;s a few that particularly caught my attention: </p>
<p><strong><a href="http://blog.inspirit.ru">Eugene Zatepyakin</a></strong> The Actionscript/Alchemy mage from Russia. You may know Eugene from his work on <a href="http://code.google.com/p/in-spirit/wiki/ASSURF">ASSURF</a> which is this amazing image recognition library. I had the pleasure to meet Eugene in Antwerp last year and I can assure you that you won&#8217;t regret attending <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&#038;presentation_id=1204">his presentation</a>. </p>
<p><strong><a href="http://theowatson.com">Theo Watson</a></strong> At FITC Amsterdam 2009 Theo was speaking as a last minute replacement for another presenter who could not make it. It was a lucky coincidence for me, because I really loved what he was showing! Theo is a digital artist working with <a href="http://openframeworks.cc">openFrameworks</a>. In San Francisco he will be taking part in a panel together with <a href="http://blprnt.com">Jer Thorp</a> and <a href="http://processing.org">Ben Fry</a>, the creator of Processing. I&#8217;m sure it will be a very <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&#038;presentation_id=1245">interesting discussion</a>. Theo will also be giving a presentation on <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&#038;presentation_id=1285">interactive storytelling</a> toghether with <a href="http://zanyparade.com">Emily Gobeille</a>. </p>
<p><strong><a href="http://www.yugop.com">Yoko Nakamura</a></strong> Yoko was doing kick-ass Flash stuff on <a href="http://yugop.com">Yugop</a> while I was still learning how to use gotoAndPlay()! I can&#8217;t wait to see the <a href="http://www.fitc.ca/events/speakers/speaker.cfm?event=110&#038;speaker_id=6159">legend live</a>. </p>
<p>And there&#8217;s me. I feel almost insignificant in face of such great talents, but I will do my best to deliver a great presentation. I was speaking in Amsterdam and Toronto and I was happy to see a full house both times for which I only partly credit my amazing speaking talent&#8230; :) It&#8217;s rather that <a href="http://www.unity3d.com">Unity3D</a> is such a hot topic right now.  In San Francisco I will be giving a new, updated presentation entitled <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&#038;presentation_id=1247">&#8220;What can you do with Unity3d?&#8221;</a>. I hope to see you there!</p>
<p>But wait, there&#8217;s more&#8230; so take a look at the complete <a href="http://www.fitc.ca/events/speakers/?event=110">speakers list</a>. If you live in California (or close to) this is an event not to miss. <strong>The super early bird tickets are only available until today (Friday, May 28th) so <a href="http://www.fitc.ca/events/tickets/?event=110">go grab them</a> before it&#8217;s too late!</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=YEk6yhuhrwo:sBKaItfYax8:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=YEk6yhuhrwo:sBKaItfYax8:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=YEk6yhuhrwo:sBKaItfYax8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/YEk6yhuhrwo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/05/28/fitc-san-francisco-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/05/28/fitc-san-francisco-2010/</feedburner:origLink></item>
		<item>
		<title>Loading 3d models at runtime in Unity3d</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/6ZNwyiiImnE/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/05/24/loading-3d-models-runtime-unity3d/#comments</comments>
		<pubDate>Mon, 24 May 2010 13:59:32 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[collada]]></category>
		<category><![CDATA[obj]]></category>
		<category><![CDATA[wavefront obj]]></category>

		<guid isPermaLink="false">http://www.everyday3d.com/blog/?p=1363</guid>
		<description><![CDATA[This post is an addition to the last series I wrote about dynamic content loading in Unity3D. When building a dynamic application, every now and then you might need to load some 3d models at runtime. Either because there's a database with models you want to use or just because you want someone to update [...]]]></description>
			<content:encoded><![CDATA[<p>This post is an addition to the last series I wrote about <a href="http://www.everyday3d.com/blog/index.php/2010/03/08/unity3d-beyond-games/">dynamic content loading</a> in Unity3D. </p>
<p>When building a dynamic application, every now and then you might need to load some 3d models at runtime. Either because there's a database with models you want to use or just because you want someone to update the models without rebuilding the project. I actually had this situation a few weeks ago. Surprisingly, <strong>this option does not come with Unity out of the box</strong>. </p>
<p><strong>Asset bundles and resource folders</strong></p>
<p>But first thing first. I said there's no ready-to-use way to load 3d models at runtime, but it's not 100% true. In fact, there are two options: <strong>asset bundles</strong> and <strong>resource folders</strong>. These methods are discussed <a href="http://unity3d.com/support/documentation/Manual/Loading%20Resources%20at%20Runtime.html">in depth here</a>. </p>
<p>They can both be useful in some cases, but they both have one fundamental drawback: in order to create them, someone needs to open the project in Unity, import the 3d models, create the bundles or resource folders and then export the whole thing again. To create an <strong>AssetBundle</strong> you need to run a script in the editor, while the <strong>Resource Folders</strong>... honestly, I failed to even make them work! </p>
<p>In brief, it's all too complicated for what I was looking for. </p>
<p><strong>A straightforward solution</strong></p>
<p>What I needed and wanted was easy and simple: to <strong>load a 3d object (geometry + some materials and textures) at runtime, using just a URL as parameter</strong>. The only solution seemed to write my own importer. </p>
<p>Basically, I had the choice between <a href="https://collada.org/mediawiki/index.php/COLLADA_-_Digital_Asset_and_FX_Exchange_Schema">Collada</a> and <a href="http://en.wikipedia.org/wiki/Obj">Wavefornt OBJ</a>. I would choose OBJ any time of the day because it's a simple, concise plain-text format, while Collada is bloated and is XML-based. </p>
<p>It's not that I hate XML (although I'm not a big fan either) but in order to parse XML you need to include a pretty weighty DLL in your *.unity3d file, around 850Kb, which in this case (and in many others) defeats the purpose. Still, it's good to know that it possible, and there are situations when it's ok to use it. If you want to learn <strong>more about Unity3D and XML</strong> there's a <a href="http://www.paultondeur.com/2010/03/23/tutorial-loading-and-parsing-external-xml-and-json-files-with-unity-part-1-xml/">awesome article</a> on this topic by <a href="http://www.paultondeur.com"/>Paul Tondeur</a>. </p>
<p>It turned out that while it's not rocket science to write an OBJ importer, it's not exactly banal either. I spent a few days coding it so I thought I'll share this with everyone - maybe someone will make good use of it. </p>
<p>Here's <a href="http://www.everyday3d.com/unity3d/obj/obj.1.1.unitypackage">a package with the source code (v1.1)</a>, along with a simple scene demonstrating how it works. In fact it couldn't be simpler. All you have to do is to create an instance of the OBJ class and start a coroutine to load the contents, like this: </p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span> path = <span style="color: #808080;">"http://www.everyday3d/unity3d/obj/monkey.obj"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">OBJ obj = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> OBJ<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">StartCoroutine<span style="color: #000000;">&#40;</span>obj.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span>path<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Supported features</strong></p>
<ul>
<li>Vertex, normals and UV data</li>
<li>Multiple objects per file</li>
<li>Vertex groups and multiple materials per object</li>
<li><a href="http://en.wikipedia.org/wiki/Material_Template_Library">MTL</a> files, diffuse and specular materials</li>
<li>Basic textures</li>
</ul>
<p>And it's all at a cost of ~12Kb extra added to your final file!</p>
<p><strong>Testing and the universality of OBJ format</strong></p>
<p>In the 3D world the <strong>OBJ format is nearly universal</strong> - I think that every 3D editor in existence is able to export to this format. This also means that Wavefront files come in many different flavors.</p>
<p>I tested the code against models created with <a href="http://blender.org">Blender</a> and against common sense assumptions on how an OBJ file can be constructed. If it doesn't work with files exported from your editor send me the OBJ file, and if possible I'll update the code. It's <strong>released under the MIT license</strong> so feel free to use it in your projects, commercial or not.</p>
<p>That's it! I hope you'll find it useful! </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=6ZNwyiiImnE:YJuh1uCrE0U:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=6ZNwyiiImnE:YJuh1uCrE0U:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=6ZNwyiiImnE:YJuh1uCrE0U:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/6ZNwyiiImnE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/05/24/loading-3d-models-runtime-unity3d/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/05/24/loading-3d-models-runtime-unity3d/</feedburner:origLink></item>
		<item>
		<title>Runtime objects in Unity3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/oFQ_DagcWEo/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/04/14/runtime-objects-with-unity3d/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 11:30:04 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[city]]></category>
		<category><![CDATA[generating 3d geometry]]></category>
		<category><![CDATA[material]]></category>
		<category><![CDATA[procedural city]]></category>
		<category><![CDATA[procedural mesh]]></category>
		<category><![CDATA[self-lit shader]]></category>
		<category><![CDATA[texture]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=1272</guid>
		<description><![CDATA[Unity3D can work with meshes created in external 3D editors, but geometry can also be created with code. And not only geometry, but materials and textures as well. To test all these options I created a simple cityscape. I got inspired by this set of awesome pictures and also by a project called Pixel City [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everyday3d.com/unity3d/city/04/"><img src="http://www.everyday3d.com/unity3d/city/city.jpg" width="520" height="239" border="0"></a></p>
<p><strong><a href="http://unity3d.com">Unity3D</a></strong> can work with meshes created in external 3D editors, but <strong>geometry can also be created with code</strong>. And not only geometry, but materials and textures as well. To test all these options I created a simple cityscape. I got inspired by this set of <a href="http://www.boston.com/bigpicture/2010/03/nyc_and_las_vegas_from_above_a.html">awesome pictures</a> and also by a project called <a href="http://www.youtube.com/watch?v=-d2-PtK4F6Y">Pixel City</a> by <a href="http://www.shamusyoung.com/">Shamus Young</a>. </p>
<p><strong>Creating meshes</strong></p>
<p>All information about the geometry of an object is stored in the <code><a href="http://unity3d.com/support/documentation/ScriptReference/Mesh.html">Mesh</a></code> object inside the <code><a href="http://unity3d.com/support/documentation/ScriptReference/MeshFilter.html">MeshFilter</a></code> component. A mesh is composed of an array of vertices grouped into triangles and with UV information added to it. It's a pretty common way to store information on 3d geometry, similar to what you can find in Actionscript - <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Graphics.html#drawTriangles%28%29">Graphics.drawTriangles</a> expects arguments in the same data format. Many file formats out there store meshes that way too, ex. <a href="http://en.wikipedia.org/wiki/Obj">Wavefront OBJ</a> (which makes writing importers/exporters relatively easy by the way).</p>
<p>Creating a mesh with code means populating the arrays of vertices, triangles and UVs. While it is pretty straightforward, even building a simple cube can be tricky and the code quickly becomes a unmanageable list of numbers. In the <a href="http://www.everyday3d.com/unity3d/city/city.unityPackage">source code</a>, the buildings are generated in the <strong>BuildingBuilder.cs</strong> file, so you can see it for yourselves.</p>
<p><strong>Creating textures</strong></p>
<p>We've <a href="http://www.everyday3d.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/">already seen</a> that any bitmap you import into a Unity3D project is represented by the class <code><a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.html">Texture2D</a></code>. <strong>Of course, bitmaps don't have to be imported - they can be created from scratch</strong>. The constructor of the Texture2D class take a few arguments, including the width and height of the image. </p>
<p>Once a new texture is created all it's pixels are empty (i.e. black and transparent). Their values can be changed either on a pixel-per-pixel basis using the <code><a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.SetPixel.html">SetPixel</a></code> method or by copying portions of other bitmaps using <code><a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.SetPixels.html">SetPixels</a></code>. </p>
<p>In the above example I have 6 predefined textures with different types of windows, so I don't create those from scratch. However I use a <strong>procedural texture for the illumination maps</strong>. I generate a 64x64 bitmap where the value of each pixel determines the brightness of a single window (i.e. how much light it emits). It's pretty basic: after the Texture2D is created I just run through all it's pixels and assign a random value to it's alpha component.</p>
<p><strong>Creating materials</strong></p>
<p>There are 6 different textures representing a different type of window each and one illumination map. <strong>How to put these together? That's what materials are used for.</strong> As with any other element, materials are represented by the <code><a href="http://unity3d.com/support/documentation/ScriptReference/Material.html">Material</a></code> object in scripts, and they can be created with code. The constructor takes only one argument: a shader. </p>
<p><strong>Shaders are one of the most crucial elements of Unity3D</strong> (and any other 3D rendering engine for that matter). They describe how a 3D geometry will be rendered, what colors and/or textures will be used and how it will interact with light. For the buildings I use a shader called <a href="http://unity3d.com/support/documentation/Components/shader-SelfIllumDiffuse.html">Self-Illuminated Diffuse</a>. It's one of Unity3D built-in shaders. </p>
<p>Shaders usually need some parameters to work with - like colors or textures. <strong>A material is essentially a shader and a number of objects that define it's parameters.</strong> Self-Illuminated shaders expect one texture for the color and the other that determines the amount of light emitted by this texture. It's great for creating objects that emit light like bulbs, neon signs or... windows in a night scenery (it's important to understand however that the object emits light but this light doesn't illuminate any other objects around it). </p>
<p>I use the window image as the color texture, and the procedural image with random alpha values as the illumination map texture. The trick is that I set the scale of the color texture to 64. This way the window is repeated 64x64 times on the material and each pixel of the procedural illumination map (scaled 1:1) corresponds to one single window. I also set the filtering mode of the illumination map texture to <a href="http://unity3d.com/support/documentation/ScriptReference/FilterMode.Point.html">Point</a>, so that it doesn't get blurred when seen form a bigger distance. </p>
<p><strong>A word on optimization</strong></p>
<p>The generated buildings have different width, height and depth. A natural solution to apply textures on all of them was to create a material that repeats the windows the appropriate amount of times for each building. Ex. a 4 story building with 3 windows in a row would have a material where the x-scale of the texture is set to 3 and y-scale to 4. The emission map scale needs to be divided by 64 in this case, giving values of 3/64 and 4/64 respectively. </p>
<p>While this seems quite ok, it poses an optimization problem. Unity3D is much more effective when there's a <strong>lower amount of meshes composed of large amount of vertices</strong>, rather that the other way around - lots of meshes with few vertices. One building has 20 vertices and I create 2500 separate meshes! It's far from optimal, and you can really feel the framerate going down because of that. Fortunately there is a <strong>built-in script called CombineChildren</strong> that automatically combines all the buildings into one huge mesh making everything work much faster and smoother. But (of course) there is a trick!</p>
<p>Unity3D will combine objects only <strong>if they share the same, exact material</strong>. The scale of a texture on a material is unique, so if there are two materials that are identical and the only difference is the scale of the texture, we still need 2 different materials. In the above scenario almost each building uses a different material, unless it has exactly the same number of stories and the same number of windows in a row. I had to come up with a way to use only one material, and to deal with texture coordinates in a different way. </p>
<p>The answer is to <strong>use UVs instead of the texture scaling</strong>. So <strong>I started by creating only one material</strong>, which contains 64x64 windows. If a building is ex. 20 stories high and has 6 windows in a row, this means that the wall of the building needs to be mapped to the texture with this coordinates [0, 0, 6/64, 20/64]. Remember that <strong>UV values are normalized</strong>, i.e have values between 0 and 1, 0 pointing to the left/top pixel of the texture, and 1 to the right/bottom. </p>
<p>This way I can reuse the same material on every building regardless of it's size. It works even on buildings that are higher that 64 stories, because UV values are repeated - ex. an UV value of 1.2 is the same as 0.2. Perfect!</p>
<p>One little problem still persist though. Since each building uses the same material it also has the same pattern of lit and unlit windows. It doesn't look nice. Fortunately there was an easy solution for this: to offset the UVs of each building by a random value multiplied by 1/64. That way each building is mapped to a different area of the of the material and things look more natural.</p>
<p><strong>Effects</strong></p>
<p>To make the cityscape more interesting I added a Glow image effect to the camera. It adds a subtle glow around lit areas of the scene - in this case the windows, giving it a slightly blurry look.</p>
<p><strong>Source</strong></p>
<p>You can grab the package with the <a href="http://www.everyday3d.com/unity3d/city/city.unityPackage">source code here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=oFQ_DagcWEo:XjLkM9wm96g:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=oFQ_DagcWEo:XjLkM9wm96g:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=oFQ_DagcWEo:XjLkM9wm96g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/oFQ_DagcWEo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/04/14/runtime-objects-with-unity3d/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/04/14/runtime-objects-with-unity3d/</feedburner:origLink></item>
		<item>
		<title>Unity3D tutorial in .NET magazine</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/hHrnHUkb1lU/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/03/31/unity3d-tutorial-in-net-magazine/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 10:57:53 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=1244</guid>
		<description><![CDATA[Recently I had the privilege to write an article for .NET magazine. It's an introductory tutorial to Unity3D in which you'll see how to build a car simulation in a simple desert scenery. Those of you who had attended my sessions at FITC Amsterdam and at the March LFPUG meeting have already seen me building [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everyday3d.com/unity3d/jeep/"><img src="http://www.everyday3d.com/unity3d/jeep/jeepwillys.jpg" width="520" height="349" border="0"></a></p>
<p>Recently I had the privilege to write an article for <a href="http://www.netmag.co.uk/">.NET magazine</a>. It's an introductory tutorial to <a href="http://www.unity3d.com">Unity3D</a> in which you'll see how to build a car simulation in a simple desert scenery. </p>
<p>Those of you who had attended my sessions at <a href="http://www.fitc.ca/events/about/?event=101">FITC Amsterdam</a> and at the March <a href="http://www.lfpug.com">LFPUG</a> meeting have already seen me building it live. The nice thing about Unity3D IDE and its drag &#038; drop abilities is that you can actually create a car simulation in 10 minutes. But don't be fooled, because tweaking it afterward takes ages - as with everything else. Anyway, now you can see and try it yourself. I hope you'll like it!</p>
<p>The tutorial will lead you through different features of Unity3D like <strong>the terrain editor, 3D assets import, built-in scripts, projected shadows and particle system</strong>. It is available in the UK and elsewhere in Europe from <strong>March 30th (issue 201)</strong>. It will be published in the US and Canada too, but a month later (also please note that .NET Magazine is called <strong>Practical Web Design on the other side of the Atlantic</strong>).</p>
<p>To make the tutorial as enjoyable as possible I put in all my modeling skills to create a nice car - a classic <strong>U.S. Army Jeep Willys</strong>. I also added a few simple scenery models like a hut and a dried tree trunk that can be used as obstacles. You can see a demo based on those models <a href="http://www.everyday3d.com/unity3d/jeep/">here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=hHrnHUkb1lU:5QK3sWibkBo:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=hHrnHUkb1lU:5QK3sWibkBo:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=hHrnHUkb1lU:5QK3sWibkBo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/hHrnHUkb1lU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/03/31/unity3d-tutorial-in-net-magazine/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/03/31/unity3d-tutorial-in-net-magazine/</feedburner:origLink></item>
		<item>
		<title>A cinematic video player</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/HVGqF72fUOI/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/03/19/cinematic-video-player/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:44:56 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[archive.org]]></category>
		<category><![CDATA[big buck bunny]]></category>
		<category><![CDATA[creative commons]]></category>
		<category><![CDATA[movie]]></category>
		<category><![CDATA[ogg theora]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[sita sings the blues]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[video player]]></category>
		<category><![CDATA[wikipedia]]></category>
		<category><![CDATA[www.movie]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=1163</guid>
		<description><![CDATA[Here's a little piece I made after the image decomposer. This time I wanted to load videos instead of images. I had the idea to project them on a big screen so that the user can actually feel like he is in a movie theater. I started to play with it, I modeled a cinema [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everyday3d.com/unity3d/theatre/?movie=http://ia331424.us.archive.org/2/items/Sita_Sings_the_Blues/Sita_Sings_the_Blues.ogv"><img src="http://www.everyday3d.com/unity3d/theatre/theatre.jpg" border="0" width="520" height="264"></a></p>
<p>Here's a little piece I made after the <a href="http://www.everydayflash.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/">image decomposer</a>. This time I wanted to <strong>load videos</strong> instead of images. I had the idea to project them on a big screen so that the user can actually feel like he is in a <strong>movie theater</strong>. I started to play with it, I modeled a cinema interior, setup the lightning and I thought it's pretty neat.</p>
<p>You can walk around the theater with cursor keys and space to jump over the seats. If you go into the corridor in the back the movie will pause (wouldn't it be nice if that happened in real life too?). Use the left mouse button to toggle a flashlight. </p>
<p><strong>Unity3D</strong> currently supports videos in <strong><a href="http://www.theora.org/">Ogg Theora</a> format only</strong>. Although it's free, it is not very popular on the net. It's mainly used by <a href="http://en.wikipedia.org">Wikipedia</a> and <a href="http://www.archive.org">Archive.org</a> for the video content. </p>
<p>The demo works the same way as the <a href="http://www.everydayflash.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/">image decomposer</a>, which means you can append a URL to any valid <a href="http://wiki.xiph.org/List_of_Theora_videos">Ogg video</a> on the web and you should be able to watch it. To start, here are a few interesting movies I found:</p>
<p><a href="http://www.everyday3d.com/unity3d/theatre/?movie=http://ia331424.us.archive.org/2/items/Sita_Sings_the_Blues/Sita_Sings_the_Blues.ogv"><strong>Sita Sings The Blues</strong></a>, an animated film produced and directed by Nina Paley. <a href="http://www.sitasingstheblues.com/">More info...</a></p>
<p><a href="http://www.everyday3d.com/unity3d/theatre/?movie=http://mirror.bigbuckbunny.de/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.ogg"><strong>Big Bucks Bunny</strong></a>, a short computer animated film by the Blender Institute. <a href="http://www.bigbuckbunny.org/">More info...</a></p>
<p><a href="http://www.everyday3d.com/unity3d/theatre/?movie=http://ia301530.us.archive.org/1/items/TheBlobTrailer/The_Blob_trailer.ogv"><strong>The Blob trailer</strong></a>, 1958 movie with Steve McQueen. Back then it was scary, today it's funny. </p>
<p><a href="http://www.everyday3d.com/unity3d/theatre/?movie=http://ia311336.us.archive.org/1/items/TheAdventuresOfFlashGordon/TheAdventuresOfFlashGordon7-15-1955.ogv"><strong>The Adventures of Flash Gordon</strong></a>, 1955. Probably a very bad movie. </p>
<p>Dynamic loading of videos in Unity is easy and it's <a href="http://unity3d.com/support/documentation/ScriptReference/WWW-movie.html">well documented</a>. The code is almost exactly that same as with images. I won't publish the sources this time because there is very little code in it, on the other hand there are over 50MB of textures in a pretty big mess.</p>
<p>If you find (or create) <strong>an Ogg encoded video worth watching</strong> post a link in the comments.<br />
Have fun!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=HVGqF72fUOI:HGzfzHB1Xls:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=HVGqF72fUOI:HGzfzHB1Xls:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=HVGqF72fUOI:HGzfzHB1Xls:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/HVGqF72fUOI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/03/19/cinematic-video-player/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/03/19/cinematic-video-player/</feedburner:origLink></item>
		<item>
		<title>3 ways to draw 3D lines in Unity3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/8NgmxlTrsEo/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 11:53:03 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[3d lines]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[GL]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[scribbler]]></category>
		<category><![CDATA[unity3d pro]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=1044</guid>
		<description><![CDATA[Just as I was thinking about an interesting demo to play with drawing functions in Unity3D, Mrdoob published his Harmony drawing tool made with HTML5/Canvas. It looks really cool, so I though how about doing this in 3D? I only had to figure out how to draw lines. I did some research and below I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everyday3d.com/unity3d/drawing/"><img src="http://www.everyday3d.com/unity3d/drawing/drawing.jpg" width="520" height="280" border="0"></a></p>
<p>Just as I was thinking about an interesting demo to play with drawing functions in <a href="http://www.unity3d.com">Unity3D</a>, <a href="http://www.mrdoob.com">Mrdoob</a> published his <a href="http://mrdoob.com/projects/harmony/">Harmony</a> drawing tool made with HTML5/Canvas. It looks really cool, so I though how about doing this in 3D? I only had to figure out how to draw lines.</p>
<p>I did some research and below I present <strong>3 different solutions</strong>. You can grab the source of the examples discussed below <a href="http://www.everydayflash.com/unity3d/drawing/lines3d.unitypackage">here</a>. </p>
<p><strong>Drawing lines with Line Renderer</strong> [<a href="http://www.everyday3d.com/unity3d/drawing/lr.html">demo</a>]</p>
<p>When it comes to lines, the first thing you'll bump into in the Unity3D API is the <a href="http://unity3d.com/support/documentation/ScriptReference/LineRenderer.html">Line Renderer</a> component. As the name suggests, it is used to draw lines so it seems the right tool for the job. Lines in this case are defined by 2 or more points (segments), a material and a width. </p>
<p>It has an important limitation: <strong>the line must be continuous</strong>. So if you need two lines, you need two renderers. The other problem is that the Line Renderer acts very strangely when new points are added dynamically. The width of the line does not seem to render correctly. It's either <strong>buggy or just wasn't designed for such use</strong>. Because of these limitations I had to create a separate Line Renderer for each tiny bit of line I'm drawing. </p>
<p>It was easy to implement, but not very fast since I end up spawning lots of GameObjects each with a LineRenderer attached. It seems to be the <strong>only option if you don't have Unity3D Pro</strong> though.</p>
<p><strong>Drawing lines as a mesh using Graphics</strong> [<a href="http://www.everyday3d.com/unity3d/drawing/gr.html">demo</a>]</p>
<p>The <a href="http://unity3d.com/support/documentation/ScriptReference/Graphics.html">Graphics</a> class allows to draw a mesh directly without the overhead of creating game objects and components to hold it. It <strong>runs much faster than Line Renderer</strong>, but you need to create the lines yourself. This is a bit more difficult but also gives you total control of the lines - their color, material, width and orientation. </p>
<p>Since meshes are composed of surfaces rather than lines or points, in 3D space a line is best rendered as a very thin quad. A quad is described with 4 vertices, and usually you'll only have the start and end points and a width. Based on this data you can compute a line like this:</p>
<div class="igBar"><span id="lcsharp-4"><a href="#" onclick="javascript:showPlainTxt('csharp-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-4">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 normal = Vector3.<span style="color: #0000FF;">Cross</span><span style="color: #000000;">&#40;</span>start, end<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 side = Vector3.<span style="color: #0000FF;">Cross</span><span style="color: #000000;">&#40;</span>normal, end-start<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">side.<span style="color: #0000FF;">Normalize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 a = start + side * <span style="color: #000000;">&#40;</span>lineWidth / <span style="color: #FF0000;color:#800000;">2</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 b = start + side * <span style="color: #000000;">&#40;</span>lineWidth / -<span style="color: #FF0000;color:#800000;">2</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 c = end + side * <span style="color: #000000;">&#40;</span>lineWidth / <span style="color: #FF0000;color:#800000;">2</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 d = end + side * <span style="color: #000000;">&#40;</span>lineWidth / -<span style="color: #FF0000;color:#800000;">2</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>First, you get the normal of the plane on which both start and end vectors lie. This will be the plane on which the line-quad will located. The cross product of the normal and of the difference between end and start vectors gives you the side vector (the "thin" side of the quad). You need to normalize it to make it a unit vector. Finally calculate all 4 points of the rectangle by adding the side vector multiplied by half width to both start and end points in both directions. In the <a href="http://www.everydayflash.com/unity3d/drawing/lines3d.unitypackage">source code</a> all this happens in <code>MakeQuad</code> and <code>AddLine</code> methods, so take a look in there.</p>
<p>It wasn't easy to implement, but once I was there it runs pretty fast.</p>
<p><strong>Direct drawing with GL</strong> [<a href="http://www.everyday3d.com/unity3d/drawing/">demo</a>]</p>
<p><strong>No fast is fast enough!</strong> Instead of leaving this topic and live happily with the Graphics solution, I kept searching for something even better. And I found the <a href="http://unity3d.com/support/documentation/ScriptReference/GL.html">GL class</a>. GL is used to "issue rendering commands similar to OpenGL's immediate mode". This sounds like fast, doesn't it? It is! </p>
<p>Being much easier to implement that the Graphics solution it is a <strong>clear winner for me</strong>, the only drawback being that <strong>you don't have much control over the appearance of the lines</strong>. You can't set a width and perspective does not apply (i.e. lines that are far behind look exactly the same as those that are close to the camera). </p>
<p><strong>Conclusion</strong></p>
<p>For massive &#038; dynamic line drawing LineRenderer is not the best solution, but it is the only one available in Unity free version. It can surely be useful to draw limited amounts of static lines and this is probably what it was made for. If you do have Unity3D Pro, the solution with Graphics is reasonable and very flexible but if it is performance you're after <strong>choose GL.</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=8NgmxlTrsEo:pHHmSqyQ0go:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=8NgmxlTrsEo:pHHmSqyQ0go:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=8NgmxlTrsEo:pHHmSqyQ0go:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/8NgmxlTrsEo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/</feedburner:origLink></item>
		<item>
		<title>Loading and manipulating images in Unity3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/yIJPMxJA0jU/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 06:52:39 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[dynamic content]]></category>
		<category><![CDATA[loading images]]></category>
		<category><![CDATA[unity3d tutorial]]></category>
		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=935</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="/unity3d/cubepict/?image=medusa.jpg"><img src="/unity3d/cubepict/imagedecomposer.jpg" width="520" height="280" border=0"></a></p>
<p>As <a href="http://www.everydayflash.com/blog/index.php/2010/03/08/unity3d-beyond-games/">I promised</a> here's the first article exploring <a href="http://www.unity3d.com">Unity</a> as a 3D web application tool. </p>
<p>Every web application nowadays is data driven, therefore the ability to dynamically load assets is crucial. Unity3D can load <strong>plain text, images, video and sound.</strong> Since loading plain text is not so interesting, <strong>I thought I'd see how it works with an image</strong>. </p>
<p>Here's a little experiment I called "<a href="/unity3d/cubepict/?image=medusa.jpg"><strong>Image Decomposer</strong></a>". It loads an image passed as parameter in the URL and creates a wall of little cubes which colors are based on the pixels of the image. When you rollover the cubes they fall down slowly decomposing it, hence the name.</p>
<p>The code is pretty simple, you can <a href="http://www.everyday3d.com/unity3d/cubepict/imageDecomposer.unityPackage">get the source here</a>. Below are a few things I found out while making it.</p>
<p><strong>URL parameters</strong></p>
<p>A very useful way to pass parameters to your swf files is to attach them as a <strong>query string</strong> in the embedding HTML, like this: <code>flash.swf?paramA=valueA&#038;paramB=valueB</code>. It's a Flash classic! </p>
<p>The good news is that is also works in Unity. Take a look a the <a href="view-source:http://www.everyday3d.com/unity3d/cubepict/?image=medusa.jpg">HTML source</a> of the demo to see how the image URL is passed to the unity3d file. Inside Unity3D it's very easy to get access to it through a static property called <code><a href="http://unity3d.com/support/documentation/ScriptReference/Application-srcValue.html">Application.srcValue</a></code>. It returns the whole path, including the file name and you need to parse the query string yourself. Here's a sample code in C#:</p>
<div class="igBar"><span id="lcsharp-9"><a href="#" onclick="javascript:showPlainTxt('csharp-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-9">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span> su = Application.<span style="color: #0000FF;">srcValue</span>; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span> qs = su.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span>su.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"?"</span><span style="color: #000000;">&#41;</span> + <span style="color: #FF0000;color:#800000;">1</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">char</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> deli = <span style="color: #808080;">"="</span>.<span style="color: #0000FF;">ToCharArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> ps = qs.<span style="color: #0000FF;">Split</span><span style="color: #000000;">&#40;</span>deli<span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The 'ps' array now contains pairs of key/values from the query string.</p>
<p><strong>Loading freedom</strong></p>
<p>Unity3D supports <strong>JPG and PNG format</strong>. Sadly GIFs are not supported, even animated... ;) The really nice thing is that <strong>there aren't any security restrictions</strong> when loading files from other domains. This is something that drove me crazy so many times with Flash! In Unity3D <strong>pass a valid URL and it will load the asset</strong>, it's so simple. If you don't believe me - just paste any link pointing to an image in the demo ("image" parameter in the URL) and see it for yourself.</p>
<p>I wouldn't expect things to be like that forever though, so use it while you can people!</p>
<p><strong>Coroutines and C#</strong></p>
<p>To deal with asynchronous events, like loading an external asset, Unity3D uses <strong>coroutines</strong>. They are a bit different from events in AS3, but not very much. If you are a fan of C# and want to use coroutines you may find the official documentation a bit unclear. So, first, read the official documentation <a href="http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html">here</a> and <a href="http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html">here</a>, and continue reading this post afterward. </p>
<p>What caught my attention is that to use the <strong>yield statement</strong>, the enclosing method must return <strong>IEnumerator</strong>. But all of the inherited methods in MonoBehavior, like Start(), Update() and the event handling ones return void. </p>
<p>Surprisingly, it turns out that you can just <strong>change the signature of any of those methods</strong> so that they return IEnumerator! If this isn't breaking OOP rules, I don't know what is. But, since it works, it's ok I guess. It's certainly not obvious. Otherwise it is possible to create a custom function that returns IEnumerator and use the StartCoroutine() method of MonoBehavior to run it. </p>
<p>Another thing is that with C# you need to write <code>yield return...</code> not just <code>yield...</code> The official docs being written in Javascript they tend to omit the <code>new</code> operator as well, and C# does not like that. So, if the docs say: </p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">yield WaitForSeconds<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>and you copy/paste this to a C# script, you need to edit this line and make it look like this: </p>
<div class="igBar"><span id="lcsharp-11"><a href="#" onclick="javascript:showPlainTxt('csharp-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-11">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">yield <span style="color: #0600FF;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WaitForSeconds<span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">2</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>If you keep this in mind you will spare yourself some annoying compile errors.</p>
<p><strong>Scaling images (or why you don't need to do this)</strong></p>
<p>Once the image is loaded, it can be assigned to a <a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.html">Texture2D</a> object, which is the type to store bitmaps in Unity3D. From now on it can be used as a texture for any material. For example, you can create a plane and assign it as the main texture of the plane's material or use <a href="http://unity3d.com/support/documentation/ScriptReference/GUI.Label.html"><code>GUI.Label</code></a> to display the picture in 2D. But let's do something more interesting.</p>
<p>Texture2D has a few methods to extract information from the image, the most basic being <a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.GetPixel.html"><code>GetPixel()</code></a> and <a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.SetPixel.html"><code>SetPixel()</code></a>. They work exactly the same way as their equivalents in AS3 BitmapData class. The first allows to get the color of a pixel at a given coordinate, the other does the opposite.</p>
<p>When you start to play with these and you use images embedded in the project, make sure to <strong>select the "Is Readable" checkbox</strong> in the inspector. Images loaded dynamically are <strong>readable by default</strong>. </p>
<p>In the demo, no matter how big the loaded image is, the amount of cubes generated remains the same (it will adapt for different aspect ratios though). My first idea was to scale the image to something like <strong>50x50 pixels</strong>, and then using <code>getPixel()</code> to <strong>fetch the color for each cube</strong>. But I found out that <strong>there isn't any function to resize an image</strong> in the API. Sure, I could write my own function, but this can get quite complex as you can see <a href="http://forum.unity3d.com/viewtopic.php?t=25191&#038;highlight=resizing+texture2d">here</a>. Fortunately there is a better way.</p>
<p>Texture2D has a method called <a href="http://unity3d.com/support/documentation/ScriptReference/Texture2D.GetPixelBilinear.html"><code>GetPixelBilinear()</code></a>. It uses <a href="http://en.wikipedia.org/wiki/Bilinear_filtering">bilinear filtering</a> to evaluate the color of the image at a specific point defined by <strong>normalized coordinates</strong> (i.e. in 0-1 range). If the word "bilinear" sounds familiar to you it's because <strong>Photoshop also uses this algorithm</strong> to scale images. With this method the same code can be used to get pixel colors from images regardless of their size and aspect ratio: </p>
<div class="igBar"><span id="lcsharp-12"><a href="#" onclick="javascript:showPlainTxt('csharp-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-12">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Color c1 = image.<span style="color: #0000FF;">GetPixelBilinear</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">0</span>,<span style="color: #FF0000;color:#800000;">0</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// always top-left color</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Color c2 = image.<span style="color: #0000FF;">GetPixelBilinear</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">1</span>,<span style="color: #FF0000;color:#800000;">1</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// always bottom-right </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It's much more elegant (and faster) than scaling images! </p>
<p>As a side note: it would be also very easy to implement an actual resizing function using this method, in case you really need that. I'm sure that by now you can figure out how to do this :)</p>
<p><strong>What's next?</strong></p>
<p>The above example is simple but I hope it shows you how to get started with dynamic content. As far as images are concerned, much more is possible. By using <a href="http://unity3d.com/support/documentation/Manual/Shaders.html">custom shaders</a> and <a href="http://unity3d.com/support/documentation/ScriptReference/RenderTexture.html">render textures</a> you can apply <strong>filter effects to images (and video)</strong>. However, these features are available <strong>only in Unity3D Pro</strong> and besides, explaining it would make this post way too long. I'll do that in a separate article instead.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=yIJPMxJA0jU:gSIYlEpDy1w:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=yIJPMxJA0jU:gSIYlEpDy1w:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=yIJPMxJA0jU:gSIYlEpDy1w:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/yIJPMxJA0jU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/</feedburner:origLink></item>
		<item>
		<title>Unity3D: beyond games</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/siYb7gmsNmc/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/03/08/unity3d-beyond-games/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 11:34:32 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[fitc amsterdam]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=923</guid>
		<description><![CDATA[I am not a game developer. For the last 10 years (with some short intervals) I've been working as a Flash designer and developer and I have been creating projects more or less related to advertising such as animations (including banners, that I actually enjoyed making), video sites, rich media interfaces, web applications, 3d simulations [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I am not a game developer.</strong> For the last 10 years (with some short intervals) I've been working as a Flash designer and developer and I have been creating <strong>projects more or less related to advertising</strong> such as animations (including banners, that I actually enjoyed making), video sites, rich media interfaces, web applications, 3d simulations and, sometimes indeed, simple games. </p>
<p>I believe however, that <strong><a href="http://www.unity3d.com">Unity3D</a> is much more that a game development platform</strong>, and all those kind of projects could be tackled with Unity3D as well. In some cases the <strong>result would be pretty awesome</strong> and way beyond anything we can currently dream of with Flash and Actionscript - and this kind of opportunity is what I am looking for. (In some other cases it could end up with a disaster, similar to what happens when sites that clearly require HTML are done with Flash. We will see those too, simply because <em>errare humanum est</em>).</p>
<p>Technology adoption is not as fast as we could wish. I'm sure that eventually <strong>Unity3D will become the standard for 3D</strong> applications on the web, but we're not there yet. So far it has been very successful with games for the iPhone and it starts to emerge as the tool of choice for online games. The advertising business will follow and adopt it as well. We can expect top interactive agencies and production companies to start releasing Unity3D productions soon. I hope this will happen within this or the next year. Chances are that <strong>such projects are already in the making</strong>.</p>
<p>The reason why this will happen is that <strong>Unity3D is versatile</strong>. It is marketed as a "game development tool", but it has numerous features that allow much more that that. It allows to <strong>integrate diversified content (2D, 3D, video, sound)</strong>, has a <strong>great animation tool</strong> and <strong>a powerful scripting API</strong> to create any kind of complex logic.</p>
<p>As I got back from <a href="http://www.fitc.ca/events/about/?event=101">FITC Amsterdam</a> loaded with new energy and inspiration, I decided to take a deeper look at Unity3D scripting and go at least a bit beyond the basics and beyond the "building a 3rd person shooter" scenario. As a long time Flash developer there are some problem/questions that are typical to Actionscript technology and I decided to check how similar problems can be solved with Unity3D. Here are the first few questions that came to my mind, pretty basic actually:</p>
<p><strong>1. <a href="http://www.everydayflash.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/">How to dynamically load an image into Unity3D and do something with it?</a><br />
2. <a href="http://www.everydayflash.com/blog/index.php/2010/03/19/cinematic-video-player/">How to load a video?</a><br />
3. <a href="http://www.everydayflash.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/">How to draw lines, points and shapes at runtime?</a><br />
4. <a href="http://www.everyday3d.com/blog/index.php/2010/04/14/runtime-objects-with-unity3d/">How to generate content with code?</a></strong></p>
<p><del datetime="2010-03-19T20:31:27+00:00">The questions order starts with those that have been easiest to answer.</del> I have some more questions lined up, so this post might get updated. Anyway, in the coming days (or weeks rather) I'll be posting the solutions. I made some experiments, I have some code to share and some tips that I found on the way. See you soon!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=siYb7gmsNmc:48w6G3_Z7wM:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=siYb7gmsNmc:48w6G3_Z7wM:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=siYb7gmsNmc:48w6G3_Z7wM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/siYb7gmsNmc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/03/08/unity3d-beyond-games/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/03/08/unity3d-beyond-games/</feedburner:origLink></item>
		<item>
		<title>Speaking in Amsterdam, London &amp; Toronto</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/080kpamrGhg/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2010/01/19/speaking-in-amsterdam-london-toronto/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 16:32:45 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Unity3d]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=887</guid>
		<description><![CDATA[The conference season is upon us! Following my last year short presentation at Flash On The Beach and at the Warsaw Flash Camp, this year I will continue my adventure with public speaking. In the next months I will be having my sessions at 3 highly interesting events. 1. FITC Amsterdam, February 22nd-23rd FITC Amsterdam [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.everyday3d.com/blog-assets/conferencesPost.jpg" alt="Amsterdam, London, Toronto" width="520" height="300"/></p>
<p><strong>The conference season is upon us!</strong> </p>
<p>Following my last year <a href="http://www.everydayflash.com/blog/index.php/2009/09/29/fotb09-3d-bowling-demo/">short presentation</a> at <a href="http://www.flashonthebeach.com/">Flash On The Beach</a> and at the <a href="http://www.everydayflash.com/blog/index.php/2009/06/23/warsaw-flash-camp-2009/">Warsaw Flash Camp</a>, this year I will continue my adventure with public speaking. In the next months I will be having my sessions at 3 highly interesting events. </p>
<p><strong>1. <a href="http://www.fitc.ca/events/about/?event=101">FITC Amsterdam, February 22nd-23rd</a></strong></p>
<p><strong>FITC Amsterdam</strong> is only a few weeks away. I've been to FITC last year and I really enjoyed the conference (and the parties too). I am thrilled to be back this year as a speaker. If you want to catch my session it's on <strong>Monday (Feb 22nd) at 12:30</strong>. If you are interested in Unity and in 3D in general you should definitely attend! For more information, here's a detailed <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=101&#038;presentation_id=1003">session description</a>. I hope to see you there!</p>
<p>FITC it's of course much more than my presentation. There are <strong>2 days packed with interesting sessions</strong>, so be sure to checkout <a href="http://www.fitc.ca/events/schedule/?event=101">the schedule</a> to see what's interesting for you. There is also a party every evening - a great opportunity to do some networking and to have a few beers and some other stuff (remember, we're in Amsterdam!). So grab <a href="http://am10.eventbrite.com/">your tickets</a> before they're all gone!</p>
<p><strong>2. <a href="http://www.lfpug.com/">London LFPUG Meeting, March 25th</a></strong></p>
<p>If you can't attend FITC and you miss my session in Amsterdam, don't panic! You can catch me again next month in London. On <strong>March 25th</strong> I will speak at the next in the series of <strong>LFPUG</strong> meetings. </p>
<p>It will be a evening packed with realtime 3D, as I will be speaking together with <a href="http://www.infiniteturtles.co.uk/blog/">Rob Bateman</a> from the <a href="http://www.away3d.com">Away3D</a> team. Here's <a href="http://www.lfpug.com/25th-march-2010-25032010/">some detailed info</a> about the event. The event is free, all you need to do is register, so if you are in London don't miss it! </p>
<p><strong>3. <a href="http://www.fitc.ca/events/about/?event=102">FITC Toronto, April 25th-27th</a></strong></p>
<p>Finally in April I'll be making the move over the Atlantic all the way to <strong>Canada</strong> for <strong>FITC Toronto</strong>, where I will also be talking <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=102&#038;presentation_id=1004">about Unity</a>. There is no schedule yet, but it's should be coming soon. However, the tickets are <strong>already on sale</strong>. If you hurry you might even get a <a href="http://www.fitc.ca/events/tickets/?event=102">early bird price</a>!</p>
<p>This is very exciting for me for several reasons. First, it's a <strong>major conference</strong> with 3 days of sessions, workshops and even a recruiting event. It's not to be missed not only if you live in Toronto, but for anyone in the region. And I've heard people come for FITC from all over Canada and US. </p>
<p>Second of all it's my first time I will attend <strong>a conference in North America</strong>. I looking forward to meet a lot of people whom so far I knew only from blogs and twitter. So if you are around don't hesitate to get in touch!</p>
<p>Finally, it will be my <strong>first visit to Toronto</strong> and I heard a lot of good stuff about the city. We also plan a short family vacation afterwards to visit <del datetime="2010-05-25T13:18:43+00:00">Montreal and Quebec</del> Miami and the Florida Keys. </p>
<p><strong>Next?</strong></p>
<p>I'm currently entirely focused on those upcoming events, preparing all the materials and the presentation. However, I hope for more opportunities in the future. If you happen to organize a <strong>Flash and/or Unity event</strong> and you are looking for speakers be sure to <a href="http://www.everydayflash.com/blog/index.php/about/">let me know</a>!</p>
<p>I don't have any further plans at this moment, except that I will also attend <a href="http://www.offf.ws/">OFFF in Paris</a> in June (as guest, not as speaker). </p>
<p><em>Photo credits [<a href="http://www.flickr.com/photos/werkunz/4206835665/">1</a>] [<a href="http://www.flickr.com/photos/sylvainbourdos/3229776868/">2</a>] [<a href="http://www.flickr.com/photos/zaniac/242158015/">3</a>]</em></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=080kpamrGhg:WPzXwDtHVAU:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=080kpamrGhg:WPzXwDtHVAU:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=080kpamrGhg:WPzXwDtHVAU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/080kpamrGhg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2010/01/19/speaking-in-amsterdam-london-toronto/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2010/01/19/speaking-in-amsterdam-london-toronto/</feedburner:origLink></item>
		<item>
		<title>A 3D racing game in Flash with Away3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/ceCg0PvmtGw/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/12/11/3d-racing-game/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 16:05:52 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Unity3d]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=832</guid>
		<description><![CDATA[I am proud to announce my latest project. It's a 3D racing game done in Flash with Away3D. I worked on this project together with Calisto Labs and our client was Snowball Media. My task was to create the 3D game part. It was great fun to work on this project. The team at Calisto [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://scionstreetracer.com/Race/Arcade"><img src="http://www.everydayflash.com/blog-assets/scion/tunnel.jpg" alt="Scion Street Racer" border="0" width="520" height="319"/></a></p>
<p>I am proud to announce my latest project. It's a 3D racing game done in Flash with <a href="http://www.away3d.com">Away3D</a>. I worked on this project together with <a href="http://calistolabs.com/">Calisto Labs</a> and our client was <a href="http://www.snowball-media.com/">Snowball Media</a>. My task was to create the 3D game part. It was great fun to work on this project. The team at Calisto Labs did a awesome job and everything went smoothly!</p>
<p>The project required to use my Actionscript and 3D modeling skills together on a scale like I never did before. I spent a lot of time with <a href="http://www.blender.org">Blender</a> and <a href="http://www.unity3d.com">Unity</a> in the last months, and without this experience I feel the project would be beyond my abilities. Also, having a direct comparison between Flash and Unity allowed be to see things in a larger perspective.</p>
<p><strong>Flash vs. Unity... again</strong></p>
<p>I built the game with <a href="http://www.away3d.com">Away3D FP10</a>. I must say that Flash 3D has gone a long way since I first started to play with it, and Away3D is a very solid engine. The 2K polygon limitation is a thing of the past, and the correct perspective projection in FP10 makes everything look so much better. The team also added some other crucial features to create 3D environments - ex. frustum clipping. </p>
<p>Before starting this project I was working on a <a href="http://www.everydayflash.com/unity3d/one/">Unity3D racing demo</a>, so I managed to get quite a few ideas on how to build such a thing. However, when I moved back to Flash, I was a bit desperate because I realized how much stuff I got used to in Unity is just not there in Flash. A built-in physics engine would be the most important one.</p>
<p><strong>Home-made physics and collision detection</strong></p>
<p>For physics in Flash I was tempted do use <a href="http://www.jiglibflash.com/blog/">JigLib</a> at first. But soon I found out that JigLib is way too complex, creating a realistic car behavior would be very difficult and it would probably eat too many CPU cycles. I estimated that Away3D will take around 90-95% of available processing power, so there's no space for any other complex piece of code to run in the same time. I always think that when it comes to 3D in Flash <strong>performance is quality</strong>, and there is no excuse for poor performance, even if you want something to look "realistic". So I ended building something very very simple.</p>
<p>Once I got the car driving around, I needed to add some collision detection. In Unity you quickly get used to the fact that any 3d object is a collider which makes collision detection a no-brainer - just implement a listener method and get a call whenever your object collides with another one. And if you need to add realistic collision response, you just make the object a rigid body and there you go! (Ok, you may need to adjust some settings, but still it's pretty straightforward).</p>
<p>In Flash it seemed like a much more complex task. I was thinking in the lines of creating a system based on the geometry of the track. I started to study curve equations just to realize I wouldn't make it even if I had a year to complete the project! Then I remembered, that a <strong>good way to test collision with complex shapes is a bitmap</strong>. </p>
<p>The way it works is that it takes the car's position and checks against a map of the track that has different colors for different areas - ex. red for the road, green for the sideways and so on... Since it samples only a few pixels per frame and all it does is check their RGB values, it's lighting fast. <strong>Truly, Flash is the art of minimal!</strong></p>
<p><strong>Scenery</strong></p>
<p>The most fun part was to create the scenery. I've never tried to import such a large 3D scene into Flash so I wasn't even sure if Away3D would handle it. It turns out it did handle it pretty well. Instead of using Collada I went with <strong>Wavefront (OBJ)</strong> format for the meshes as I feel it gave me more flexibility. OBJ is a simple format which makes it a bit easier to see what's going on while <strong>Collada is bloated</strong> and overly complex for my taste. I used <strong>Blender to model the track</strong> and the few objects that you can see around it - lampposts, houses and the tunnel. </p>
<p><strong>Lightning</strong></p>
<p>Lightning is very important in low poly scenes, <strong>because it adds a lot of detail and atmosphere to the scenery</strong>, without adding any polygons. Even thought the scenery is simple, I ended up having more that 60 lamps. Of course all those lights needs to be baked on the textures, there's no way to run them in real-time. Blender has a very good texture baking tool and all this works fine for static objects. But what about objects that move, like the car? </p>
<p>For lightning the car, I reused the concept from collision testing. But instead of a collision map I made another one - <strong>a light map</strong>. Basically it's a bitmap with white areas where the scenery is lit and dark ones where it's not. By sampling a single pixel on every frame I can see if the car is passing through a lit area. Then, all I have to do is to <strong>apply a color transform on the car texture</strong> to make it brighter. Again - a minimal solution, but it works!</p>
<p>Now that you know all about it, go ahead and <a href="http://scionstreetracer.com/Race/Arcade">try it out!</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ceCg0PvmtGw:THmb41nhPb8:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=ceCg0PvmtGw:THmb41nhPb8:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ceCg0PvmtGw:THmb41nhPb8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/ceCg0PvmtGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/12/11/3d-racing-game/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/12/11/3d-racing-game/</feedburner:origLink></item>
		<item>
		<title>Modifiers in Unity3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/0f7VMy4RAUs/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 13:04:03 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[as3dmod]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438</guid>
		<description><![CDATA[Ringo from FlashBookmarks asked me if there were modifiers similar to AS3Dmod in Unity. I searched for something similar some time ago, but didn't find anything interesting. However, when I was starting C# scripting, I ported two of the modifiers from AS3Dmod - Bend and Twist. So I thought to share them with everyone. Don't [...]]]></description>
			<content:encoded><![CDATA[<p><img width="520" height="279" src="http://www.everydayflash.com/blog-assets/unityModifier.jpg"/></p>
<p>Ringo from <a href="http://www.flashbookmarks.com/">FlashBookmarks</a> asked me if there were modifiers similar to <strong>AS3Dmod</strong> in <a href="http://unity3d.com/">Unity</a>. I searched for something similar some time ago, but didn't find anything interesting. </p>
<p>However, when I was starting C# scripting, I ported two of the modifiers from AS3Dmod - <strong>Bend and Twist</strong>. So I thought to share them with everyone. Don't expect much, it's not the full library, just two classes. If I have some free time, I'll look into how to implement stacking, since for the moment you cannot apply two modifiers to the same object (the second one won't have any effect). </p>
<p>To play around with them grab <a href="http://www.everydayflash.com/unity3d/UnityModifiers.unitypackage">this package</a> and import it into Unity. Keep in mind that the modifiers work at runtime, so you won't see any effects in the editor until you run the game. If you want to animate them, just add another script that will have a reference to the modifier instance and change it's properties at each Update() call.</p>
<p>If you are interested in this kind of "bricolage" with 3D geometry, I recommend to take a look at the <strong><a href="http://unity3d.com/support/resources/example-projects/procedural-examples">Procedural Examples</a></strong> project provided by Unity. You will find there some highly interesting samples like <strong>dynamic extrudes or perlin noise</strong>. It's a great starting point to explore <strong>runtime geometry transformation</strong>. </p>
<p>Of course, take a look into the sources of the modifiers too! You'll see how simple it is to access the geometry at runtime and do some modifications. Basically it goes like this: </p>
<div class="igBar"><span id="lcsharp-14"><a href="#" onclick="javascript:showPlainTxt('csharp-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-14">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MeshFilter mfilter&nbsp; = GetComponent<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #000000;">&#40;</span>MeshFilter<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">as</span> MeshFilter;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mesh = mfilter.<span style="color: #0000FF;">mesh</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> vs = mesh.<span style="color: #0000FF;">vertices</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">int</span> vc = vs.<span style="color: #0000FF;">Length</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;vc; i++<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #008080; font-style: italic;">// Modify your vertices here</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mesh.<span style="color: #0000FF;">vertices</span> = vs;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mesh.<span style="color: #0000FF;">RecalculateNormals</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Things worth notice: In Unity a <strong>vertex is just an instance of Vector3</strong> - there isn't any special class for this, as in Flash-based 3D engines. </p>
<p>You can see a bit of the casting-drama I need to do (lines 1-2) to get to the object holding the actual geometry information (Mesh). That's a bit annoying in C#, with JS that code would be more readable. Anyway, it's better to <strong>make that only once</strong>, in Start() and not at every Update(). </p>
<p>To get <strong>correct lightning effects</strong> on the materials, do not forget to call <strong>mesh.RecalculateNormals()</strong> after you've modified the positions of the vertices.</p>
<p>If you want to modify your mesh continuously (i.e. to animate it) it's necessary to keep the <strong>original array of vertices</strong>, because the code above overwrites the original positions. Take a look at the <a href="http://www.everydayflash.com/unity3d/UnityModifiers.unitypackage">source code in the package</a> to see how I did it. </p>
<p>That's all for now, hope you enjoy it!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=0f7VMy4RAUs:ss6ouaNioNA:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=0f7VMy4RAUs:ss6ouaNioNA:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=0f7VMy4RAUs:ss6ouaNioNA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/0f7VMy4RAUs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/</feedburner:origLink></item>
		<item>
		<title>First steps in 3D design</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/-4OOS2PQrxY/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/11/09/first-steps-in-3d-design/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 11:08:55 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[Blender]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[3d modeling]]></category>
		<category><![CDATA[car game]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[lightmaps]]></category>
		<category><![CDATA[racing game]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=727</guid>
		<description><![CDATA[There's something you'll quickly realize when you start playing with Unity. It's the fact that you won't go far without some basic knowledge of a 3D editor. I've been using Blender for my Flash 3D experiments, but I can't honestly say I knew anything about it. I was able to model some very basic shapes, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/unity3d/one/"><img src="http://www.everydayflash.com/unity3d/firststep/mracer.jpg" border="0" alt="" width="520" height="319" /></a></p>
<p><a href="http://www.everydayflash.com/unity3d/lightmap/1.html"><img src="http://www.everydayflash.com/unity3d/firststep/interior.jpg" border="0" alt="" width="520" height="319" /></a></p>
<p>There's something you'll quickly realize when you start playing with <a href="http://unity3d.com/">Unity</a>. It's the fact that you won't go far without some <strong>basic knowledge of a 3D editor</strong>. I've been using <a href="http://www.blender.org/">Blender</a> for my Flash 3D experiments, but I can't honestly say I knew anything about it. I was able to model some very basic shapes, and whenever I needed something more complex I'd ask someone who's more experienced or just find a free model on the Internet. With Unity it just doesn't make sense. <strong>You won't be able to understand half of the functionality</strong> if you don't have a 3D editor to work with. By the way, I'm not the only one <a href="http://blog.almostlogical.com/2009/11/06/flash-developer-to-unity3d-developer-where-should-i-begin/">who noticed this</a>.</p>
<p>As a logical consequence, I decided to <strong>take a step back and learn Blender</strong>. I don't want to go into details on the choice of software. If you prefer <strong>Maya or Cinema4D</strong>, fine. I grew to like Blender, but I know it makes a horrible first impression. The thing about Blender is that it's free, and that's a huge advantage for beginners.</p>
<p>After some time of <strong>modeling, texturing and setting up lights</strong> and I started to really love that. I felt like I was taken 10 years back, at the time when I was discovering Flash, HTML, <strong>building my first "home page"</strong>. I'm sure you all know the great feeling when you start to understand something new and your skills grow every day. <strong>There's nothing like it!</strong> <em>(Ok, there are other things better than that, but let's stay within our geeky subject).</em></p>
<p>At first I wanted to get <strong>just enough skills to continue with Unity3D</strong> development. But soon I realized that this might be what I'd like to do for a living. <strong>Wait, what?</strong> Can you imagine? I'm in my thirties. I'm doing pretty well in flash development business. Is there <strong>anything more stupid</strong> that dropping all this and becoming a 3D designer? And how many years I would need to become any good at this? Or maybe it's just a matter of a couple months to master the tool and I'll be all set? But maybe I don't have what it takes to be a 3D designer. However a fundamental thing I believe in, is that there's no such thing as innate talent and all you need is enough persistence...</p>
<p>I've been struggling with those questions for a while, and I don't have any answers yet. In the meantime I ordered some books, found some tutorials and kept learning to keep all the options open. I still have a long way to go, but I can already see some results.</p>
<p>As my modeling skills grow, I feel much more confident as a 3D developer because I can understand where the assets come from, how they are built, how visual effects are achieved. Those things were like a black box to me before. Now I can even build some 3D stuff myself. It's so much worth the effort even if I'll never work as full time 3D designer.</p>
<p>The two Unity examples above are <strong>my first, modest 3D modeling experiences</strong>. One is a <a href="http://www.everydayflash.com/unity3d/one/">mini game</a>. It features a scenery that I populated with a few models including my first car model. Apart from modeling the scenery elements I used that as a testing ground for many Unity features like <a href="http://unity3d.com/support/documentation/Components/script-Terrain.html">the terrain engine</a>, <a href="http://unity3d.com/support/documentation/Components/class-LineRenderer.html">line</a> and <a href="http://unity3d.com/support/documentation/Components/class-TrailRenderer.html">trail</a> renderers, <a href="http://unity3d.com/support/documentation/Components/comp-DynamicsGroup.html">rigid body</a> physics, car simulation, <a href="http://unity3d.com/support/documentation/Components/comp-ParticlesGroup.html">particle systems</a> and of course scripting. The <strong>end result is a bit random</strong>, but I don't remember having that much fun for a long time!</p>
<p>The second is a small <a href="http://www.everydayflash.com/unity3d/lightmap/1.html">interior scene</a> (really small!). I couldn't grasp how <strong>lightmaps</strong> work in Unity until one morning I woke up and I just knew (yeah, that's how it happens sometimes!). During the day, I quickly threw up this demo to test if my understanding was correct. I think it was, even though in the end the <strong>shadows came out too subtle</strong>. Anyway, I'm doing more experiments on that subject now and maybe I'll write a separate post on how to work with lightmaps in Blender &amp; Unity.</p>
<p>That's it for now! I'll see where it takes me, but you should expect more 3D modeling related posts on this blog from now on. Also, I'm not giving up on coding... yet ;)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=-4OOS2PQrxY:DUG8saT5lQo:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=-4OOS2PQrxY:DUG8saT5lQo:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=-4OOS2PQrxY:DUG8saT5lQo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/-4OOS2PQrxY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/11/09/first-steps-in-3d-design/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/11/09/first-steps-in-3d-design/</feedburner:origLink></item>
		<item>
		<title>Book review “Unity Game Development Essentials”</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/scSha6CT6rA/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/10/16/unity-game-development-essentials/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 19:39:19 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[packt]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=631</guid>
		<description><![CDATA[I like books. A book is always a good thing, no matter how abundant online resources are. It's always at hand, with all the information brought together in one place, not scattered across different sites or even worst, across different forum threads. When I learned a couple of months ago that Will Goldstone was writing [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/unity-game-development-essentials/book"><img width="520" height="243" src="http://www.everydayflash.com/unity3d/unityBook.jpg" alt="Unity Game Development Essentials" border="0"/></a></p>
<p><strong>I like books.</strong> A book is always a good thing, no matter how abundant online resources are. It's always at hand, with all the information brought together in one place, not scattered across different sites or even worst, across different forum threads.</p>
<p>When I learned a couple of months ago that <a href="http://willgoldstone.com/blog/?p=468">Will Goldstone</a> was writing a <a href="http://www.packtpub.com/unity-game-development-essentials/book">book on Unity3D</a>, I was pleasantly surprised. A bit later Packt, the publisher of the book, contacted me asking for a review. </p>
<p>In the meantime the book <a href="http://www.amazon.com/Unity-Game-Development-Essentials-Goldstone/dp/184719818X">hit the shelves</a>, and there was some buzz on Twitter, so there's a good chance you've already heard about it. If you are still wondering whether you should buy it, keep reading.</p>
<p><strong>Great for beginners</strong></p>
<p>The book is written in the form of one big tutorial. The author leads us through different parts of the Unity3D IDE in the course of creating a simple game. The word "simple" is key here. Before I had the chance to read the book I went through the <a href="http://unity3d.com/support/resources/tutorials/3d-platform-game">Unity3D official tutorial</a> which has a similar structure. It presents us with a very cool 3D artwork and a pretty complex game to build. Compared to that, what we will create with the book is pretty basic. <strong>However, in this case: simpler means better.</strong></p>
<p>After completing the official tutorial I felt I merely scratched the surface, and many parts of it were too complex to follow. The book doesn't leave you with this feeling. You'll be guided in creating a game but you will do it from scratch and all the steps are explained in depth. </p>
<p><strong>Scripting</strong></p>
<p>I assume most readers of this blog are familiar with programming. In this case you may find the code presented in the book somewhat rudimentary. One way of making it more fun is to <strong>translate the code from JavaScript into C#</strong> on the way. I did that, and I think it's much more beneficial than just copy-pasting. At least you will read it that way.</p>
<p>Furthermore, Actionscript 3 programmers can find that some examples are <strong>bending the rules of strict OOP</strong>. Again, for a seasoned AS3 developer, restructuring the code in those places can be another good exercise. </p>
<p>The book covers obviously more than just scripting. Among other topics, I particularly enjoyed the chapters on <strong>particle systems</strong> and on <strong>2D GUI</strong> (as you will find out, 2D GUI is the weird part of Unity) </p>
<p><strong>Other ressources</strong></p>
<p>An indispensable companion of the book is the Unity <a href="http://unity3d.com/support/documentation/ScriptReference/index.html">scripting reference</a>. The docs are solid and in most cases you'll find what you're looking for. Not always however, and if you feel you need more info I recommend to <a href="http://forum.unity3d.com/search.php">search the forums</a>. I am not a fan of forums overall, but I must admit that the Unity3D forum is a pretty good resource. </p>
<p><strong>A remark on the Unity3D documentation</strong></p>
<p>A bit off-topic, but I will take the occasion to rant about the Unity3D scripting documentation. Not about the content, but about the form.</p>
<p>In the Unity3D docs the list of classes is sometimes placed on the left column, sometimes in the middle. Sometimes they are listed in alphabetical order, sometimes presented in an inheritance structure. Every property and method is presented on a separate page, which is a big waste of space given the fact that most of them have max 2-3 lines of description. It leads to constant back/forward clicking when exploring the API. And it might get even worse when Unity will introduce namespace support.</p>
<p>It would be cool if the docs followed the good old <a href="http://java.sun.com/j2se/1.5.0/docs/api/">Java standard</a>, where the list of classes is always in the same place, always accessible and in alphabetical order. The properties and methods are listed in one big table, which is also much easier to browse. </p>
<p>OK, enough complaining, now back to the book...</p>
<p><strong>Conclusion</strong></p>
<p>If you want to get into Unity, it's probably a <strong>good idea to buy this book</strong>. You'll get yourself a decent introduction to the main aspects of the software. Remember that you won't learn any advanced stuff like stucturing code in large projects, writing custom shaders or making advanced physics simulations. <strong>The important thing is that the book explains all the basics leaving you well prepared to explore the rest</strong>. I enjoyed reading it and I learned quite a lot!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=scSha6CT6rA:5f3Irjoqncw:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=scSha6CT6rA:5f3Irjoqncw:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=scSha6CT6rA:5f3Irjoqncw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/scSha6CT6rA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/10/16/unity-game-development-essentials/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/10/16/unity-game-development-essentials/</feedburner:origLink></item>
		<item>
		<title>FOTB’09 presentation: 3D Bowling demo</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/p7ME6VHczMw/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/09/29/fotb09-3d-bowling-demo/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 11:17:02 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[JigLibFlash]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[bowling game]]></category>
		<category><![CDATA[brighton]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[elevator pitch]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash on the beach]]></category>
		<category><![CDATA[fotb]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=573</guid>
		<description><![CDATA[UPDATE Nov 2009 There is a better quality video posted by John from Flash On The Beach. It is available here: http://vimeo.com/7292505. As I promised during my "3 minutes" in Brighton, I publish all the sources of my presentation. I added some comments in the code and removed the part with the slides. Here's also [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vimeo.com/6768982"><img width="520" height="259" src="http://www.everydayflash.com/flash/fotb/fotb09bowling.png" alt="Video of 3D Bowling Demo, Flash on the Beach 2009" border="0"/></a></p>
<p><strong>UPDATE Nov 2009</strong> <em>There is a better quality video posted by John from Flash On The Beach. It is available here: <a href="http://vimeo.com/7292505">http://vimeo.com/7292505</a>.</em></p>
<p>As I promised during my <strong>"3 minutes"</strong> in Brighton, I publish all the <a href="http://www.everydayflash.com/flash/fotb/fotb09bowling.zip">sources</a> of my presentation. I added some comments in the code and removed the part with the slides.</p>
<p>Here's also the <a href="http://www.everyday3d.com/flash/fotb/"> demo</a> and a <a href="http://www.vimeo.com/6768982">video of the mini-session</a>. The demo is pretty rudimentary - I made so because I wanted to keep things simple during the presentation. I hope that it will be a solid base for someone who wish to create a full featured bowling game in Flash.</p>
<p>There were a few <strong>other implementations</strong> of a bowling game in <a href="http://www.jiglibflash.com/blog/">JigLibFlash</a> and <a href="http://blog.papervision3d.org/">Papervision3D</a>. Initially, guys a <strong>Blitz Agency</strong> published a few <a href="http://labs.blitzagency.com/?p=634">interesting experiments</a> with JigLibFlash, including a simple bowling simulation. <a href="http://blog.onebyonedesign.com/">Devon O. Wolfgang</a> has written a <a href="http://www.thetechlabs.com/tutorials/3d/create-a-3d-bowling-game-with-jiglibflash-and-papervision-3d/">great tutorial</a> about building such a game on <a href="http://www.thetechlabs.com/">Tech Labs</a> - be sure to check it out. I found it only after the presentation and since the tutorial explains a lot of things in details I felt like I was reinventing the wheel here. But hopefully there are still a couple of things I can add. </p>
<p>Thanks to the <a href="http://code.google.com/p/jiglibflash/wiki/New_API_Very_Short_Tutorial">new plugin API</a> we developped some time ago, setting up a scene with JigLib and an 3D engine has got a bit less complicated. However, tweaking the engine can be a hell. Here's a few things I found out:</p>
<p><strong>1. Simulation speed</strong></p>
<p>When you create the physics engine instance, the default speed of the simulation is 1. This is <strong>very slow</strong> and unrealistic. It will look much more natural if the speed is increased. Beware however - at higher speeds the collision detection system can be <strong>very inaccurate</strong> and result in objects running through each other without any collision being detected. I don't think there is a single setting that works fine in every situation, but for this case 9 worked fine for the regular speed simulation, and 2 for the "slow speed". <strong>You should always try different settings.</strong></p>
<p><strong>2. Mass</strong></p>
<p>Each rigid body has a mass property. It's easy to forget about it since it has a default value and it never complains if you don't change it. However, setting the masses right is crucial for a <strong>realistic simulation</strong>. In real world object have different masses, and so they should in a simulation. This is particularly important for a bowling game, where the ball is pretty heavy and the bins are not (I guess... has anyone ever had a bowling pin in his hands?) The trick is that the <strong>masses are relative to each other</strong>, so the more different objects you have the more you need to tweak the masses to get the results right. Also remember the effect of any forces applied to an object is related to it's mass.</p>
<p><strong>3. Physics material</strong></p>
<p>Each rigid body has a property called material which is an instance of the <a href="http://www.jiglibflash.com/docs/jiglib/physics/MaterialProperties.html">MaterialProperties</a> class. It has two properties: <strong>friction and restitution</strong>. I found out that playing with this values has a quite big impact on the simulation. Ex. setting a high value of the restitution results in the object becoming <strong>bouncy</strong> - I used this for the ball in my older <a href="http://www.everydayflash.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/">ping-pong example</a>. In the bowling demo I used lower friction on the ball to make it <strong>slide</strong> more - just as a real bowling ball does. </p>
<p><strong>4. Object rotation</strong></p>
<p>Once a DisplayObject is wrapped into a physics rigid body you can't rely on it's <strong>rotationX, rotationY and rotation</strong>Z propeties anymore - because they <strong>are not being set</strong>. The physics engine sets the transformation matrix directly on the DisplayObject, so if you need to check it's rotation you need to <strong>extract it from the matrix</strong>. Fortunately, there's an easy way to do this:</p>
<div class="igBar"><span id="lactionscript-17"><a href="#" onclick="javascript:showPlainTxt('actionscript-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-17">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> p:DisplayObject3D = physics.<span style="color: #006600;">getMesh</span><span style="color: #66cc66;">&#40;</span>pins<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> h:Number3D = Matrix3D.<span style="color: #006600;">matrix2euler</span><span style="color: #66cc66;">&#40;</span>p.<span style="color: #006600;">transform</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// h.x is the rotationX of the object in this case. </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>5. Object activity</strong></p>
<p>As a result of multiple forces being applied to an object and multiple collisions sometimes the objects are left in a state where the shake a bit endlessly. This can also happen when the objects are initially positioned. Calling the RigidBody.setInactive() will fix that. And you can call more than once.</p>
<p><strong>Important conclusion: tweak, tweak, tweak...</strong></p>
<p>It is generally agreed that <strong>hardcoded ("magic") numbers</strong> are not a good coding practice. However in 3D animations, and especially with physics the important thing is <strong>not the beauty of the code, but the what you see at the end</strong>. If you browse the source code from this demo you will notice that I not only hardcoded a lot of values, I even left ugly lines like that: </p>
<div class="igBar"><span id="lactionscript-18"><a href="#" onclick="javascript:showPlainTxt('actionscript-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-18">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">force = <span style="color: #66cc66;">&#40;</span>speed == <span style="color: #cc66cc;color:#800000;">9</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #cc66cc;color:#800000;">5000</span> : <span style="color: #cc66cc;color:#800000;">3000</span> * <span style="color: #cc66cc;color:#800000;">8</span> * <span style="color: #cc66cc;color:#800000;">4</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In fact this is what I like the most in doing all those demos and experiments - the moment when code stops being just a list of instructions for the machine and becomes an <strong>art of making things look good</strong> by adding little tweaks here and there. If you tend to write very clean code and use all possible standards and conventions, from time to time <strong>make it ugly</strong>... you'll see how good it feels :)</p>
<p>I hope that this few tips will help you with your <strong>next JigLib project</strong>!</p>
<p>Last but not least, I'd like to say thanks to everyone who woke up early to see the <strong>Elevator Pitch session</strong>. It was a great experience being there and talking to you. <strong>The Brighton Dome</strong> packed with people can be intimidating and 3 minutes is not much time, so there was no place for mistakes. Fortunately, the <strong>FOTB technical crew</strong> made it all seamless. Great job guys! </p>
<p>Finally, I would like to give a special thanks to <strong>John Davey</strong> for inviting me to <strong>Flash On The Beach</strong> and for making this great conference happen! </p>
<p>Hope to see you next year!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=p7ME6VHczMw:-hTcOcui6G8:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=p7ME6VHczMw:-hTcOcui6G8:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=p7ME6VHczMw:-hTcOcui6G8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/p7ME6VHczMw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/09/29/fotb09-3d-bowling-demo/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/09/29/fotb09-3d-bowling-demo/</feedburner:origLink></item>
		<item>
		<title>Speaking at Flash on the Beach ’09</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/NIgkZF-njGQ/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/09/06/speaking-at-flash-on-the-beach-09/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 11:25:05 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[antwerp]]></category>
		<category><![CDATA[brighton]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[fotb]]></category>
		<category><![CDATA[mrhenry]]></category>
		<category><![CDATA[speaker]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=562</guid>
		<description><![CDATA[I extremely happy to announce that I will speak at this year's Flash on the Beach in Brighton. It starts two weeks from now and if you haven't already got a ticket it might be too late, because they're all sold out (sorry). It will be my first appearance on such major Flash event. I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashonthebeach.com/"><img width="520" height="178" src="http://www.everydayflash.com/flash/fotb/brighton09.png" alt="Flash on the Beach 2009" border="0"/></a></p>
<p>I extremely happy to announce that I will speak at this year's <a href="http://www.flashonthebeach.com/">Flash on the Beach</a> in Brighton. It starts two weeks from now and if you haven't already got a ticket it might be too late, because they're all sold out (sorry).</p>
<p>It will be my <strong>first appearance on such major Flash event</strong>. I am taking part in the <strong><a href="http://www.flashonthebeach.com/sessions/index.php?pageid=2999">Elevator Pitch session</a></strong>, which features 20 speakers (!) in 1 hour - 3 minutes each. So it won't be a long presentation, but be sure - it will be intense. I will show a new 3D Flash experiment made especially for FOTB. The session takes place on the second day of the conference, <a href="http://www.flashonthebeach.com/schedule/">Tuesday 22nd at 9AM</a> in the Brighton Dome. Hope to see you there!</p>
<p>On a related note: if you live in <strong>Antwerp, on September 16th</strong> I will be also speaking at an event organized by my friends at <a href="http://www.mrhenry.be">Mr. Henry</a>. I'll present some of my new and older experiments and talk about 3D in Flash in general. You can find more info <a href="http://blog.mrhenry.be/2009/09/mr-henry-event-flash-2000/">about this here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=NIgkZF-njGQ:IKDibW7y-z4:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=NIgkZF-njGQ:IKDibW7y-z4:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=NIgkZF-njGQ:IKDibW7y-z4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/NIgkZF-njGQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/09/06/speaking-at-flash-on-the-beach-09/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/09/06/speaking-at-flash-on-the-beach-09/</feedburner:origLink></item>
		<item>
		<title>Getting started with C# for Unity3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/QXiB-n42NeY/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/07/21/c-sharp-for-unity3d/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 19:34:56 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=434</guid>
		<description><![CDATA[Unity3D offers a choice between 3 different programming languages: JavaScript, C# and Boo. Each of them has its pros and cons, but for me C# almost immediately came out as a clear winner. That is because it is fully object oriented and it's syntax is similar to Java and Actionscript 3, both of which I [...]]]></description>
			<content:encoded><![CDATA[<p><img width="520" height="240" src="http://www.everydayflash.com/unity3d/csharp.jpg" alt="C#" /></p>
<p><a href="http://unity3d.com/">Unity3D</a> offers a choice between 3 different programming languages:<strong> JavaScript, C# and <a href="http://boo.codehaus.org/">Boo</a></strong>. Each of them has its pros and cons, but for me C# almost immediately came out as a clear winner. That is because it is <strong>fully object oriented</strong> and it's syntax is similar to <strong>Java and Actionscript 3</strong>, both of which I am experienced with. However, before I started to play with Unity3D, I never wrote a single line in C#, so I had to learn it from scratch.</p>
<p>As you probably know C# was originally developed by <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx">Microsoft</a> and is widely used in the <a href="http://msdn.microsoft.com/en-us/netframework/default.aspx">.NET framework</a> as well as in <a href="http://silverlight.net/">Silverlight</a> development. It is important to understand however that learning <strong>C# for Unity3D</strong> is not the same thing as learning the .NET platform. In fact you don't have to know anything about .NET to use C# with Unity3D. </p>
<p>While I use all kinds of online documentation, a book is often the best companion, so I thought buying a <strong>good C# book</strong> would be in order. It turns out that the small <a href="http://oreilly.com/catalog/9780596519223/">O'Reilly C# Pocket Guide</a> is exactly what one needs. It is absolutely unnecessary to buy a 500 page C# bible, as most of the stuff in those books is related to .NET and is not applicable to Unity3D at all. </p>
<p>Of course the book alone is not enough. You also need the <a href="http://unity3d.com/support/documentation/ScriptReference/">Unity3D scripting reference</a>. All the examples in the docs are given <strong>in Javascript</strong> only. But don't worry, they are easy to translate once you get used to.</p>
<p>C# is a very <strong>elegant and powerful</strong> language. It's dot-syntax is based on Java, so if you come from a Java background you'll quickly feel comfortable with it. There are a few differences though. The most striking difference is the convention to start property and method names with an uppercase letter. I guess it comes from Visual Basic. I am not a fan of this convention, but it's better to use it and have a consistent code rather than fight it. </p>
<p>The list of all C# features is so long, that it makes AS3 look poor in comparison. C# is really like <strong>Actionscript on steroids</strong>. I suppose the next version of Actionscript will have at least some of those implemented, so it's good to know about them. Here's a list of my favorites.</p>
<p><strong>Operator overloading</strong></p>
<p>This is the coolest one by far! It allows to define custom actions for common operators like +, -, * or /. The best illustration of this feature comes with vector addition. In Actionscript, to get a sum of 2 vectors you need to write something like this:</p>
<div class="igBar"><span id="lactionscript-25"><a href="#" onclick="javascript:showPlainTxt('actionscript-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-25">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> c:Vector3D = a.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is not very nice, and becomes almost unreadable if more than two vectors are added. In C#, thanks to the <strong>overloaded + operator</strong> it looks like this:</p>
<div class="igBar"><span id="lcsharp-26"><a href="#" onclick="javascript:showPlainTxt('csharp-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-26">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Vector3 c = a + b; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is much more readable and elegant, isn't it? It goes without saying that the 3D vector implementation in Unity3D has all the operators overloaded. In case you want to do it yourself however, the implementation of operator overloading is very simple and in the above case could look something like this:</p>
<div class="igBar"><span id="lcsharp-27"><a href="#" onclick="javascript:showPlainTxt('csharp-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-27">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> Vector3 <span style="color: #0600FF;">operator</span> + <span style="color: #000000;">&#40;</span>a:Vector3, b:Vector3<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Vector3<span style="color: #000000;">&#40;</span>a.<span style="color: #0000FF;">x</span> + b.<span style="color: #0000FF;">x</span>, a.<span style="color: #0000FF;">y</span> + b.<span style="color: #0000FF;">y</span>, a.<span style="color: #0000FF;">z</span> + b.<span style="color: #0000FF;">z</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>There are some simple rules: the operator function must always be static and must return an object of type it is defined for. However it can take any type of parameters. This allows to define operator overloading for adding or multiplying vectors but also for multiplying vector by a scalar or multiplying vectors by matrices. In fact this can be achieved thanks to another C# feature - method overloading.</p>
<p><strong>Method overloading</strong></p>
<p>Method overloading allows to define multiple methods with the same name provided that they take different parameters. It works with regular methods and with constructors as well. If there a multiple ways to create an object you can define multiple constructors to satisfy each case. As mentioned above it works with operators too.</p>
<p>A good example of method overloading in Unity3D API is the 'Transform.Rotate()' method. It has has been overloaded 3 times with different ways to specify a rotation:</p>
<div class="igBar"><span id="lcsharp-28"><a href="#" onclick="javascript:showPlainTxt('csharp-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-28">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">void</span> Rotate <span style="color: #000000;">&#40;</span>Vector3 eulerAngles, Space relativeTo<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">void</span> Rotate <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span> xAngle, <span style="color: #FF0000;">float</span> yAngle, <span style="color: #FF0000;">float</span> zAngle, Space relativeTo<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">void</span> Rotate <span style="color: #000000;">&#40;</span>Vector3 axis, <span style="color: #FF0000;">float</span> angle, Space relativeTo<span style="color: #000000;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You can either pass a vector of angle values, three floats - one for each axis, or a single angle combined with a rotation axis. This is only logical to call it 'Rotate' every time because this is what the method does at the end. </p>
<p>Actionscript has default parameter values, which in some cases can simulate method overloading but they are not quite as flexible as that.</p>
<p><strong>Getter/setter syntax</strong></p>
<p>C# has a very concise way of declaring parameters. While in Actionscript it takes two functions - one for 'get' and one for 'set', in C# it can look like this:</p>
<div class="igBar"><span id="lcsharp-29"><a href="#" onclick="javascript:showPlainTxt('csharp-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-29">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">float</span> Size <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In this case the compiler automatically adds a private member for this property and there isn't anything else you need to do. Of course such a parameter is not very practical, so here's a more complex code, involving a public getter and private setter:</p>
<div class="igBar"><span id="lcsharp-30"><a href="#" onclick="javascript:showPlainTxt('csharp-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-30">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">float</span> Area <span style="color: #000000;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> size * size; <span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">private</span> set <span style="color: #000000;">&#123;</span> size = Mathf.<span style="color: #0000FF;">Sqrt</span><span style="color: #000000;">&#40;</span>value<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You will also notice that neither the 'function' nor the 'var' keywords do not exist in C#. In that C# closely follows Java. This is good because both these keywords are completely redundant and do not add any information to the code.</p>
<p>Among other interesting features I recommend to explore <strong>indexers, generic types, structures and enumerators</strong> all of which are covered in depth in the pocket guide mentioned above but also in the many online C# tutorials.</p>
<p><strong>Editing C#</strong></p>
<p>There are multiple editors that support C#. Microsoft offers a great and free editor called <a href="http://www.microsoft.com/express/vcsharp/">Visual C# Express Edition</a> which features code completion, but is Windows only (obviously). For a Mac there's <a href="http://monodevelop.com/">Mono Develop</a> which looks very powerful, but is not very stable yet. Unfortunately the <a href="http://www.improve-technologies.com/alpha/esharp/">C# plugin</a> for Eclipse is completely unstable for the moment, and I wouldn't recommend it. On the other hand, it is still in alpha so let's give it some time. Of course there's always <a href="http://macromates.com/">TextMate</a>. </p>
<p>Last but not least there's <strong>Unitron</strong> - the Unity3D default editor. It is not very popular among developers, and I saw people complaining about it being too basic. I don't share this opinion. While it ain't no <a href="http://fdt.powerflasher.com/">FDT</a>, it's pretty solid, very stable and has <strong>basic auto-completion</strong>. The trick is auto-completion is turned off by default (why?). To turn it on go to 'Preferences' and you'll find it at the bottom of the 'General' section. With that, I'm sure that Unitron is enough to get started.</p>
<p>Most of us know JavaScript from the <strong>browser environment</strong>. JavaScript is often the first programming language people ever used. If this is the case, you may be tempted to just use JS with Unity3D right away and not bother learning anything new. After all, as far as Unity3D is concerned, anything that can be done with C# <strong>can also be done with JavaScript</strong>. </p>
<p>However in the long term, C# offers better control over the code, full OOP support, strong typing and a lot satisfaction of mastering a robust programming language, so the extra effort is worth it. Plus, for a seasoned AS3 developer, mastering C# is a matter of a couple of weeks anyway, so go ahead and try it out!</p>
<p><strong>UPDATE March 2010. </strong>Here's a new post about C# and Unity3D:<br />
<a href="http://www.everydayflash.com/blog/index.php/2010/03/09/loading-and-manipulating-images-in-unity3d/">Loading and manipulating images in Unity3D</a><br />
<em>(more coming)</em></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=QXiB-n42NeY:T-dZJj3uXsw:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=QXiB-n42NeY:T-dZJj3uXsw:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=QXiB-n42NeY:T-dZJj3uXsw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/QXiB-n42NeY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/07/21/c-sharp-for-unity3d/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/07/21/c-sharp-for-unity3d/</feedburner:origLink></item>
		<item>
		<title>My presentation at Warsaw Flash Camp 2009</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/9uGcGZHMCwI/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/06/23/warsaw-flash-camp-2009/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 14:51:51 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[News & Events]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[adobe user group]]></category>
		<category><![CDATA[flash camp]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[warsaw]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=367</guid>
		<description><![CDATA[On June 9th the Polish Adobe User Group organized a Flash Camp in Warsaw. It was the first meeting of this kind in Poland. I had the privilege to be one of the speakers. It was a one day event featuring 6 sessions all related to Flash &#038; Flex. It aroused great interest in the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/28455087@N08/sets/72157619452685259/detail/" title="More pictures from Warsaw Flash Camp 2009"><img src="http://farm4.static.flickr.com/3644/3650817392_a7e749d0a8_o.jpg" width="520" height="294" alt="More pictures from Warsaw Flash Camp 2009" border="0"/></a></p>
<p>On June 9th the <a href="http://www.g-media.pl/aug/">Polish Adobe User Group</a> organized a <strong><a href="http://www.g-media.pl/aug/flashCamp/index.html">Flash Camp</a></strong> in Warsaw. It was the first meeting of this kind in Poland. I had the privilege to be <strong>one of the speakers</strong>. It was a one day event featuring <strong>6 sessions</strong> all related to Flash &#038; Flex. It aroused great interest in the local Flash Community and <strong>more than 300 people</strong> attended  </p>
<p>We kicked off in the morning with a very comprehensive presentation by <a href="http://www.webkitchen.be/">Serge Jespers</a> on the Flash Platform. Serge went through a lot of interesting projects including some of the best <a href="http://www.webkitchen.be/2009/04/29/the-power-of-the-flash-platform-part-2-augmented-reality/">Augmented Reality</a> examples. He also showcased his favorite AIR applications. Apparently AIR is not used only for Twitter clients! But seriously, I neglected this technology so far, but I promised myself to fix this in the near future. I'm looking for some ideas for a simple AIR app now... a Collada viewer maybe?</p>
<p>Next, the Platform Evangelist from Poland, <a href="http://www.riaspace.net/">Piotr Walczyszyn</a> gave us an insightful presentation on <strong>Flash Catalyst and the new Flash Builder</strong>. I use FDT to do all my Flash stuff for some time now, so all the things he presented were totally new to me. I must say I was surprised how fast and efficient the new workflow is. Things like working directly with <strong>PSD files in Catalyst</strong> look great (how many hours have I spent "cutting" PSD files and importing them into Flash!) He build a complete application connected to a database without writing a single line of code! It was amazing... and a bit frightening too ;)</p>
<p><a href="http://nordicnets.com/main/">Wojtek Ptak</a> made a great presentation about building <strong>large scale RIA's</strong>. Usually this kind of applications are not my primary interest but Wojtek showed us some really inspiring stuff and it was a pleasure to listen to him speaking.</p>
<p>Unfortunately I could not attend the other sessions, because I was rehearsing my own. It was my first public presentation, so I was pretty excited but also a bit nervous, especially that I did not expect such a huge crowd. </p>
<p>During my session, I focused on <strong>3D in Flash</strong> (of course!). By showing some new and old demos I tried to explain the <strong>fundamental concepts of 3D graphics</strong> and how they are <strong>implemented in Actionscript</strong>. After my session I had a few minutes to answer some questions. Most of them were about <strong><a href="http://blog.papervision3d.org">Papervision3D</a></strong>, and the nature of those questions clearly showed that they were coming from <strong>very experienced developers</strong>. I did my best to answer all of them.</p>
<p>Overall it was a great experience, and I'd like to thank the organizers for inviting me. I like the idea of public speaking. It's a great way to share some thoughts and knowledge, but also, most importantly, to meet interesting people. I feel it nicely complements my blogging experience, so from now on I'll be looking for more speaking opportunities.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=9uGcGZHMCwI:WruW3dxtl9c:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=9uGcGZHMCwI:WruW3dxtl9c:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=9uGcGZHMCwI:WruW3dxtl9c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/9uGcGZHMCwI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/06/23/warsaw-flash-camp-2009/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/06/23/warsaw-flash-camp-2009/</feedburner:origLink></item>
		<item>
		<title>Unity3D is awesome!</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/xbLx7iWk2Ck/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/05/27/flash-vs-unity3d/#comments</comments>
		<pubDate>Wed, 27 May 2009 10:55:52 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[3d games]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[macbook pro]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=289</guid>
		<description><![CDATA[How I learned to stop worrying about plugin penetration and love Unity3D I started this blog almost 2 years ago with an idea to explore the world of 3D in Flash and learn new stuff on the way. I quickly fell in love with Papervision3D. It offered a whole new world of possibilities for someone [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.unity3d.com" title="Lerpz character from Unity 3D Game Tutorial" ><img src="/unity3d/lerpz.jpg" border="0" width="520"/></a></p>
<p><strong>How I learned to stop worrying about plugin penetration and love Unity3D</strong></p>
<p>I started this blog almost 2 years ago with an idea to explore the world of <strong>3D in Flash</strong> and learn new stuff on the way. I quickly fell in love with <a href="http://blog.papervision3d.org/">Papervision3D</a>. It offered a whole new world of possibilities for someone like me - bored with buttons &#038; dropdowns and not particularly interested in building Flex-type applications. </p>
<p>Unfortunately the <strong>performance limitations</strong> of Flash Player prevented me from going far beyond the demos I posted on this blog. Creating a solid piece of <strong>3D in Flash</strong>, with a decent frame rate is either <strong>impossible</strong> or requires an insane amount of code optimization. It often means resorting to <strong>low level programming</strong>. I think it is  dangerous, because it's easy to loose track of the overall picture then. I feel that this is what happened to me the last few months.</p>
<p>I sure heard about <a href="http://unity3d.com/">Unity3D</a> before, but, as it often happens, I did not have time to take a closer look. I applied for the Unity 2.5 beta test program back in February. I was accepted and got a 30-day copy of the software. What happened next? I <strong>opened it only once</strong> before the trial expired. </p>
<p>It's just hard to move to another software/platform when you are so <strong>completely immersed in Flash</strong>. Unity3D ended on my perpetual to-do list alongside with so many other things. I am sure many of you feel the same way.</p>
<p><strong>A new toy</strong></p>
<p>Recently I bought a <strong>Macbook Pro</strong>. My first Mac ever! A friend suggested that I move all my projects and workspace to the Mac immediately to make the transition fast. Unfortunately I had some difficult and urgent projects to finish, and ultimately I decided to stick with Flash on the PC for a while. </p>
<p>I had to do something with the Mac then... and that's where <a href="http://unity3d.com/">Unity3D</a> comes in. Additionally, this time I decided to buy a license, thinking that spending those 150 EUR extra will make me even more motivated.</p>
<p>After just a few hours I was amazed. <strong>And I mean AMAZED!</strong> You can check the <a href="http://unity3d.com/gallery/live-demos/tropical-paradise.html">Tropical Paradise demo</a> if you haven't seen it yet, download the <a href="http://unity3d.com/unity/download">trial copy</a> and start exploring the <a href="http://unity3d.com/support/resources/tutorials/3d-platform-game">3D Game Tutorial</a> to see what I mean. </p>
<p>It's not only how fast the 3D rendering is. Unity3D has a very intuitive interface organized around a simple and clear concept. I can literally see myself doing 3D games in a matter of weeks from now. Doesn't take long to realize the <strong>sad truth that Flash is far behind</strong> in almost every aspect.</p>
<p><strong>The myth of high penetration</strong></p>
<p>I do not want to do a list of pros and cons or some Flash vs. Unity3D comparison here. For a person who wants to do 3D for the web <strong>Unity3D is the winner by knockout</strong> and it makes no sense to elaborate on the subject. </p>
<p>However, there is one common argument against Unity3D. It's the <strong>low penetration</strong> rate of the web plugin. While Flash Player is at 98%, <strong>Unity3D is probably at < 1%</strong>. Aye! That sounds bad, doesn't it? I thought so too, but I made some thinking and researched a bit. Now please consider these points:</p>
<ul>
<li>Unity3D plugin is only <strong>~4MB</strong> and it's installation is seamless. In most cases, it doesn't even require browser restart. Thanks to this it has a <strong>high successful-install rate</strong>, which means it's share of the market will be quickly growing. You can read a whole article on this topic <a href="http://blogs.unity3d.com/2008/03/31/thoughts-on-browser-plugin-penetration/">here</a>.</li>
<li>Content created with Unity3D can be <strong>visually and interactively much superior</strong> to anything you can do with Flash. This will convince people that the little extra effort required to install the plugin is worth it.</li>
<li><strong>Most important argument</strong>: people access content from different devices. There are mobile phones, consoles, multi-touch interfaces etc. PC is no longer the king. Unity3D can be published for two of the most successful platforms out there: <strong>iPhone and Wii</strong>. "Web penetration" has no practical meaning in this case.</li>
</ul>
<p>So, if you think Unity3D is not worth looking at because of the low penetration of the web plugin, think again!</p>
<p>This blog note may seem emotional. It is! I feel I have discovered the <strong>perfect technology</strong>, that I have been looking for and I just wanted to share. Now I need to master Unity3D as quickly as possible. On my way I will certainly discover it's flaws... it must have some. Maybe later I will find a more objective way to <strong>compare Flash and Unity</strong>. </p>
<p><strong>Flash is much more than 3D</strong> and there are multiple directions it is evolving in. I am not predicting "the end of Flash" or anything like that - it would be ridiculous. Unity3D on the other hand, with all it's coolness is still the <strong>new kid on the block</strong>. It might be a huge success but it might as well share <strong>the fate of Wild Tangent and Shockwave</strong> players (I hope not!). </p>
<p>One thing is sure: if you are into 3D, you can't miss it! </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=xbLx7iWk2Ck:m7uXyXQltJM:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=xbLx7iWk2Ck:m7uXyXQltJM:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=xbLx7iWk2Ck:m7uXyXQltJM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/xbLx7iWk2Ck" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/05/27/flash-vs-unity3d/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/05/27/flash-vs-unity3d/</feedburner:origLink></item>
		<item>
		<title>Exploring JigLibFlash – the AS3 3D physics library</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/aiwTPw6eNw8/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 08:38:27 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[JigLibFlash]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[physics simulation]]></category>
		<category><![CDATA[pingpong]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=204</guid>
		<description><![CDATA[JigLibFlash is a new library for 3D physics simulation in Flash. It is ported from a C++ open source engine. It's been around for a few months now, and if you haven't heard about it, you need to catch up! I believe physics simulation is the next step in the Flash 3D world, so I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/flash/jiglib/pingpong.html" target="_blank"><img src="http://www.everydayflash.com/flash/jiglib/pingpong.jpg" width="520" height="245" border="0" alt=""></a></p>
<p><strong>JigLibFlash</strong> is a new library for 3D physics simulation in Flash. It is ported from a <strong>C++ open source engine</strong>. It's been around for a few months now, and if you haven't heard about it, you need to catch up!</p>
<p>I believe physics simulation is the <strong>next step</strong> in the Flash 3D world, so I got very excited when Ringo from <a href="http://www.flashbookmarks.com/" target="_blank">FlashBookmarks</a> invited me <strong>join the JigLibFlash team</strong> a couple of months ago. One little problem: I am perfectly lame when it comes to physics... In this situation, the only logical thing to do was to join the team and learn all the stuff I need to know about it in the meantime. Sounds like a challenge! </p>
<p>Now I slowly fill my knowledge gap. However, I also managed to do some actual work on the library. Together with <a href="http://blog.reyco1.com/" target="_blank">Reyco</a> we remodeled the API. We started by making it more <strong>Flash developer</strong> friendly, less C-style and more AS-style. All the methods start with a lowercase letter now, and instead of having to set the position and rotation using vectors and matrices, the new API offers simple getter/setters for properties like x/y/z and rotationX/Y/Z just like in <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> or in the new Flash Player 10 API. </p>
<p>Last but not least, we also created a plugin system to <strong>easily integrate</strong> <strong>JigLibFlash </strong>with the popular 3D engines like <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> or <a href="http://away3d.com/" target="_blank">Away3D</a>. Now there are <strong>specialized classes</strong> to interact with those two engines and it should be pretty easy to create a plugin for another engine if one needs. If you worked with <a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod</a> you should notice that the concept is similar to the plugin architecture in there. <em>Update: I just saw in the sources that someone already created a plugin for Sandy3D.</em></p>
<p>To learn more about these changes you can refer to the <a href="http://code.google.com/p/jiglibflash/wiki/New_API_Very_Short_Tutorial" target="_blank">tutorial</a> I wrote which is posted on the projects wiki page. Reyco also wrote a <a href="http://blog.reyco1.com/jiglibflash-papervision3d-quick-run-through/" target="_blank">great article</a> about this on his blog.</p>
<p>The <a href="/flash/jiglib/pingpong.html" target="_blank">demo above</a> is my <strong>first little experiment</strong> with JigLibFlash and <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a>. My idea was to integrate a <strong>Collada object with the physics system</strong> and to add some interactivity to it. I extended the <a href="http://code.google.com/p/jiglibflash/source/browse/trunk/fp9/src/jiglib/plugin/papervision3d/constraint/MouseConstraint.as" target="_blank">Mouse constraint class</a> created by Reyco to control the racket. I encountered some problems with stabilizing it in the long run. After having bounced the ball a few times the racket starts to rotate as if the constraints were broken... well, I still need to do some research on that. </p>
<p><strong>Source code</strong>. You can browse the sources for the demo <a href="http://code.google.com/p/barteksplayground/source/browse/#svn/trunk/fp10/src/com/everydayflash/jiglib/pong" target="_blank">here</a>.</p>
<p><strong>Links</strong>. Some links to get you started with JigLibFlash:</p>
<ul>
<li><a href="http://www.jiglibflash.com/blog/" target="_blank">Official blog</a>, <a href="http://code.google.com/p/jiglibflash/" target="_blank">Google code</a></li>
<li><a href="http://code.google.com/p/jiglibflash/wiki/New_API_Very_Short_Tutorial" target="_blank">Wiki tutorial on new API</a> and <a href="http://blog.reyco1.com/jiglibflash-papervision3d-quick-run-through/" target="_blank">Reyco's article</a></li>
<li><a href="http://blog.zupko.info/?p=273" target="_blank">Really cool demo by Andy Zupko</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=aiwTPw6eNw8:ezfyl1R5y58:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=aiwTPw6eNw8:ezfyl1R5y58:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=aiwTPw6eNw8:ezfyl1R5y58:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/aiwTPw6eNw8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/</feedburner:origLink></item>
		<item>
		<title>PDFBook3D, a 3D flipbook engine</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/IkzXkPqB3Gk/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/04/03/pdfbook3d-3d-flipbook-engine/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 11:16:37 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[News & Events]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[flipbook]]></category>
		<category><![CDATA[flippage]]></category>
		<category><![CDATA[pdfbook]]></category>
		<category><![CDATA[powerflasher]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=118</guid>
		<description><![CDATA[PDFBook3D is a Flash application that allows to transform a PDF document into a 3D model, that later can be viewed pretty much like a real book. The product was just released by Powerflasher, and I was involved in creating the front-end 3d Flash part of it. This application belongs to the family of flipbook [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.powerflasher.de/pdfbook3d/" target="_blank"><img src="/flash/pdfbook/pdfbook3d.jpg" width="520" height="190" border="0" alt="PDFBook3d"></a></p>
<p><strong><a href="http://www.powerflasher.de/pdfbook3d/" target="_blank">PDFBook3D</a></strong> is a Flash application that allows to transform a <strong>PDF document into a 3D model</strong>, that later can be viewed pretty much like a real book. The product was just released by <a href="http://solutions.powerflasher.com/en/products/pdfbook-3d/information/" target="_blank">Powerflasher</a>, and I was involved in creating the front-end 3d Flash part of it. </p>
<p>This application belongs to the family of flipbook engines. I am sure you have seen the classic 2D version of a flipbook at least once. It is widely popular around the web! <strong>PDFBook3D</strong> replaces this classic piece with a more accurate and realistic 3D version of the effect created with <strong>AS3Dmod bend modifier</strong>. The bend modifier allows to create paper simulation in Flash, which is something I already posted about <a href="http://www.everydayflash.com/blog/index.php/2008/11/03/paper-simulation-as3dmod/">back in November</a>.</p>
<p>The application has a rich set of configurable properties, including dimensions of the book (for non typical page sizes) and a number of quality settings to get a decent framerate on slower machines as well. The Powerflasher team created an admin interface to generate 3d books on the fly. You can see it in action <a href="http://pdfbook-3d-demo.powerflasher.com/" target="_blank">here</a>. The product functionality also includes links editor and video embedding. If you are interested in more information please refer to the <a href="http://solutions.powerflasher.com/en/products/pdfbook-3d/information/" target="_blank">Powerflasher Solutions</a> site. </p>
<p>PDFBook3D is also my first commercial project made using <strong><a href="http://www.away3d.com" target="_blank">Away3D</a></strong>. There are a few features in Away3D that made me choose it, but mostly it was the curiosity to try <em>"the other"</em> engine. I must admit Away3D turned out to be pretty cool! </p>
<p>It is most famous for its advanced features like <a href="http://www.closier.nl/blog/?p=82" target="_blank">normal maps</a>, <a href="http://www.closier.nl/blog/?p=73" target="_blank">path extrudes</a> and <a href="http://www.infiniteturtles.co.uk/blog/away3d-multimario" target="_blank">bones animation</a>. However, this project does not rely on those advanced functionalities. Most of what I used in here is pretty basic, but still I was able to find some cool stuff. </p>
<p>One very useful feature is being able to assign <strong>back material</strong> to planes. It might not seem like a huge thing, but since it is used to create the flipping page, it helped me a lot. Actually any <strong>mesh in Away3D can have a back material</strong> assigned to its faces using the <code>back</code> property of the class:</p>
<div class="igBar"><span id="lactionscript-32"><a href="#" onclick="javascript:showPlainTxt('actionscript-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-32">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myMesh.<span style="color: #006600;">material</span> = <span style="color: #000000; font-weight: bold;">new</span> WireframeMaterial<span style="color: #66cc66;">&#40;</span>0xff0000<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// classic front-side material</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myMesh.<span style="color: #006600;">back</span> = <span style="color: #000000; font-weight: bold;">new</span> WireframeMaterial<span style="color: #66cc66;">&#40;</span>0x00ff00<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// back material </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice, that it is not the same thing as having a <strong>double sided material</strong> - that is, the same material used for both sides of a face. In this case - one material is used for one side, and a completely different one for the other. This is why it was perfect for creating a page of a book.</p>
<p>Another cool feature of Away3D is <strong>triangle caching</strong> - it is a built in functionality, that doesn't require any extra coding and it can give a significant <a href="http://www.infiniteturtles.co.uk/blog/awa3d-220-sierpinski-turtles" target="_blank">performance boost</a>. Thanks to triangle caching, whenever the page flip animation is on, the rest of the book that does not move at this moment is not re-rendered at each frame. A similar optimization can be achieved in Papervision3D using render layers, but it's not as easy to use. </p>
<p>Last but not least, I'd like to thank <a href="http://blog.closier.nl/" target="_blank">Fabrice Closier</a> from the Away3D team for support and feedback during the project! </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=IkzXkPqB3Gk:C_lLubDtgiA:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=IkzXkPqB3Gk:C_lLubDtgiA:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=IkzXkPqB3Gk:C_lLubDtgiA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/IkzXkPqB3Gk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/04/03/pdfbook3d-3d-flipbook-engine/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/04/03/pdfbook3d-3d-flipbook-engine/</feedburner:origLink></item>
		<item>
		<title>Mustang goes into augmented reality</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/0_NxyU6HhlM/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/03/26/mustang-augmented-reality/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 18:45:01 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[augmented reality]]></category>
		<category><![CDATA[FLARToolkit]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[mustang]]></category>
		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=66</guid>
		<description><![CDATA[Augmented Reality (AR) generated so much buzz in the community in the last few weeks that I had to give it a try! I suppose most of you know what AR is, however just in case you don't, here's some basic facts from an Actionscript developer perspective: augmented reality uses pattern recognition to render 3D [...]]]></description>
			<content:encoded><![CDATA[<p><object width="520" height="388"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3864433&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3864433&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="520" height="388"></embed></object></p>
<p><strong>Augmented Reality (AR)</strong> generated so much buzz in the community in the last few weeks that I had to give it a try!</p>
<p>I suppose most of you know what AR is, however just in case you don't, here's some basic facts from an Actionscript developer perspective: augmented reality uses <strong>pattern recognition</strong> to render <strong>3D graphics on top of a video display</strong>. A pattern, also called marker, is a rectangular shape that you need to print and position in front of your camera. The stream from the camera is analyzed and the marker is used to determine the <strong>coordinate system of the world</strong> captured by the camera. This coordinate system is passed to a 3D engine which <strong>renders objects on top of the video image</strong>. Pretty simple, huh?</p>
<p>As far as Flash is concerned, the API for augmented reality is called <a href="http://www.libspark.org/wiki/saqoosha/FLARToolKit/en" target="_blank"><strong>FLARToolkit</strong></a>, which is an AS3 <strong>port of library written in Java and C</strong> done by <a href="http://saqoosha.net/" target="_blank">Saqoosha</a>. If you want to know more about this project, here's a great <a href="http://www.mikkoh.com/blog/?p=182" target="_blank">intro to the subject</a> written by Mikko Haapoja.</p>
<p>In most of the cool AR projects I have seen so far <a href="http://ge.ecomagination.com/smartgrid/#/augmented_reality" target="_blank">[1]</a> <a href="http://www.boffswana.com/news/?p=392" target="_blank">[2]</a> the <strong>user is supposed to hold the marker and move it around</strong> in front of the camera and the 3d object follows the marker. I had a slightly different idea: why not just <strong>leave the marker and the camera in one place</strong> and use your keyboard to move around the 3d objects? </p>
<p>Some time ago I posted a <a href="http://www.everydayflash.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/" target="_blank">demo featuring a Mustang</a> that you could drive around a desert scenery. I thought it would be cool if I could now drive it around my bedroom floor. I was very surprised how easy it was to integrate my model with <strong>FLARToolkit and Papervision3D</strong>. All I had to do was to scale and rotate the model a bit and that's it! </p>
<p>The <a href="http://vimeo.com/3864433" target="_blank">above video</a> shows a recording of the experiment. If you have a webcam you can try it yourself. To do this, follow this instructions:</p>
<ol>
<li><a href="http://www.everydayflash.com/flash/flar/marker.pdf" target="_blank">Print the marker</a> (You can alternatively display it on your iPhone)</li>
<li>Click on <a href="http://www.everydayflash.com/flash/flar/" target="_blank">this link</a>, and choose "Allow" from the security dialog</li>
<li>Point your webcam so that the marker is fully visible</li>
<li>When the car is loaded (~250kb) it will appear on top of it</li>
<li>Use cursor keys to drive the car and CTRL key to apply hand brake</li>
<li>Have fun!</li>
</ol>
<p>If you want to dig further <a href="http://code.google.com/p/barteksplayground/source/browse/#svn/trunk/fp10/src/com/everydayflash/flar/mustang" target="_blank"><strong>here's the source code</strong></a>. The whole magic is in the <code>FlarMustang.as</code> class. The rest of the classes are an adaptation from the FLARToolkit basic example and some classes I used for the <a href="http://www.everydayflash.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/">Mustang demo</a>. </p>
<p><strong>Unrelated note</strong>. In case you are reading this post in your RSS reader, you might not have noticed that <a href="http://www.everydayflash.com/blog/">I redesigned the blog</a>. It's good to change from time to time! Among other stuff, there's a new list of previous 3D experiments and new links in the blogroll, so take a look.  </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=0_NxyU6HhlM:9-a0vcrDqpI:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=0_NxyU6HhlM:9-a0vcrDqpI:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=0_NxyU6HhlM:9-a0vcrDqpI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/0_NxyU6HhlM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/03/26/mustang-augmented-reality/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/03/26/mustang-augmented-reality/</feedburner:origLink></item>
		<item>
		<title>3D experiments with Flash Player 10 and AS3Dmod</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/BvXhryN7kv0/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/03/16/3d-experiments-with-flash-player-10-and-as3dmod/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 10:50:32 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[flash player 10]]></category>
		<category><![CDATA[3d animation]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[fp10]]></category>
		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=54</guid>
		<description><![CDATA[Demos: [ 1 ] [ 2 ] [ 3 ] [ 4 ]&#160;&#160;&#160;&#160;&#160;&#160;Flash Player 10 required (obviously) Flash Player 10 has been around for a few months now. As most of you know, it brings some native 3D support. It's not as robust as Papervision3D or Away3D, and in fact was not designed to compete [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/flash/as3dmod/fp10/as3dmod-fp10.gif" width="520" height="280" border="0" alt="Flash Player 10 3D experiments"></p>
<p><strong>Demos: <a href="http://www.everydayflash.com/flash/as3dmod/fp10/points3d.html" target="_blank">[ 1 ]</a> <a href="http://www.everydayflash.com/flash/as3dmod/fp10/walk.html" target="_blank">[ 2 ]</a> <a href="http://www.everydayflash.com/flash/as3dmod/fp10/tunnel.html" target="_blank">[ 3 ]</a> <a href="http://www.everydayflash.com/flash/as3dmod/fp10/twistedRibbon.html" target="_blank">[ 4 ]</a></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>Flash Player 10 required (obviously)</em></p>
<p><strong>Flash Player 10</strong> has been around for a few months now. As most of you know, it brings some <strong>native 3D support</strong>. It's not as robust as <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> or <a href="http://www.away3d.com/" target="_blank">Away3D</a>, and in fact was not designed to compete with those engines. Rather than that, it contains classes that perform 3D calculations and allows basic 3D manipulation of display objects.</p>
<p>The last months I focused on catching up with <strong>3D math</strong>. I ordered a book called <a href="http://www.amazon.co.uk/Primer-Graphics-Development-Wordware-Library/dp/1556229119/" target="_blank">"3D Math Primer"</a>, which explains in detail all the vector and matrix operations involved in 3D graphics. Even though the examples are in C++ I recommend this book to anyone doing 3D in Flash. The authors made a great effort to explain the subject with clarity. It worked pretty well for me and I understand the math behind 3D much better now. </p>
<p>Both <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> and <a href="http://www.away3d.com/" target="_blank">Away3D</a> were created so that <strong>we don't have to deal directly with 3D calculations</strong>. If you are working on a project that involves non-trivial 3D and has a deadline, it's better to choose one of those engines instead of "pure Flash Player 10". </p>
<p>However, if you just want to do some <strong>casual experiments</strong> and learn something on the way, <strong>FP10 is great</strong>. It offers a small number of tools, focused around <strong>Vector3D and a Matrix3D</strong> classes. These classes offer low level functionality, so to use them one needs to understand what's going on under the hood. This is a great way to learn! </p>
<p>Then I had this idea to port <strong>AS3Dmod to Flash Player 10</strong> and try to run the modifiers on objects created using FP10 3D classes. It turns out it was not so difficult. Instead of rendering textured 3D objects I just render a <strong>single pixel for each vertex</strong>. Thanks to this I get a relatively good performance even with as much as <strong>8000 vertices</strong>. I found that a modifier applied to such a large amount of vertices, gives interesting visual effects. I even wrote a very simple <strong>Wavefront OBJ importer</strong>, and I could import the 3d pants model from one of my <a href="http://www.everydayflash.com/blog/index.php/2009/02/09/making-things-walk-in-flash-3d/" target="_blank">previous posts</a> to <a href="http://www.everydayflash.com/flash/as3dmod/fp10/walk.html" target="_blank">render them in Flash Player 10</a>. </p>
<p>All my previous demos with AS3Dmod involved pretty <strong>small amount of vertices</strong> - most often no more than 500-600. At this level the performance of the modifiers was not a problem. But with 8000 vertices the modifiers start to have an big impact on the frame rate. A Perlin modifier alone takes <strong>4-5 FPS</strong>, which is quite a lot and it got me worried. I believe code optimizations are in order. An interesting solution could be to implement the <strong>modifiers as a Pixel Bender kernels</strong>. Anyway, I need to do some more research...</p>
<p>In the AS3Dmod SVN you'll find the <a href="http://code.google.com/p/as3dmod/source/browse/#svn/branches/fp10" target="_blank">FP10</a> branch. The main difference between this version and the trunk is that it uses FP10 built-in <strong>Vector3D</strong> and <strong>Matrix3D</strong> classes as well as <strong>Vectors instead of Arrays</strong>. The sources for all experiments mentioned above, including a simple AS3Dmod plugin for FP10, are <a href="http://code.google.com/p/barteksplayground/source/browse/#svn/trunk/fp10/src/com/everydayflash/cart" target="_blank">available here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=BvXhryN7kv0:1iVWSrdBhlE:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=BvXhryN7kv0:1iVWSrdBhlE:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=BvXhryN7kv0:1iVWSrdBhlE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/BvXhryN7kv0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/03/16/3d-experiments-with-flash-player-10-and-as3dmod/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/03/16/3d-experiments-with-flash-player-10-and-as3dmod/</feedburner:origLink></item>
		<item>
		<title>Car simulation with Maya &amp; Papervision3d</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/Lvhau4JX4zA/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 10:17:09 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[car]]></category>
		<category><![CDATA[car game]]></category>
		<category><![CDATA[car physics]]></category>
		<category><![CDATA[car simulation]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[mustang]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[racing]]></category>
		<category><![CDATA[racing game]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=51</guid>
		<description><![CDATA[Take a test drive with a powerful Mustang GT in a desert scenery! This demo features a car model imported from Maya into Papervision3D. It uses some home-made physics to simulate the car movement and a couple of new AS3Dmod features to manage the model (more below). I created this demo together with Krister Karlsson. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/flash/mustang/" target="_blank"><img src="/flash/mustang/mustang.jpg" width="520" height="200" border="0" alt="Mustang GT | Maya, Papervision3D"></a></p>
<p>Take a test drive with a powerful <strong>Mustang GT</strong> in a desert scenery! This demo features a car model imported from Maya into Papervision3D. It uses some home-made physics to simulate the car movement and a couple of new AS3Dmod features to manage the model (more below). </p>
<p>I created this demo together with <strong>Krister Karlsson</strong>. Krister is a 3d artist working with Maya and founder of <a href="http://www.modesty.se" target="_blank">Modesty</a> - a Stockholm based creative agency. The (super)low poly Mustang used here is based on a concept model made by Krister that was <strong>later used to create an actual car!</strong> You can read more about <a href="http://modesty.se/clients/eleanor/" target="_blank">this project here</a>.</p>
<p>Working with this demo has been an occasion for me to explore all the spectrum of Flash 3D related development, like importing and managing a <strong>complex model</strong>, adding interaction and scripting <strong>car physics</strong>. All this with a reasonable performance in mind, of course. </p>
<p>There is quite a lot of source code involved in this demo. I won't be publishing it all as parts of it are rather messy. Instead I'll focus on some <strong>particular problems</strong> I've encountered and solutions to them.</p>
<p><strong>Pivots.</strong> I can't tell if this is a problem of the <a href="http://sourceforge.net/projects/colladamaya/" target="_blank">Maya Collada Exporter</a> or if we have been doing something wrong, but the fact remains that <strong>moving the pivot point of an object in Maya is not reflected in Papervision3D</strong>. Instead, all pivot points default to the center of the whole object when the DAE file is imported.</p>
<p>To fix it, I had the idea to move the pivot point in Actionscript. Unfortunately, there isn't an easy way to do that in Papervision3D. This problem is <a href="http://www.nabble.com/changing-rotation-pivot-td14613233.html#a14613233" target="_blank">generally solved</a> by putting the DisplayObject3D inside another and move it in relation to its parent. But when all the objects are part of a structured DAE it becomes quite painful and requires additional steps. So instead, I wrote a modifier that takes care of that. It's called <a href="http://code.google.com/p/as3dmod/source/browse/trunk/src/com/as3dmod/modifiers/Pivot.as" target="_blank"><strong>Pivot</strong></a>, and this is the way it works:</p>
<div class="igBar"><span id="lactionscript-37"><a href="#" onclick="javascript:showPlainTxt('actionscript-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-37">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> do3d:Cube = <span style="color: #000000; font-weight: bold;">new</span> Cube<span style="color: #66cc66;">&#40;</span>materials, <span style="color: #cc66cc;color:#800000;">200</span>, <span style="color: #cc66cc;color:#800000;">200</span>, <span style="color: #cc66cc;color:#800000;">200</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> stack:ModifierStack = <span style="color: #000000; font-weight: bold;">new</span> ModifierStack<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LibraryPv3d<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, do3d<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> pivot:Pivot = <span style="color: #000000; font-weight: bold;">new</span> Pivot<span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;color:#800000;">200</span>,-<span style="color: #cc66cc;color:#800000;">200</span>,-<span style="color: #cc66cc;color:#800000;">200</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #006600;">addModifier</span><span style="color: #66cc66;">&#40;</span>pivot<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #006600;">collapse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This piece of code will move the pivot point <strong>-200 units on all 3 axes</strong>. In case of this cube it will end up in the lower left corner. It does it without creating any additional display objects, but rather by offsetting all the objects vertices.</p>
<p>Please note that I collapse the stack after applying the pivot. Otherwise the pivot would be moved at every call to <code>stack.apply()</code>, which is not what we are looking here for.</p>
<p>The problem with the Mustang model was that all 4 wheels were rotating around the center of the car rather then around individual centers of each object. I needed to move the pivot point to the center of each wheel. I thought that moving the pivot to the geometrical center of the object is a typical thing to do, so I create a shortcut method for it:</p>
<div class="igBar"><span id="lactionscript-38"><a href="#" onclick="javascript:showPlainTxt('actionscript-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-38">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pivot.<span style="color: #006600;">setMeshCenter</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Calling this function automatically sets the pivot point in the geometrical <strong>center of the mesh</strong>. At this point I thought I was done with the wheels, but there was one more problem...</p>
<p><strong>Roll &#038; steer</strong>. I think anyone who ever created an interactive 3d car model must have faced this one. <strong>A wheel rolls around the Z axis and the steering goes along it's Y axis</strong>. So, the first think that came to my mind when I started to code it was:</p>
<div class="igBar"><span id="lactionscript-39"><a href="#" onclick="javascript:showPlainTxt('actionscript-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-39">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wheel.<span style="color: #006600;">rotationZ</span> += <span style="color: #cc66cc;color:#800000;">10</span>; <span style="color: #808080; font-style: italic;">// roll 10 degrees</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wheel.<span style="color: #006600;">rotationY</span> = <span style="color: #cc66cc;color:#800000;">30</span>; <span style="color: #808080; font-style: italic;">// turn 30 degrees </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>While this code seems perfectly logical, when put in action <strong>things go wrong</strong> and the wheel starts to act like if the car had undergone a severe crash.</p>
<p>The reason for this is that once the wheel rotates along the Y axis (turns), the Z axis is no longer the right axis for roll. The correct axis would be the Z axis rotated 30 degrees on the XZ plane. </p>
<p>Again, a solution would be to enclose the wheel into a parent DisplayObject3D and then use the parent to steer and the child to roll. However, since I had already an elegant solution for the pivot I didn't want to <strong>clutter my model</strong> with an additional set of elements for this one either. </p>
<p>There comes the <strong><a href="http://code.google.com/p/as3dmod/source/browse/trunk/src/com/as3dmod/modifiers/Wheel.as" target="_blank">Wheel modifier</a></strong>. Apply it to an object - typically of a cylindrical shape - and use its <code>speed</code> and <code>turn</code> properties to manipulate the wheel. </p>
<div class="igBar"><span id="lactionscript-40"><a href="#" onclick="javascript:showPlainTxt('actionscript-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-40">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> do3d:DisplayObject3D = dae.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"wheel"</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> stack:ModifierStack = <span style="color: #000000; font-weight: bold;">new</span> ModifierStack<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LibraryPv3d<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, do3d<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> wheel:Wheel = <span style="color: #000000; font-weight: bold;">new</span> Wheel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #006600;">addModifier</span><span style="color: #66cc66;">&#40;</span>wheel<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Please mind that it expects values in radians</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wheel.<span style="color: #006600;">turn</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;color:#800000;">6</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wheel.<span style="color: #006600;">speed</span> = <span style="color: #cc66cc;color:#800000;">5</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Internally the modifier applies some math to <strong>rotate the roll axis according the the current turn value</strong> so that everything looks fine and you don't need to worry about it ;) Read the <a href="http://www.everydayflash.com/flash/as3dmod/doc/com/as3dmod/modifiers/Wheel.html" target="_blank">documentation of this class</a> for more information.</p>
<p>All this new features are available in the <strong>latest SVN revision of AS3Dmod</strong>. So, go ahead and <a href="http://code.google.com/p/as3dmod/source/checkout" target="_blank">grab it </a> later. But first, <a href="/flash/mustang/" target="_blank">enjoy your ride</a>!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=Lvhau4JX4zA:wTIqbheNuHY:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=Lvhau4JX4zA:wTIqbheNuHY:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=Lvhau4JX4zA:wTIqbheNuHY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/Lvhau4JX4zA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/</feedburner:origLink></item>
		<item>
		<title>Making things walk in Flash 3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/GbMOVsYX6g0/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/02/09/making-things-walk-in-flash-3d/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 09:06:22 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[2D Animation]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[character animation]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[walk cycle]]></category>
		<category><![CDATA[walking]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=52</guid>
		<description><![CDATA[An Actionscript-based 3D bone system is something I wanted to do for a long time, but I couldn't figure out how to approach this problem for several months. A few days ago, I finally made a breakthrough. Here's a first demo I quickly put together: a 3D walk cycle. So far the only way to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/flash/walk/" target="_blank"><img src="http://www.everydayflash.com/flash/walk/walk-cycle-3d.png" border="0" alt="Walk cycle in Papervision3D" width="520" height="220" /></a></p>
<p>An <strong>Actionscript-based 3D bone system</strong> is something I wanted to do for a long time, but I couldn't figure out how to approach this problem for several months. A few days ago, I finally made a breakthrough. Here's a first demo I quickly put together: <a href="http://www.everydayflash.com/flash/walk/" target="_blank">a 3D walk cycle</a>.</p>
<p>So far the only way to have a <strong>walking character in Flash 3D</strong> was to create an animation sequence in a 3D editor and export it as an <strong>animated DAE</strong> and/or use <a href="http://cast3d.org/" target="_blank">Cast3D</a>. For sure, this method allows to achieve <a href="http://www.bajibot.com/xmas2008/" target="_blank">awesome results</a>, but it is <strong>not nearly as flexible</strong> as being able to control the animation <strong>directly from Actionscript</strong>.</p>
<p>So, how does the above demo work? First of all I created a model of <strong>pants in Blender</strong>. This is the 4th model I ever did with Blender so it not perfect, but is good enough for the job. The important part is that both legs and the waist form a <strong>single mesh</strong>.</p>
<p>After I imported the model into <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> I applied several <strong>Break modifiers</strong> to the model. The <a href="http://code.google.com/p/as3dmod/source/browse/trunk/src/com/as3dmod/modifiers/Break.as" target="_blank"><strong>Break modifier</strong></a> is a new class I wrote for <a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod</a> and is of key importance for this demo. In brief, it allows to apply rotation only to a group of vertices while leaving the rest untouched. The resulting deformation makes the mesh look like it was broken, hence the name.</p>
<p>I created a <a href="http://code.google.com/p/as3dmod/wiki/AS3Dmod_Tutorial" target="_blank">modifier stack</a> and added <strong>4 Break modifiers</strong> to the pants. One for each tight, and one for each knee. The angle for each of them can be modified separately, which allows dynamic animation. </p>
<p>You probably wonder how I did <strong>indicate which vertices belong to which part of the mesh</strong> (waist, thigh, calf) and how I even know where those parts start or end on the code level. That is crucial in creating an armature and it is also the tricky part. Most of the 3D IDEs, like 3Dsmax or Blender have some kind of visual interface that allows the user to <strong>select vertices and attach them to a bone</strong>. In AS everything is code, so this is a challenge. I must confess that for this demo I hardcoded some values and did some assumptions to make it work, but I think there is a way to make this task <strong>relatively easy</strong> or at least possible to apprehend.</p>
<p>In the long run, it would be cool if bones could be <strong>exported from 3D IDEs</strong> and <strong>exposed as objects</strong> in Actionscript. As far as I know, there isn't anything like this available for the moment. <a href="http://www.away3d.com" target="_blank">Away3D</a> supports <a href="http://www.infiniteturtles.co.uk/blog/away3d-multimario" target="_blank">collada bone animation</a> but, despite its promising name, it serves a different purpose (correct me if I am wrong.)</p>
<p>Let's go back to the demo. Once I had the Break modifiers in place and applied to the correct areas of the mesh, the rest was rather easy. To create a proper <strong>walk cycle</strong>, I just took <a href="http://www.bit-101.com/blog/" target="_blank">Keith Peters'</a> book <a href="http://www.friendsofed.com/book.html?isbn=1590597915" target="_blank"><strong>"Making Things Move"</strong></a>, Chapter 13 on <strong>Forward Kinematics</strong>, and I adapted the code from the examples.</p>
<p>In case you don't know that book, I would strongly recommend getting it. It contains all the essential stuff you need to know, if you want to call yourself a serious AS3 developer. I never leave home without it! There is also a <a href="http://www.friendsofed.com/book.html?isbn=9781430216087" target="_blank">sequel</a>, with stuff for Flash Player 10.</p>
<p>This walk cycle is only a <strong>first step</strong> to create a bone system in AS, but I wanted to share it with you without spending another few months making it fully featured. <strong>Break modifier</strong> is available in the latest <a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod</a> SVN repository. I should warn you however that this is a <strong>very early version</strong>, not really usable for the moment. </p>
<p>Of course, updates are coming so <strong>stay tuned!</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=GbMOVsYX6g0:9PStn2Qp8QM:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=GbMOVsYX6g0:9PStn2Qp8QM:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=GbMOVsYX6g0:9PStn2Qp8QM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/GbMOVsYX6g0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/02/09/making-things-walk-in-flash-3d/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/02/09/making-things-walk-in-flash-3d/</feedburner:origLink></item>
		<item>
		<title>The AS3Dmod tutorial</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/ZJOtWdtTSXc/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2009/01/06/the-as3dmod-tutorial/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 19:23:16 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[Actionscript APIs]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=49</guid>
		<description><![CDATA[I did some research in the blogs and on Twitter, and often when someone mentioned AS3Dmod, the recurring theme was the lack of documentation. Yeah... but creating proper documentation is such a difficult task! First of all, it's hard to find enough free time. Then, even if you find some, most of us, including me, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/as3dmod/wiki/AS3Dmod_Tutorial" target="_blank"><img src="/flash/as3dmod/as3dmod-tutorial.gif" width="520" height="200" border="0" alt="The AS3Dmod tutorial"></a></p>
<p>I did some research <strong>in the blogs and on Twitter</strong>, and often when someone mentioned AS3Dmod, the recurring theme was the <strong>lack of documentation</strong>. Yeah... but creating proper documentation is such a difficult task! </p>
<p>First of all, it's hard to find enough free time. Then, even if you find some, most of us, including me, will always find it more fun <strong>to write code instead</strong>. Eventually, I profited of the calmer period in the last 3 weeks and made some progress with that. The result is <a href="http://code.google.com/p/as3dmod/wiki/AS3Dmod_Tutorial" target="_blank"><strong>the AS3Dmod tutorial</strong></a>.</p>
<p>In the tutorial you will find answers to the following topics:</p>
<ul>
<li>how to integrate AS3Dmod with the Flash 3d engines</li>
<li>how the modifier stack works</li>
<li>how to create and apply modifiers</li>
<li>how to animate the modifier properties</li>
<li>how to use the <code>collapse</code> feature</li>
</ul>
<p>Beside the tutorial there are <a href="http://www.everydayflash.com/flash/as3dmod/doc/" target="_blank"><strong>API Docs</strong></a> available for some time now. </p>
<p>Another thing are simple <strong>interactive demos for each modifier</strong>. So far I created it for one: <strong>Skew</strong>. You <a href="http://www.everydayflash.com/flash/as3dmod/demo/skew.html" target="_blank">can view it here</a>. The demo allows to see all the properties and features of the modifier in action, instead of explaining it in writing. If this concept gets some positive feedback, I'll try to do more of those.</p>
<p>Hope you will find all this useful, and remember that feedback is very welcome (and much needed). And of course <strong>Happy New Year everyone!</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ZJOtWdtTSXc:dki-xRX_IY0:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=ZJOtWdtTSXc:dki-xRX_IY0:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ZJOtWdtTSXc:dki-xRX_IY0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/ZJOtWdtTSXc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2009/01/06/the-as3dmod-tutorial/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2009/01/06/the-as3dmod-tutorial/</feedburner:origLink></item>
		<item>
		<title>EA Skateit Nintendo DS demo with Papervision3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/ap0PBjhlJY0/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2008/12/16/paperskate3d-ea-skateit/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 22:32:34 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[EA]]></category>
		<category><![CDATA[Electronic Arts]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[gesture recognition]]></category>
		<category><![CDATA[Nintendo ds]]></category>
		<category><![CDATA[paperking3d]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[skate]]></category>
		<category><![CDATA[skateboard]]></category>
		<category><![CDATA[skateboarding game]]></category>
		<category><![CDATA[skateit]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=48</guid>
		<description><![CDATA[Those of you who follow my blog, may remember the Paperskate3D demo I published back in the summer. Back then I said that I'll post the rest of the story someday. So here it is. It was originally created for the Paperking3D contest organized by the Pv3D team. There were many awesome project sent it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.skateit.ea.com/" target="_blank"><img src="/blog-assets/skateit.jpg" width="520" height="200" border="0" alt="Nintendo DS Skate Demo"></a></p>
<p>Those of you who follow my blog, may remember the <a href="http://www.paperskate3d.com" target="_blank">Paperskate3D demo</a> I published back in the summer. Back then I said that I'll post the <strong>rest of the story</strong> someday. So here it is. </p>
<p>It was <strong>originally created</strong> for the <a href="http://blog.papervision3d.org/2008/07/02/paperking3d-the-papervision3d-contest/" target="_blank"><strong>Paperking3D contest</strong></a> organized by the Pv3D team. There were many awesome project sent it for this contest, including <a href="http://code.google.com/p/vectorvision/" target="_blank">Vectorvision</a> - the cool 3d vector library. The skate demo didn't make it to the top 3 but it received a <strong>honorable mention</strong>, which made me very happy.</p>
<p>But the best came a bit later, when I was contacted by <a href="http://www.revolutivedesign.com/" target="_blank">Revolutive Design</a> from Vancouver. Based on the original application, together we created a demo for <a href="http://www.skateit.ea.com/" target="_blank"><strong>Skateit</strong>,</a> a new <strong>skating game from Electronic Arts targeted for Nintendo DS</strong>. </p>
<p>To <strong>biggest improvement</strong> over the original version is the new way the skateboard is controlled by the user. While before it was based on keyboard, in the EA demo it is modeled on the "Flickit" system which allows to <strong>control the skateboard with the stylus</strong> on the DS. To simulate this in Flash, I used mouse <strong>gesture recognition</strong> based on the <a href="http://www.bytearray.org/?p=91" target="_blank">excellent class</a> provided by Didier Brun. This class was originally intended to identify written characters, but I was able to adapt it to my needs pretty easily. In the demo, it is used to recognize gestures for 20 different tricks. </p>
<p>To access the demo go to the <a href="http://www.skateit.ea.com/" target="_blank">EA website</a> and click the large button in the middle right of the screen. Have fun! </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ap0PBjhlJY0:N_Nzef9uzZw:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=ap0PBjhlJY0:N_Nzef9uzZw:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=ap0PBjhlJY0:N_Nzef9uzZw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/ap0PBjhlJY0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2008/12/16/paperskate3d-ea-skateit/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2008/12/16/paperskate3d-ea-skateit/</feedburner:origLink></item>
		<item>
		<title>Wind simulation with modifiers and WOW Engine</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/1vshvLLhwVc/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2008/12/08/wind-simulation-wow-engine-as3dmod/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 08:30:22 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash physics]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[physics simulation]]></category>
		<category><![CDATA[wind simulation]]></category>
		<category><![CDATA[wow]]></category>
		<category><![CDATA[wow-engine]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=47</guid>
		<description><![CDATA[WOW-Engine is an Actionscript API to simulate physics in a 3d environment. The code is based on a popular 2d physics library - APE. It offers some very interesting possibilities in 3D animation, and everyone doing 3D in Flash should have it in their toolbox. WOW engine simulates a physics world model composed of entities [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/flash/pv3d/windsock/" target="_blank"><img src="http://www.everydayflash.com/flash/pv3d/windsock/windsock.jpg" border="0" alt="" width="520" height="202" /></a></p>
<p><strong><a href="http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/" target="_blank">WOW-Engine</a></strong> is an Actionscript <strong>API to simulate physics in a 3d environment</strong>. The code is based on a popular 2d physics library - <a href="http://www.cove.org/ape/" target="_blank"><strong>APE</strong></a>. It offers some very interesting possibilities in 3D animation, and everyone doing 3D in Flash should have it in their toolbox.</p>
<p>WOW engine <strong>simulates a physics world model</strong> composed of entities called particles. <strong>Particles</strong> can be connected using <strong>constraints</strong> and exposed to different <strong>forces</strong> that make them move around. Some more information as well as a few tutorials can be found on the <a href="http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/" target="_blank">projects home page</a>.</p>
<p>The basic technique of using WOW and 3D in Flash is to <strong>map those particles to objects on the 3D scene</strong>, and before each render read synchronize their x, y and z coordinates. But there are other ways too... On the WOW page, <a href="http://seraf.mediabox.fr/wow-engine/wow-engine-technical-advanced-demo-cloth-demo-01/" target="_blank">here</a> and <a href="http://seraf.mediabox.fr/wow-engine/wow-engine-technical-advanced-demo-cloth-demo-03/" target="_blank">here</a> you can find some examples of particles mapped not to whole objects but rather to <strong>individual vertices</strong>. </p>
<p><strong>Animation based on vertices</strong> has been my main preoccupation for some time now, so I got immediately interested. Unfortunately those WOW examples come <strong>without source code</strong>, so I had to figure that out on my own. The <a href="http://www.everydayflash.com/flash/pv3d/windsock/" target="_blank">above demo</a> comes as a result. </p>
<p>Some quick details: the windsock was modeled in <a href="http://www.blender.org" target="_blank">Blender</a> and the textures were baked using the technique I mentioned in my <a href="http://www.everydayflash.com/blog/index.php/2008/11/20/texture-baking-is-your-friend/" target="_blank">previous post</a>. On the flash side <a href="http://blog.papervision3d.org" target="_blank">Papervision3D</a> engine is used and a couple of <a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod</a> modifiers - <strong>Taper and Perlin</strong>.</p>
<p>This is my <strong>first experiment</strong> with <strong><a href="http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/" target="_blank">WOW physics engine</a></strong>, but after getting a basic understanding of how it works, I am convinced there is a big potential in <strong>combining AS3Dmod and WOW</strong>, so more stuff will be coming hopefully!</p>
<p>As usual here's the <strong><a href="http://www.everydayflash.com/flash/pv3d/windsock/windsock.zip">source code</a></strong>. Please mind that this code is a result of a late night coding session ;)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=1vshvLLhwVc:Z2Pg9PtAt7g:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=1vshvLLhwVc:Z2Pg9PtAt7g:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=1vshvLLhwVc:Z2Pg9PtAt7g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/1vshvLLhwVc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2008/12/08/wind-simulation-wow-engine-as3dmod/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2008/12/08/wind-simulation-wow-engine-as3dmod/</feedburner:origLink></item>
		<item>
		<title>Texture baking is your friend</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/GCMpxFqQOmI/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2008/11/20/texture-baking-is-your-friend/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 23:57:59 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[alternativa3d]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[ecodazoo]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[roxik]]></category>
		<category><![CDATA[texture baking]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=45</guid>
		<description><![CDATA[Texture baking has been known to the Flash 3d community since a long time, but a quick look into Google shows us that it is not a very popular topic. I think it definitely should get more attention. In Flash performance is always an issue, and high quality is always expected by our clients. Texture [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/flash/chair/" target="_blank"><img src="http://www.everydayflash.com/flash/chair/awaychair.jpg" border="0" alt="" width="520" height="202" /></a></p>
<p><strong>Texture baking</strong> has been known to the Flash 3d community since a long time, but a quick look into Google shows us that it is not a very popular topic. I think it definitely should get more attention. <strong>In Flash performance is always an issue, and high quality is always expected</strong> by our clients. Texture baking helps to achieve this goal. </p>
<p>In short, it consists of getting all the lightning effects of a material and "burning" them directly on the material itself. After such operation, the lights cannot change anymore, but the material gets a nice effect of depth and it doesn't require any more computations at runtime.</p>
<p>Most of the available 3D software offers a texture baking function. <a href="http://www.everydayflash.com/flash/chair/" target="_blank">For the demo above</a>, I did choose <strong><a href="http://www.blender.org/" target="_blank">Blender</a></strong> because it's free (it also has a very weird user interface, but I digress). On the Flash side, it runs on <strong><a href="http://www.away3d.com" target="_blank">Away3d</a></strong>.</p>
<p>To create a model with baked textures in Flash I followed this steps:</p>
<ol>
<li><strong>Create the 3d model</strong> of the chair in Blender</li>
<li><strong>Project all the faces</strong> of the model on to an bitmap (in Blender its called UV Unwrapping)</li>
<li><strong>Paint the texture</strong> in Photoshop</li>
<li>Import the texture to Blender and <strong>apply it to back the model</strong></li>
<li><strong>Add lights and bake the texture</strong> on to another bitmap</li>
<li><strong>Export the geometry</strong> with the UV information included (<a href="http://en.wikipedia.org/wiki/COLLADA" target="_blank">Collada</a> or <a href="http://en.wikipedia.org/wiki/Obj" target="_blank">Wavefront</a>)</li>
<li><strong>Export the baked texture</strong> as a jpg</li>
<li>Import both into Flash and use your favorite 3d engine to render</li>
</ol>
<p>Each of the steps above could require a separate tutorial, so instead I published some <strong>files created in the process</strong> to give you a better idea. You can <a href="http://www.everydayflash.com/flash/chair/baked-textures.zip">get them here</a>. <em>Please note, that this is only a reference material - it is not supposed to be built or compiled or anything.</em></p>
<p>Additionally, for those of you who use Blender a nice tutorial on both <strong>UV Texture Mapping and Texture Baking</strong> is <a href="http://www.scifi-meshes.com/forums/dojo/1755-blender-faint-hearted-08-uv-texture-mapping-texture-baking.html" target="_blank">available here</a>.</p>
<p>In the current state of Flash 3D and its overall performance, texture baking is a <strong>highly useful technique</strong> that allows to achieve very good results. If you do not believe me, take look at some of the most awesome Flash 3d pieces that came out in the last few months: </p>
<ul>
<li><strong><a href="http://blog.alternativaplatform.com/ru/files/2008/04/bunker.swf" target="_blank">Bunker demo</a></strong> by Alternativa3d team (<a href="http://alternativaplatform.com/en/download/src/bunker_src_en.zip" target="_blank">sources available here</a>) </li>
<li><strong><a href="http://ecodazoo.com/" target="_blank">EcoDaZoo</a></strong> by <a href="http://www.roxik.com/" target="_blank">Roxik</a></li>
</ul>
<p>I am sure you've seen them before anyway. They both combine great visual effects with a very high performance. And guess what... in both of them, you'll find <strong>baked textures all over the place!</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=GCMpxFqQOmI:jv21SCEE-6k:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=GCMpxFqQOmI:jv21SCEE-6k:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=GCMpxFqQOmI:jv21SCEE-6k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/GCMpxFqQOmI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2008/11/20/texture-baking-is-your-friend/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2008/11/20/texture-baking-is-your-friend/</feedburner:origLink></item>
		<item>
		<title>Paper simulation in with AS3Dmod and Away3D</title>
		<link>http://feedproxy.google.com/~r/EverydayFlash/~3/opxOckihj8M/</link>
		<comments>http://www.everyday3d.com/blog/index.php/2008/11/03/paper-simulation-as3dmod/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 09:28:09 +0000</pubDate>
		<dc:creator>bartek drozdz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[as3dmod]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[bend modifier]]></category>
		<category><![CDATA[declaration of independence]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[tweener]]></category>

		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=44</guid>
		<description><![CDATA[Since I released the bend modifier a lot of people have been asking how to bend an object not only along one of its axes, but along any angle. That was clearly a feature missing, but I also didn't have a clue ho to do that. Now, a after a good few days of struggle, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.everydayflash.com/flash/paper/" target="_blank"><img src="http://www.everydayflash.com/flash/paper/awaypaper.jpg" border="0" alt="" width="520" height="202" /></a></p>
<p>Since I released the bend modifier a lot of people have been asking how to bend an object not only along one of its axes, but <strong>along any angle</strong>. That was clearly a feature missing, but I also didn't have a clue ho to do that. Now, a after a good few days of struggle, and with a little help from my friends - <a href="http://www.everydayflash.com/flash/paper/" target="_blank">here it is</a>. </p>
<p>The Bend class now takes 3 arguments in the constructor, the third being the angle at which the bend is executed. Please mind, that this argument expects an <strong>angle in radians</strong>. In the code it looks like this:</p>
<div class="igBar"><span id="lactionscript-42"><a href="#" onclick="javascript:showPlainTxt('actionscript-42'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-42">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> mesh:Mesh = <span style="color: #66cc66;">&#91;</span>a mesh<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> stack:ModifierStack = </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> ModifierStack<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LibraryAway3d<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, mesh<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> bend:Bend = <span style="color: #000000; font-weight: bold;">new</span> Bend<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span>, .<span style="color: #cc66cc;color:#800000;">5</span>, <span style="color: #cc66cc;color:#800000;">1</span>.<span style="color: #cc66cc;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #006600;">addModifier</span><span style="color: #66cc66;">&#40;</span>bend<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stack.<span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Of course, there is also a getter/setter for the <code>angle</code>, which allows to change the value dynamically, and to use libraries such as Tweener to animate it. </p>
<p>The Bend modifier is now part of the <strong><a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod library</a></strong>. Since AS3Dmod is cross-engine, the above demo was done <strong>with Away3D</strong>, but of course, <strong>the same functionality can be used with other engines</strong>, including Papervision3D. </p>
<p>For those of you who remember the <a href="http://www.everydayflash.com/blog/index.php/2008/06/11/bending-modifier-papervision3d/" target="_blank">initial bending demo</a>, I used a 100$ bill as a graphic element then. I thought it would fun to be consistent and to stay in the American theme. Therefore, <a href="http://www.everydayflash.com/flash/paper/" target="_blank">this time</a> you can play with the <a href="http://en.wikipedia.org/wiki/United_States_Declaration_of_Independence" target="_blank">Declaration of Independence</a>. Fans of <a href="http://www.imdb.com/title/tt0368891/" target="_blank">"National Treasure"</a> should be delighted.</p>
<p>As usual the sources are available and you can <a href="http://www.everydayflash.com/flash/paper/awaypaper.zip" target="_blank">get them here</a>. I hope you like the demo and that you will find the code useful. To compile it you need the latest versions of <a href="http://code.google.com/p/as3dmod/" target="_blank">AS3Dmod</a>, <a href="http://away3d.com/" target="_blank">Away3D</a> and <a href="http://code.google.com/p/tweener/"target="_blank">Tweener</a> libraries.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=opxOckihj8M:IB64OBV6fXU:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?i=opxOckihj8M:IB64OBV6fXU:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/EverydayFlash?a=opxOckihj8M:IB64OBV6fXU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/EverydayFlash?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/EverydayFlash/~4/opxOckihj8M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.everyday3d.com/blog/index.php/2008/11/03/paper-simulation-as3dmod/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
		<feedburner:origLink>http://www.everyday3d.com/blog/index.php/2008/11/03/paper-simulation-as3dmod/</feedburner:origLink></item>
	</channel>
</rss>
