<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thinking in Code &#187; model</title>
	<atom:link href="http://www.michelboudreau.com/tags/model/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michelboudreau.com</link>
	<description>Michel Boudreau&#039;s Personal Blog</description>
	<lastBuildDate>Wed, 25 Apr 2012 20:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Alternator &#8211; A Mock DynamoDB Server</title>
		<link>http://www.michelboudreau.com/2012/04/05/alternator-a-mock-dynamodb-server/</link>
		<comments>http://www.michelboudreau.com/2012/04/05/alternator-a-mock-dynamodb-server/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 21:29:27 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[alternator]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dynamodb]]></category>
		<category><![CDATA[dynamodbclient]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[mapper]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[Thomas Bredillet]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=886</guid>
		<description><![CDATA[When I heard of DynamoDB, I thought to myself that ...]]></description>
			<content:encoded><![CDATA[<p>When I heard of <a href="http://aws.amazon.com/dynamodb/" target="_blank">DynamoDB</a>, I thought to myself that this was the first properly made NoSQL service because of it&#8217;s ability to scale infinitely and the fact that it&#8217;s extremely easy to use and configure.  I decided to plunge head first into it and try it on a project I&#8217;m working on called <a href="http://www.tivity.us" target="_blank">Tivity</a>.</p>
<p>My co-worker (<a href="https://github.com/tnbredillet" target="_blank">Thomas Bredillet</a>) and I started using it immediately for our purposes which seemed to work wonderfully. However, it&#8217;s still in Beta mode and there are a few missing features, one of which is a way to test the database locally.</p>
<p>We couldn&#8217;t find a simple solution online using Java (since our back-end is Java) that would emulate DynamoDB, so we decided to create our own and call it <a href="https://github.com/mboudreau/Alternator" target="_blank">Alternator</a>.  It&#8217;s a fairly simple implementation and it&#8217;s only a first draft right now.  Since we&#8217;re using it on a day to day basis, are are continually improving it where we can but any extra help would definitely be appreciated.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2012/04/05/alternator-a-mock-dynamodb-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping Model State in Components</title>
		<link>http://www.michelboudreau.com/2009/12/11/keeping-model-state-in-components/</link>
		<comments>http://www.michelboudreau.com/2009/12/11/keeping-model-state-in-components/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 21:11:48 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[state]]></category>
		<category><![CDATA[sync]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=204</guid>
		<description><![CDATA[Here&#8217;s a problem that occurs often in UI development; You ...]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a problem that occurs often in UI development; You have a model and you want to do changes that can be &#8216;cancelled&#8217; or reverted back to it&#8217;s original.  You don&#8217;t want to modify the model directly because those are normally the values that the server gives you and you wouldn&#8217;t want to be off-sync with the server if you&#8217;re doing polling or pushing data retrieval.</p>
<p>What&#8217;s the solution?  Since it&#8217;s the actual components doing a change, you want them to keep state because the components know when to update or reset.  How you implement this solution is up to you, but here&#8217;s a utility that might help; ObjectUtil.</p>
<p><span id="more-204"></span></p>
<p><a href="http://livedocs.adobe.com/flex/3/langref/mx/utils/ObjectUtil.html">ObjectUtil</a> is a class (under the mx.utils package) that helps you do various object operations that are particularly useful in this case.  One function especially, &#8216;copy&#8217;, is used to create a straight memory to memory copy (also called a &#8216;deep copy&#8217;) of your object into a new variable.  This can save a lot of time and lines of code to do an actual copy manually, which I&#8217;ve done in my early days of Flex before I found out about this class.  <strong>But be warned, since this is a deep copy, it will copy over everything in it</strong>.   If you were to say, copy an ArrayCollection, it will copy the collection, all the elements within it, and the refering objects within those elements which can be quite costly.  It is best used for a self contained data model classes, that way it copies only small bits of data that&#8217;s needed for a specific component.</p>
<p>Here&#8217;s a quick and dirty example that one could use for their own purposes.  Notice how I use an &#8216;edited&#8217; flag so that new data coming in doesn&#8217;t affect the changes done by the user until the user is done.  This is not the best example, but it does give an idea of how to use ObjectUtil.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:VBox xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import com.codemonkeycreative.delegates.SomeDelegate;
			import com.codemonkeycreative.model.entity.SomeModel;
			import mx.utils.ObjectUtil;

			[Bindable] private var _data:SomeModel;
			private var _currentData:SomeModel;
			private var _min:Number;
			private var _max:Number;
			private var _edited:Boolean = false;

			[Bindable]
			public function get dataProvider():SomeModel
			{
				return this._currentData;
			}

			public function set dataProvider(value:SomeModel):void
			{
				this._currentData = value;
				if(!this._edited)
				{
					this._data = SomeModel(ObjectUtil.copy(this._currentValue));
				}
			}

			private function reset():void
			{
				this._data =  SomeModel(ObjectUtil.copy(this._currentValue));
				this._edited = false;
			}

			private function save():void
			{
				// Call your Delegate/Webservice here with the new value
				// Making this generic since there's many ways to implement
				SomeDelegate.saveValue(this._data);
				this._currentData = this._data;

				// Reset form
				this.reset();
			}

			private function onChange():void
			{
				this._edited = true;
				this._data.value = stepper.value;
			}
		]]&gt;
	&lt;/mx:Script&gt;
	&lt;mx:HBox&gt;
		&lt;mx:Label text=&quot;{stepper.value}&quot; /&gt;
		&lt;mx:NumericStepper id=&quot;stepper&quot; value=&quot;{this._data.value}&quot;  stepSize=&quot;1&quot;
			minimum=&quot;{this._data.min}&quot; maximum=&quot;{this._data.max}&quot; change=&quot;onChange&quot; /&gt;
	&lt;/mx:HBox&gt;
	&lt;mx:HBox enabled=&quot;{this._edited}&quot;&gt;
		&lt;mx:Button label='Reset' click=&quot;reset()&quot; /&gt;
		&lt;mx:Button label='Save' click=&quot;save()&quot; /&gt;
	&lt;/mx:HBox&gt;
&lt;/mx:VBox&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2009/12/11/keeping-model-state-in-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dabbling in Papervision</title>
		<link>http://www.michelboudreau.com/2009/01/06/dabbling-in-papervision/</link>
		<comments>http://www.michelboudreau.com/2009/01/06/dabbling-in-papervision/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 23:00:43 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Papervision]]></category>
		<category><![CDATA[Collada]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[image map]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=52</guid>
		<description><![CDATA[A few months ago, I was approached by the president ...]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I was approached by the president of the company I&#8217;m currently working for.</p>
<p>He needed a game; more precisely, one of our clients needed a game.  The president approached me for two reasons:  I&#8217;m the flash guru in this joint and he knew I wanted to work in games.  We sat down with the client and talked more about the game, how it&#8217;ll play and more importantly, how it&#8217;ll look.</p>
<p>Without a doubt, I pitched the idea that we use<a href="http://blog.papervision3d.org/" target="_blank"> Papervision 3D</a> to render the game.  It&#8217;ll add the extra wow factor to the project when combining it with a proper 2D physics engine to create something that should look and feel like the real thing.  After showing a few examples of what Papervision 3D can do, they were both sold that we should use this technology.  Only problem was, I never used it before and I needed to learn it quickly to get a working prototype up.</p>
<p><span id="more-52"></span></p>
<p>Being an open source project, it was lacking what open source projects lack the most; proper documentation.  A lot of my questions could not be answered through the internet since this project is still very new and not a whole lot of people have dabbled in it.  However, luckily for me, there was an <a href="http://pv3d.org/chat/" target="_blank">irc chan</a> with some really helpful people that saved my ass on several occasions.</p>
<p>For our purposes, we needed two different viewports with two cameras (a shot cam and an overview cam) and because of this, we could only go with the very latest version of <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk" target="_blank">Papervision (Great White)</a>.  For the physics engine, we needed something that&#8217;s fast, easy to use and easy to modify.  I personally selected the <a href="http://www.cove.org/ape/" target="_blank">APE engine</a> since it was one of the least complex, yet it was fast and did it&#8217;s job properly.  I needed something not too complex since I&#8217;m no physics major and furthermore, I needed to modify the engine to have &#8216;z friction&#8217; since this is a 2D engine.  I decided to go with a 2D engine because a 3D engine would be too complex and slow for something which is essentially 2D with a deceleration of speed when moving which I call &#8216;z friction&#8217;.</p>
<p>The learning curve wasn&#8217;t too steep, which is good since we had a tight deadline for this project.  The beginning tutorial on papervision is easy to follow, but the more advanced topics aren&#8217;t exactly talked about and that&#8217;s where things became a hassle.  With our engines chosen, it was off to the races to get this out.</p>
<p><strong>Modeling</strong></p>
<p>When I was in my teens, I did some 3D modeling using <a href="http://www.newtek.com" target="_blank">Lightwave</a> which was self-taught using online resources.  I wasn&#8217;t an expert, but it gave me some basic concepts on how to model and texture.  Thankfully, this knowledge was enough to get me by on this project.</p>
<p>However, there is one important question to ask yourself before you do anything else:  Do I really need a model of that?</p>
<p>Simple question, but I noticed that just a few polygons removed can make a significant difference in processing speed.  Sometimes it&#8217;s the model that&#8217;s too complex, sometimes the texture.  Either way, we needed this game to be able to run on most computers, so performance was the utmost priority.</p>
<p>At first, I used a plane to have the ice surface on.  After trying this out for a while, I decided against it because it was hogging resources to render it.  Instead, I made the background static (both the overview background and shot background), this gave the game a 35% performance increase.  So, before you start modeling, ask yourself if a model is really required, or you could get away with a simple image or some other ingenious solution.</p>
<p>The first obstacle was to import a model into Papervision that was modeled with 3dsmax.  Since Papervision uses the Collada file format to import their models, I decided to use that.  Luckily enough, there&#8217;s a free plugin to export Collada files with 3dsmax (don&#8217;t use the native collada exporter) called <a href="http://update.multiverse.net/wiki/index.php/Installing_the_3ds_Max_COLLADA_Plugin" target="_blank">ColladaMax</a>.  After installing the plugin, we need to create our model; let&#8217;s create a box for example sake.  Next, click the modify tab and make sure our box is selected.  We are now going to create a UVW Map for the box so to texture our model.  Drop down the modifier list and add &#8216;Unwrap UVW&#8217; from the list.  Now, find the &#8216;Parameters&#8217; box and click on the &#8216;Edit&#8217; button.  This will pop up a window with a mesh (a square if you made a box).  Normally, the mesh is a lot more complex when it isn&#8217;t a primitive object and we would need to turn this mesh into a human understandable map.  To simplify it, click the &#8216;Face Sub &#8211; Object Mode&#8217; button at the bottom then click on the &#8216;Mapping&#8217; menu bar item and click on &#8216;Flatten Mapping&#8217;.  Keep the numbers in the popup box as default and click &#8216;ok&#8217;.</p>
<p>You should now see each face of your object in 2D.  Now remove the checkerboard texture from the dropdown box at the top right by clicking on &#8216;Remove Texture&#8217;.  Then click the &#8216;Tools&#8217; menu bar item and select &#8216;Render UVW Template&#8217;.  Keep the defaults and click on the &#8216;Render UV Template&#8217; button. A new window should appear with all your faces outlined.  Click the top-left button to save your template as an image where you can then open it using your favorite image editing software and add whichever texture you want to each face then save your changes while removing the actual template.</p>
<p>Now we&#8217;re going to add the texture to our object. Open the Material Editor window (under Rendering -&gt; Material Editor), and change the name of the material in the combobox to whatever you want or just keep it as default.  Then we will add the image map to this material by pressing the button on the right of the &#8216;Diffuse&#8217; box.  A window should appear with a list and in that list, click on &#8216;Bitmap&#8217;.  You can now choose the texture you want to add to it.  You then just need to click the &#8216;Assign Material to Selection&#8217; button located near the top of the Material Editor window.  That&#8217;s it, our map is now complete.  Now you can see the object with the current applied map to it and you can modify the texture and the changes will be applied to the object in real time.</p>
<p>The last step is to export the model in Collada file format.  Select &#8216;Export Selected&#8217; from the File menu item and select the file type to be &#8216;COLLADA(*.DAE)&#8217; and choose a filename.  A window should appear, make sure that &#8216;Relative Paths&#8217; and &#8216;Triangulate&#8217; option is selected.  The relative paths is so that the texture is in a relative directory from the file you&#8217;re saving (ie. ../../images/texture.jpg).  And that&#8217;s it, you&#8217;re now ready to load your model within papervision!</p>
<p><strong>Importing Model</strong></p>
<p>My prefered way to import a model is to create a subclass of the Collada class to load the model and then you can modify it from within the class as you want.  It&#8217;s also useful to have all the physics related to the model within this subclass.  Here&#8217;s an example class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.*;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FileLoadEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>InteractiveScene3DEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>DisplayObject3D<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>parsers<span style="color: #000066; font-weight: bold;">.</span>Collada<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>MaterialsList<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #3f5fbf;">/**
	*  Creates the different rocks to be displayed in the game
	*
	* @see org.papervision3d.objects.parsers.Collada
	* @see org.papervision3d.objects.DisplayObject3D
	*/</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SomeModel <span style="color: #0033ff; font-weight: bold;">extends</span> Collada
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> modelLoaded<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// loaded flag</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* Constructor
		*
		* @param matList:MaterialList the material list to be added to the model
		* @param name:String name of this specific rock
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SomeModel<span style="color: #000000;">&#40;</span>matList<span style="color: #000066; font-weight: bold;">:</span>MaterialsList<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'modelPath.dae'</span><span style="color: #000066; font-weight: bold;">,</span> matList<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// listen for when it's done</span>
			<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FileLoadEvent<span style="color: #000066; font-weight: bold;">.</span>LOAD_COMPLETE<span style="color: #000066; font-weight: bold;">,</span> handleLoadComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #3f5fbf;">/**
		*  Handles the event when the broom finishs loading the material and model.
		*  Certain properties cannot be accessed until model is fully loaded
		*
		*  @param e:Event event handler object
		*  @return void
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleLoadComplete<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>modelLoaded = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This will load the model, but will not add it to the scene, you need to use the &#8216;scene.addChild&#8217; function to add the model to your scene.  The material list that needs to be provided is the texture that was used on your model in 3dsmax.  So, to instantiate the class to add it to the stage, you&#8217;d do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> mat<span style="color: #000066; font-weight: bold;">:</span>BitmapFileMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;boxMaterial.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> model<span style="color: #000066; font-weight: bold;">:</span>SomeModel = <span style="color: #0033ff; font-weight: bold;">new</span> SomeModel<span style="color: #000000;">&#40;</span>mat<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">'someBox'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>model<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p><strong>Rendering</strong></p>
<p>A problem I&#8217;ve noticed early on is how the rendering engine works.  Apparently, it uses a painter&#8217;s algorithm which isn&#8217;t exactly perfect and when it comes to displaying objects that are close to each other, it can create some flickering.  After a lot of searching, some people on the irc chan helped out.  I needed to change the rendering order of the object manually using a z sort.  To do this, you need to access your viewport and change the sortMode property like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>view<span style="color: #000066; font-weight: bold;">.</span>layer<span style="color: #000066; font-weight: bold;">.</span>util<span style="color: #000066; font-weight: bold;">.</span>ViewportLayerSortMode<span style="color: #000066; font-weight: bold;">;</span>
viewport<span style="color: #000066; font-weight: bold;">.</span>containerSprite<span style="color: #000066; font-weight: bold;">.</span>sortMode = ViewportLayerSortMode<span style="color: #000066; font-weight: bold;">.</span>INDEX_SORT<span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>After that, the rest was easy.  I placed all rendered objects in a 2D array consisting of the object itself then it&#8217;s z coordinate.  Since the camera was at (0, 0, 0), we can sort the array using the z index in descending order and add the proper layerIndex to each model.</p>
<p><strong>Conclusion</strong></p>
<p>This game was quite an experience and has gotten quite a good amount of attention.  Throughout the whole project, creating the model, adding the texture and the z sorting was the biggest challenges because of lack of information.  Hopefully this will help anyone out there.  Please be free to ask any questions or come visit on the irc chan.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2009/01/06/dabbling-in-papervision/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/20 queries in 0.007 seconds using disk: basic
Object Caching 419/476 objects using disk: basic

Served from: www.michelboudreau.com @ 2012-05-21 07:20:08 -->
