<?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>publicreative lab &#187; Papervision</title>
	<atom:link href="http://lab.publicreative.com/tag/papervision/feed/" rel="self" type="application/rss+xml" />
	<link>http://lab.publicreative.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 15:59:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Inside the Classic</title>
		<link>http://lab.publicreative.com/2009/04/inside-the-classic/</link>
		<comments>http://lab.publicreative.com/2009/04/inside-the-classic/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 16:19:52 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Collada]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Papervision]]></category>

		<guid isPermaLink="false">http://lab.publicreative.com/?p=105</guid>
		<description><![CDATA[It’s been a while between posts for me. Mainly because I have been heavily involved in creating the Remaster the Classic project for the last month or so.
The site was made for K-Swiss and MTV to promote the K-Swiss Classic Remastered trainer. Users have the opportunity to customise their Classic by expressing their creativity using [...]]]></description>
			<content:encoded><![CDATA[<p>It’s been a while between posts for me. Mainly because I have been heavily involved in creating the <a href="http://www.remastertheclassic.com/gb#/create">Remaster the Classic</a> project for the last month or so.</p>
<p>The site was made for K-Swiss and MTV to promote the K-Swiss Classic Remastered trainer. Users have the opportunity to customise their Classic by expressing their creativity using paint, graphics and uploading images not to mention adding chains, diamonds and/or studs to their shoe.</p>
<p>Designs are applied to the shoe (a Collada  model rendered with Papervision, created in Maya) in real time. Users can continue to edit the shoe until they are happy with it and then submit the shoe to the competition and <a href="http://www.remastertheclassic.com/gb#/gallery">gallery</a> when both the texture and a thumbnail of the designed shoe are saved.</p>
<p>There were many challenges and many (very) late nights but well worth it as the end result has proven to be extremely popular. Below is a high level overview of the site in relation to the functionality of the Shoe.</p>
<p><span id="more-105"></span><br />
<strong>Creating the model and applying materials.</strong></p>
<p>The shoe model and the additions you can add to it (the chains and the studs) were created in Maya and exported as Collada  files using the <a href="http://sourceforge.net/project/showfiles.php?group_id=136478">Collada plugin</a>. The chains and studs are separate Collada files with individual textures that are mapped to each of them. These are added as children to the main shoe DAE.</p>
<p>Most people reading this will probably be aware that when you export a Collada file from Maya (or Max) that you want to use with Papervision you need a Collada (.dae) file and the texture/material image that has been mapped to that model.</p>
<p>The trick is getting this material image to map correctly to the model in Papervision. To do this you need to know where to look.</p>
<p>With a Collada file exported from Maya I found you need to search the Collada file for the triangles node.</p>
<p>Here it is in our Collada file.</p>

<div class="wp_syntax"><div class="code"><pre class="xml xml" style="font-family:monospace;">triangles material=&quot;a_Backed_Shoe2SG&quot; count=&quot;1958&quot;</pre></div></div>

<p>You need the name of the material, in our case &#8220;a_Backed_Shoe2SG&#8221;.</p>
<p>Then when you are creating the MaterialsList to use with the DAE in Papervision you pass it this name.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #009900;">// create a BitmapMaterial instance using the BitmapData from the loaded texture image.</span>
_shoeMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapMaterial<span style="color: #000000;">&#40;</span>_loader.getBitmapData<span style="color: #000000;">&#40;</span>_shoeTexture<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// create a new materials list. Pass it the bitmap material and give it the name we found in the Collada file from the triangles node.		 </span>
_materialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; _materialsList.addMaterial<span style="color: #000000;">&#40;</span> _shoeMaterial , <span style="color: #990000;">&quot;a_Backed_Shoe2SG&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// the shoeDae is an instance of a DAE class and is passed the loaded DAE file in binary form and the materials list we created above.</span>
_shoeDae.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>_loader.getBinary<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;shoe_model&quot;</span><span style="color: #000000;">&#41;</span> ,_materialsList<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// the DAE is then added to the Papervision scene</span>
scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_shoeDae<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>NB: _loader is an instance of the Bulk Loader class. You can check out this library <a href="http://code.google.com/p/bulk-loader/">here</a>.</p>
<p><strong>Swapping textures at runtime.</strong></p>
<p>To swap the material at runtime which obviously happens often I made a setter function on the Shoe class.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> material<span style="color: #000000;">&#40;</span> material<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #009900;">// if the shoe material exists, dispose of the bitmap</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_shoeMaterial<span style="color: #000000;">&#41;</span> _shoeMaterial.bitmap.<span style="color: #004993;">dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">// make a new bitmap material</span>
	_shoeMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapMaterial<span style="color: #000000;">&#40;</span> material <span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">// replace the material using the name that we found in the Collada  file above</span>
	_shoeDae.replaceMaterialByName<span style="color: #000000;">&#40;</span> _shoeMaterial , <span style="color: #990000;">&quot;a_Backed_Shoe2SG);
}</span></pre></div></div>

<p>One of the trickiest challenges was turning the area of the shoe the user was editing into the BitmapData to pass to this function and use as the new material for the shoe.</p>
<p>In brief the recipe for this was:<br />
1.	Grab a copy of the current shoe material with everything the user has already created on it. This is a 1600&#215;1600 Bitmap.<br />
2.	Create a holder sprite to build the new image in. Add this current shoe material as the bottom layer.<br />
3.	Grab a copy of the original material, a clean canvas with nothing on it.<br />
4.	Mask the original material with the exact shape of the area the user is editing. This mask needs to be rotated, scaled and translated to the correct position on the original material. Layer this on top of the current shoe material.<br />
5.	So now the resulting image should show everything the user has added to the rest of the texture but the current area they are editing will be clear.<br />
6.	Grab the BitmapData from the area of the shoe the user is currently editing with all the graphics etc the user has added.<br />
7.	Again mask this so that graphics that go outside the editable area are not going to be included on the final image.<br />
8.	Layer this on top, rotating, scaling and translating as necessary with a Multiply blend mode so the stitching comes through from the original texture.<br />
9.	BitmapData.draw the resulting holder sprite with these layers on it and pass to the material function above to swap out the material.</p>
<p>Everything is easier to understand in pictures so here it is:<br />
<a title="Shoe Layering" rel="shadowbox" href="http://lab.publicreative.com/wp-content/uploads/2009/04/shoelayering.jpg"><img src="http://lab.publicreative.com/wp-content/uploads/2009/04/shoelayering-300x158.jpg" alt="" /></a></p>
<p><em><strong>Here is the original shoe material:</strong></em><br />
<a title="Original Texture" rel="shadowbox" href="http://lab.publicreative.com/wp-content/uploads/2009/04/texture_image_original1.jpg"><img src="http://lab.publicreative.com/wp-content/uploads/2009/04/texture_image_original1-300x300.jpg" alt="" /></a></p>
<p><em><strong>And here it is an example of what it looks like once edited:</strong></em><br />
<a title="Edited Texture&lt;/i&gt;" rel="shadowbox" href="http://lab.publicreative.com/wp-content/uploads/2009/04/texture_image_edited.jpg"><img src="http://lab.publicreative.com/wp-content/uploads/2009/04/texture_image_edited-300x300.jpg" alt="" /></a></p>
<p><strong>Preformance and Rendering</strong></p>
<p>Other things to consider were balancing performance with quality. We tried to keep the polygons on the shoe model as low as possible before it really became noticeable and keep the quality of the material image high.</p>
<p>When both the chains and the studs are added, as these are additional models the polygon count goes up considerably so we really tried hard to keep this as low as possible. When flash is asked to render anything over 3000 triangles, it really starts to show.</p>
<p>Additional to that we had problems with Z-Sorting due to the many overlapping parts of the shoe, especially around the laces. To solve this we needed to employ the services of the QuadrantRenderEngine with the Z sorting filter. However, as there are more calculations with every render, this slowed things down even more.</p>
<p>To use this advanced render engine, and keep the polygon count high while not affecting performance we made it so instead of constantly rendering, the Papervision scene was only updated when needed, i.e. when rotated or the texture has been changed.</p>
<p><strong>Saving the entries.</strong></p>
<p>A major part of this campaign is the competition. Every shoe designed and submitted needs to be saved for the gallery and judging.</p>
<p>To do this there are two main things that are needed. The main texture of the shoe, the 1600&#215;1600 jpg that holds the users design and the small thumbnail of the shoe with the design in place for use in the gallery.</p>
<p>The main texture of the shoe is always present in the current BitmapMaterial of the shoe. We just get it out using the BitmapMaterial.bitmap property.</p>
<p>Capturing the thumbnail is a little more involved. First we needed to rotate the shoe to the correct position so that all thumbnails are in the same position. Then we do a BitmapData.draw of the viewport after doing a bit of Matrix scaling and translating.</p>
<p>So we now have the two BitmapData objects for the two images, we just need to save them to the server along with the rest of the users entry details. To save the images we encode the images with Adobes JPGEncoder class (for the big texture) and the PNGEncoder (for the thumbnail). These are both available in the <a href="http://code.google.com/p/as3corelib/">corelib</a>.</p>
<p>Next we encode the resulting ByteArrays with the Base64 encoder. You can grab this from <a href="http://dynamicflash.com/goodies/base64/">Dynamic Flash</a>.</p>
<p>Code for saving the main image.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #009900;">// the bitmap data for the current shoe material</span>
<span style="color: #6699cc; font-weight: bold;">var</span> imageBd<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = Shoe2.getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.shoeMaterial.bitmap; imageBd = Shoe2.getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.shoeMaterial.bitmap;
<span style="color: #009900;">// the jpg encoder and the resulting ByteArray</span>
<span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000000; font-weight: bold;">:</span>JPGEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPGEncoder<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span>; 
<span style="color: #6699cc; font-weight: bold;">var</span> bytes<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = j.encode<span style="color: #000000;">&#40;</span> imageBd<span style="color: #000000;">&#41;</span>; bytes.<span style="color: #004993;">position</span> = 0; 
<span style="color: #009900;">// Encoding to Base64 and saving as part of the entry data object.</span>
entryData.texture_image = Base64.encodeByteArray<span style="color: #000000;">&#40;</span>bytes<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>The whole package containing the users entry data along with the Base64 encoded images are sent to our custom PHP backend in one tidy package via AMFPHP.</p>
<p>The obvious final step is PHP decoding the base64 images and saving them to disk storing the resultant URL with the rest of the entry data.</p>
<p><strong>Summary.</strong></p>
<p>As I warned at the start of this post, the above is only a very brief overview of how things were done. There was so much more to this than just the shoe but obviously this was the focus and main technical challenge of the site. Any feedback, questions or requests for further detail are obviously welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.publicreative.com/2009/04/inside-the-classic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>3dsMax Texture Baking and Papervision</title>
		<link>http://lab.publicreative.com/2009/01/3dsmax-texture-baking-and-papervision/</link>
		<comments>http://lab.publicreative.com/2009/01/3dsmax-texture-baking-and-papervision/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 19:01:32 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[3dsMax]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Papervision]]></category>

		<guid isPermaLink="false">http://lab.publicreative.com/?p=64</guid>
		<description><![CDATA[<script type="text/javascript" src="http://lab.publicreative.com/wp-includes/js/jquery/jquery.js"></script><script type="text/javascript" src="http://lab.publicreative.com/wp-content/plugins/pb-embedflash/js/sbadapter/shadowbox-jquery.js"></script><script type="text/javascript" src="http://lab.publicreative.com/wp-content/plugins/pb-embedflash/js/shadowbox.js"></script><script type="text/javascript"><!--
window.onload = function() {var options ={assetURL:'',loadingImage:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/css/images/loading.gif',flvPlayer:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf',animate:true,animSequence:'wh',overlayColor:'#000',overlayOpacity:0.9,overlayBgImage:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/css/images/overlay-85.png',listenOverlay:true,autoplayMovies:true,showMovieControls:true,resizeDuration:0.35,fadeDuration:0.35,displayNav:true,continuous:false,displayCounter:true,counterType:'default',viewportPadding:20,handleLgImages:'resize',initialHeight:160,initialWidth:320,enableKeys:true,keysClose:['c', 'q', 27],keysPrev:['p', 37],keysNext:['n', 39],handleUnsupported:'',text: {cancel:'Cancel',loading: 'loading',close:'<span class="shortcut">C</span>lose',next:'<span class="shortcut">N</span>ext',prev:'<span class="shortcut">P</span>revious',errors:{single: 'You must install the <a href="{0}">{1}</a> browser plugin to view this content.',shared: 'You must install both the <a href="{0}">{1}</a> and <a href="{2}">{3}</a> browser plugins to view this content.',either: 'You must install either the <a href="{0}">{1}</a> or the <a href="{2}">{3}</a> browser plugin to view this content.'}}};Shadowbox.init(options);}
--></script>3d is really exciting us at the moment. Papervision is great but so far we’ve only used primitive shapes within Papervision to do all our work. Chris, our newest arrival in the Public development pit has been amazing us with his 3dsMax skills and of course prompted us to get up with the play and [...]]]></description>
			<content:encoded><![CDATA[<p>3d is really exciting us at the moment. Papervision is great but so far we’ve only used primitive shapes within Papervision to do all our work. Chris, our newest arrival in the Public development pit has been amazing us with his 3dsMax skills and of course prompted us to get up with the play and start exporting from Max into flash.</p>
<p>It’s also prompted me, having no 3dsMax experience but plenty of Papervision experience to start having a play. After many hours at work and home coming up to speed with the basics of modelling, lightning and materials and learning how to texture bake and deal with UV maps I think I’ve got a handle on what this is all about.</p>
<p>Here’s the first test. Nothing amazing but the speakers are fully UVW unwrapped in 3dsMax and the textures are baked on.</p>
<p>Next up will be testing animation exported from 3dsMax and some more detailed modeling.</p>
<p><strong>Click image to open:</strong></p>
<p><small>(Please open the article to see the flash file or player.)</small></p>
<p><span id="more-64"></span><br />
<strong>Here is the source:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 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> com.publicreative.<span style="color: #004993;">graphics</span>.BackgroundGradient;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.publicreative.pv.interaction.MouseGrab;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.parsers.DAE;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.BitmapFileMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.ColorMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.utils.MaterialsList;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Cube;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.BasicView;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span> = <span style="color: #990000;">&quot;600&quot;</span>, <span style="color: #004993;">height</span> = <span style="color: #990000;">&quot;450&quot;</span>, <span style="color: #004993;">backgroundColor</span> = <span style="color: #990000;">&quot;#000000&quot;</span>, <span style="color: #004993;">frameRate</span> = <span style="color: #990000;">&quot;60&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> BakedStage extends BasicView
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;speakers.DAE&quot;</span>, mimeType = <span style="color: #990000;">&quot;application/octet-stream&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> SpeakerDAE<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>; 
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dae<span style="color: #000000; font-weight: bold;">:</span>DAE;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _stage<span style="color: #000000; font-weight: bold;">:</span>Cube;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _grab<span style="color: #000000; font-weight: bold;">:</span>MouseGrab;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> const DISTANCE<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1200</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BakedStage<span style="color: #000000;">&#40;</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: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span> , <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">addChildAt</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> BackgroundGradient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,0<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> byteArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> SpeakerDAE<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">ByteArray</span>;
&nbsp;
			 _dae = <span style="color: #0033ff; font-weight: bold;">new</span> DAE<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> ml<span style="color: #000000; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			ml.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;SpeakerImageMap.png&quot;</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;SpeakerImageMap.png&quot;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">//Speakers are texture baked round dae file.</span>
			_dae.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> byteArray , ml<span style="color: #000000;">&#41;</span>;
			_dae.<span style="color: #004993;">scale</span> = <span style="color: #000000; font-weight:bold;">3.5</span>;
			_dae.useOwnContainer = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_dae.rotationY = <span style="color: #000000; font-weight:bold;">180</span>;
			scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _dae <span style="color: #000000;">&#41;</span>; 
&nbsp;
			<span style="color: #009900;">//Stage is done in traditional way using a skinned cube.</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> stageML<span style="color: #000000; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;floorFront.jpg&quot;</span><span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;back&quot;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;floorSide.jpg&quot;</span><span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;floorSide.jpg&quot;</span><span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;floorTop.jpg&quot;</span><span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;top&quot;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span>0x111111<span style="color: #000000;">&#41;</span> , <span style="color: #990000;">&quot;bottom&quot;</span><span style="color: #000000;">&#41;</span>;
			stageML.addMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span>0x111111<span style="color: #000000;">&#41;</span>, <span style="color: #990000;">&quot;front&quot;</span><span style="color: #000000;">&#41;</span>;  
&nbsp;
			stageML.getMaterialByName<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;top&quot;</span><span style="color: #000000;">&#41;</span>.smooth = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			_stage = <span style="color: #0033ff; font-weight: bold;">new</span> Cube<span style="color: #000000;">&#40;</span> stageML , <span style="color: #000000; font-weight:bold;">484</span> , <span style="color: #000000; font-weight:bold;">484</span> , <span style="color: #000000; font-weight:bold;">16</span>, <span style="color: #000000; font-weight:bold;">4</span> , <span style="color: #000000; font-weight:bold;">1</span> , <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span>;
			_stage.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">8</span>;
			scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _stage <span style="color: #000000;">&#41;</span>;
&nbsp;
			camera.<span style="color: #004993;">zoom</span> = <span style="color: #000000; font-weight:bold;">100</span>;
			camera.z = <span style="color: #000000; font-weight: bold;">-</span>DISTANCE;
&nbsp;
			_grab = <span style="color: #0033ff; font-weight: bold;">new</span> MouseGrab<span style="color: #000000;">&#40;</span>  camera , <span style="color: #004993;">stage</span> <span style="color: #000000;">&#41;</span>;
			_grab.addSingleAxis<span style="color: #000000;">&#40;</span> MouseGrab.<span style="color: #004993;">VERTICAL</span> , MouseGrab.Y , <span style="color: #000000; font-weight:bold;">1000</span> , <span style="color: #000000; font-weight:bold;">10</span> , <span style="color: #000000; font-weight:bold;">30</span> <span style="color: #000000;">&#41;</span>;
			_grab.addDoubleAxis<span style="color: #000000;">&#40;</span> MouseGrab.<span style="color: #004993;">HORIZONTAL</span> , MouseGrab.XZ, DISTANCE, <span style="color: #000000; font-weight:bold;">1000</span>, <span style="color: #000000; font-weight:bold;">10</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			startRendering<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_grab.processFrame<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">super</span>.onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Here is the MouseGrab class as a few people have requested. It&#8217;s far from my best work and pretty much untested so use at your own risk. <a href='http://lab.publicreative.com/wp-content/uploads/2009/01/mousegrab.as'>MouseGrab</a>. Things have been very busy here of late so sorry for the slow replies.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.publicreative.com/2009/01/3dsmax-texture-baking-and-papervision/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>PV3D with AS3DMod and Shaders</title>
		<link>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/</link>
		<comments>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 19:45:40 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3DMod]]></category>
		<category><![CDATA[Papervision]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://lab.publicreative.com/?p=30</guid>
		<description><![CDATA[This was my first attempt at using the AS3DMod Library so you can see where the previously posted example came from.
I&#8217;ve also added gouraud shading to make it a little more interesting.
Click image to open:
(Please open the article to see the flash file or player.)

Here is the source:

package
&#123;
	import com.as3dmod.ModifierStack;
	import com.as3dmod.modifiers.Perlin;
	import com.as3dmod.plugins.pv3d.LibraryPv3d;
&#160;
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import [...]]]></description>
			<content:encoded><![CDATA[<p>This was my first attempt at using the <a href="http://code.google.com/p/as3dmod/">AS3DMod</a> Library so you can see where the previously posted example came from.</p>
<p>I&#8217;ve also added gouraud shading to make it a little more interesting.</p>
<p><strong>Click image to open:</strong></p>
<p><small>(Please open the article to see the flash file or player.)</small></p>
<p><span id="more-30"></span><br />
<strong>Here is the source:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 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> com.as3dmod.ModifierStack;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.modifiers.Perlin;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.plugins.pv3d.LibraryPv3d;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Loader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageAlign</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageQuality</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageScaleMode</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.lights.PointLight3D;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.BitmapMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.shaders.GouraudShader;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.shaders.ShadedMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Plane;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.BasicView;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;600&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;400&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#000000&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;31&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PublicFlag extends BasicView
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;assets/flagLogo.gif&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> Flag<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _plane<span style="color: #000000; font-weight: bold;">:</span>Plane;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _mod<span style="color: #000000; font-weight: bold;">:</span>ModifierStack;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _perlin<span style="color: #000000; font-weight: bold;">:</span>Perlin;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _xPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _yPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _targXPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _targYPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _light<span style="color: #000000; font-weight: bold;">:</span>PointLight3D;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PublicFlag<span style="color: #000000;">&#40;</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: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span>.<span style="color: #004993;">NO_SCALE</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span>.<span style="color: #004993;">TOP_LEFT</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">stageFocusRect</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			_light = <span style="color: #0033ff; font-weight: bold;">new</span> PointLight3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_light.z = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">100</span>;
			_light.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">100</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> logo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Flag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Bitmap</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> shader<span style="color: #000000; font-weight: bold;">:</span>GouraudShader = <span style="color: #0033ff; font-weight: bold;">new</span> GouraudShader<span style="color: #000000;">&#40;</span> _light , 0xffffff , 0x555555 , <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> mat<span style="color: #000000; font-weight: bold;">:</span>ShadedMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ShadedMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapMaterial<span style="color: #000000;">&#40;</span> logo.<span style="color: #004993;">bitmapData</span><span style="color: #000000;">&#41;</span> , shader<span style="color: #000000;">&#41;</span>;
			mat.doubleSided = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_plane = <span style="color: #0033ff; font-weight: bold;">new</span> Plane<span style="color: #000000;">&#40;</span> mat , logo.<span style="color: #004993;">width</span> , logo.<span style="color: #004993;">height</span> , <span style="color: #000000; font-weight:bold;">12</span>, <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span>;
			_plane.useOwnContainer = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			camera.fov=<span style="color: #000000; font-weight:bold;">34</span>;
			scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _plane <span style="color: #000000;">&#41;</span>;
&nbsp;
			modify<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			startRendering<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> modify<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			 _mod = <span style="color: #0033ff; font-weight: bold;">new</span> ModifierStack<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> LibraryPv3d<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> , _plane <span style="color: #000000;">&#41;</span>;
&nbsp;
			_perlin = <span style="color: #0033ff; font-weight: bold;">new</span> Perlin<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
			_perlin.setFalloff<span style="color: #000000;">&#40;</span> 0 , <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			_mod.addModifier<span style="color: #000000;">&#40;</span> _perlin <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
		 	_xPhaseVal = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
		 	_plane.rotationY <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">160</span><span style="color: #000000; font-weight: bold;">*</span>_xPhaseVal<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span>_plane.rotationY<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
		 	_yPhaseVal = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
		 	_plane.rotationX <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span> <span style="color: #000000; font-weight: bold;">*</span> _yPhaseVal<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> _plane.rotationX<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
			_mod.<span style="color: #004993;">apply</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">super</span>.onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PV3D Page Flip with AS3Dmod and Effects</title>
		<link>http://lab.publicreative.com/2009/01/pv3d-page-flip-with-as3dmod-and-effects/</link>
		<comments>http://lab.publicreative.com/2009/01/pv3d-page-flip-with-as3dmod-and-effects/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 17:52:58 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3DMod]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Papervision]]></category>

		<guid isPermaLink="false">http://lab.publicreative.com/?p=7</guid>
		<description><![CDATA[We’ve made sites using Papervision in the past, but I’ve had a bit of time to really get to know it a lot better. There has been so much functionality added lately it’s hard to keep up!
I’ve also really enjoyed playing with the AS3Dmod library by Bartek Drozdz and using BitmapEffectLayer’s
The following project started as [...]]]></description>
			<content:encoded><![CDATA[<p>We’ve made sites using Papervision in the past, but I’ve had a bit of time to really get to know it a lot better. There has been so much functionality added lately it’s hard to keep up!</p>
<p>I’ve also really enjoyed playing with the AS3Dmod library by <a href="http://www.everydayflash.com/">Bartek Drozdz</a> and using <a href="http://blog.zupko.info/?p=129">BitmapEffectLayer’s</a></p>
<p>The following project started as a simple idea for a gallery to showcase work that we have done but eventually evolved into more of a personal indulgence. Click anywhere to flip the page over.</p>
<p>To get the two sided Plane effect I’ve simply used a Cube that is 1px deep. The thing that frustrated me the most was trying to get the MovieMaterial holding the content of the image Loader instance to render the correct size. Initially I was creating the MovieMaterial’s at the same time I was initialising the Loaders but as there was no content in the loaders yet, the MovieMaterial rendered at its default size.</p>
<p>To fix this I initially assign a place holder Sprite that is the correct size to the MovieMaterial objects. Then when the Loader finishes loading the asset I switch the MovieMaterial that contains the Sprite for a new MovieMaterial that contains the image data from the Loader. This also means that the MovieMaterial does not have to be animated (updated on each render loop) improving performance.</p>
<p>It took me a long time find the method to replace materials, but it should have been pretty obvious.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;">_cube.replaceMaterialByName<span style="color: #000000;">&#40;</span> <span style="color: #3f5fbf;">/* new material */</span> , <span style="color: #3f5fbf;">/* material name */</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><strong>Click image to open: Click again to flip:</strong></p>
<p><small>(Please open the article to see the flash file or player.)</small></p>
<p>Also thanks to Zack Jordan for sharing his <a href="http://pixelwelders.com/blog/best-practices/2008/flashflex-integration-swflibrary-v15/">SWFLibrary</a> class.</p>
<p><span id="more-7"></span></p>
<p><strong>Here is the source:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 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> com.as3dmod.ModifierStack;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.modifiers.Bend;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.modifiers.Perlin;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.plugins.pv3d.LibraryPv3d;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.util.ModConstant;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.util.Phase;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.pixelwelders.util.SWFLibrary;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.publicreative.utils.MathUtils;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BlendMode</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Loader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageAlign</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageQuality</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageScaleMode</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span>.<span style="color: #004993;">BlurFilter</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLLoader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLRequest</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> gs.TweenLite;
	<span style="color: #0033ff; font-weight: bold;">import</span> gs.easing.<span style="color: #000000; font-weight: bold;">*</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.effects.BitmapLayerEffect;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.ColorMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.MovieMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.utils.MaterialsList;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Cube;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Plane;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.BasicView;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.layer.BitmapEffectLayer;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;560&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;295&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;31&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>	
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PVModBedHeader extends BasicView
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _plane<span style="color: #000000; font-weight: bold;">:</span>Plane;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _mod<span style="color: #000000; font-weight: bold;">:</span>ModifierStack;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _bend<span style="color: #000000; font-weight: bold;">:</span>Bend;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _planeMouseX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _planeMouseY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _tweenX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _tweenY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>= 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _perlin<span style="color: #000000; font-weight: bold;">:</span>Perlin;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _phase<span style="color: #000000; font-weight: bold;">:</span>Phase;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _tweenObj<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _tweenObj2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _tweenObj3<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _flipping<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _modified<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _effects<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _firstFlip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _imageLoader1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _imageLoader2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _cube<span style="color: #000000; font-weight: bold;">:</span>Cube;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _data<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _lib<span style="color: #000000; font-weight: bold;">:</span>SWFLibrary;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dataIndex<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = 0;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _header<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _body<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _link<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _bendStrength<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0.4</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _side<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = 0;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _bitmapEffectLayer<span style="color: #000000; font-weight: bold;">:</span>BitmapEffectLayer;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _blur<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BlurFilter</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> const BASE_DIR<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;http://lab.publicreative.com/uploads/modBendHeader/&quot;</span>;
&nbsp;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PVModBedHeader<span style="color: #000000;">&#40;</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: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">quality</span> = <span style="color: #004993;">StageQuality</span>.<span style="color: #004993;">MEDIUM</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span>.<span style="color: #004993;">NO_SCALE</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span>.<span style="color: #004993;">TOP_LEFT</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> xmlLoader<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			xmlLoader.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span> , onData , <span style="color: #0033ff; font-weight: bold;">false</span> , 0 , <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			xmlLoader.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span> BASE_DIR<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;xml/assets.xml&quot;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Once the image data has loaded start rendering and add effects
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onData<span style="color: #000000;">&#40;</span>ev<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_data = <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span>ev.<span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_lib = <span style="color: #0033ff; font-weight: bold;">new</span> SWFLibrary<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_lib.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span> , onLibComplete , <span style="color: #0033ff; font-weight: bold;">false</span> , 0 , <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			_lib.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> BASE_DIR<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;assets.swf&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			renderInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Setup papervision and materials and start rendering
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> renderInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span> , onFlip , <span style="color: #0033ff; font-weight: bold;">false</span> , 0 , <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// LOADERS.. one for each side of the plane</span>
			_imageLoader1 = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_imageLoader1.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span> , onLoad1Complete , <span style="color: #0033ff; font-weight: bold;">false</span> , 0 , <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			_imageLoader1.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span> BASE_DIR<span style="color: #000000; font-weight: bold;">+</span>_data.image<span style="color: #000000;">&#91;</span>_dataIndex<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_imageLoader2 = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_imageLoader2.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span> , onLoad2Complete , <span style="color: #0033ff; font-weight: bold;">false</span> , 0 , <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			_imageLoader2.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span>BASE_DIR<span style="color: #000000; font-weight: bold;">+</span> _data.image<span style="color: #000000;">&#91;</span>_dataIndex<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// PUT IN A PLACEHOLDER SPRITE TO FORCE THE RIGHT SIZE FOR THE LOADED IMAGES!</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> sprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			sprite.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xffffff<span style="color: #000000;">&#41;</span>;
			sprite.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span>0,0,<span style="color: #000000; font-weight:bold;">454</span>,<span style="color: #000000; font-weight:bold;">294</span><span style="color: #000000;">&#41;</span>;
			sprite.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> mt1<span style="color: #000000; font-weight: bold;">:</span>MovieMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MovieMaterial<span style="color: #000000;">&#40;</span> sprite, <span style="color: #0033ff; font-weight: bold;">false</span> , <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> mt2<span style="color: #000000; font-weight: bold;">:</span>MovieMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MovieMaterial<span style="color: #000000;">&#40;</span> sprite, <span style="color: #0033ff; font-weight: bold;">false</span> , <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			mt1.smooth = <span style="color: #0033ff; font-weight: bold;">true</span>;
			mt2.smooth = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> emptyMat<span style="color: #000000; font-weight: bold;">:</span>ColorMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span> 0xffffff ,0<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// MATERIALS.. materials with loaders on two sides all other materials transparent color material</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> mats<span style="color: #000000; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> emptyMat, <span style="color: #990000;">&quot;bottom&quot;</span><span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> emptyMat , <span style="color: #990000;">&quot;top&quot;</span> <span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> emptyMat , <span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> emptyMat , <span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> mt2 , <span style="color: #990000;">&quot;front&quot;</span> <span style="color: #000000;">&#41;</span>;
			mats.addMaterial<span style="color: #000000;">&#40;</span> mt1 , <span style="color: #990000;">&quot;back&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// CUBE.. that appears as a plane with two sides</span>
			_cube = <span style="color: #0033ff; font-weight: bold;">new</span> Cube<span style="color: #000000;">&#40;</span> mats, <span style="color: #000000; font-weight:bold;">454</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">294</span>, <span style="color: #000000; font-weight:bold;">20</span>, <span style="color: #000000; font-weight:bold;">10</span>, <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
			_cube.useOwnContainer = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			<span style="color: #009900;">// CAMERA..</span>
			camera.fov = <span style="color: #000000; font-weight:bold;">40</span>;
			camera.<span style="color: #004993;">zoom</span> = <span style="color: #000000; font-weight:bold;">90</span>;
			scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _cube<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// USING OBJECTS TO STORE TWEEN VALUES..</span>
			_tweenObj = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_tweenObj2 = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_tweenObj2.flipValue = 0;
			_tweenObj3 = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_tweenObj3.bendValue = <span style="color: #000000; font-weight: bold;">-</span>_bendStrength;
&nbsp;
			modifyInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			effectsInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Add bitmap effects layer for blur when flipping
		 * The amount of blur is animated as the cube flips
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> effectsInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_effects = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_bitmapEffectLayer = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapEffectLayer<span style="color: #000000;">&#40;</span> viewport , <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span> , <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
			_bitmapEffectLayer.renderAbove = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			viewport.containerSprite.addLayer<span style="color: #000000;">&#40;</span> _bitmapEffectLayer <span style="color: #000000;">&#41;</span>; 
&nbsp;
			_bitmapEffectLayer.addDisplayObject3D<span style="color: #000000;">&#40;</span> _cube <span style="color: #000000;">&#41;</span>;
			_blur = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BlurFilter</span><span style="color: #000000;">&#40;</span>0,0<span style="color: #000000;">&#41;</span>;
			_blur.<span style="color: #004993;">quality</span> = <span style="color: #000000; font-weight:bold;">2</span>;
			_bitmapEffectLayer.addEffect<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapLayerEffect<span style="color: #000000;">&#40;</span> _blur <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_bitmapEffectLayer.clearBeforeRender = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_bitmapEffectLayer.drawLayer.<span style="color: #004993;">blendMode</span> = <span style="color: #004993;">BlendMode</span>.<span style="color: #004993;">ADD</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * ADD the background from the assets.swf
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onLibComplete<span style="color: #000000;">&#40;</span>ev<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">background</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = _lib.getSprite<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Background&quot;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChildAt</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">background</span> , 0 <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 *  APPLY BEND AND PERLIN MODIFICATIONS
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> modifyInit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_modified = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			_mod = <span style="color: #0033ff; font-weight: bold;">new</span> ModifierStack<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> LibraryPv3d<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> , _cube <span style="color: #000000;">&#41;</span>;
&nbsp;
			_bend = <span style="color: #0033ff; font-weight: bold;">new</span> Bend<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight: bold;">-</span>_bendStrength<span style="color: #000000;">&#41;</span>;
			_bend.constraint = ModConstant.<span style="color: #004993;">NONE</span>;
&nbsp;
			_tweenX = <span style="color: #000000; font-weight:bold;">0.5</span>;
			_tweenY = 0;
&nbsp;
			_perlin = <span style="color: #0033ff; font-weight: bold;">new</span> Perlin<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0.5</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			_mod.addModifier<span style="color: #000000;">&#40;</span> _perlin <span style="color: #000000;">&#41;</span>;  
			_mod.addModifier<span style="color: #000000;">&#40;</span> _bend <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * AS MATERIALS are only placeholder sprites
		 * we must swap them out for the correct moviematerial containing the image loaders
		 * we can also unload the image once the loader is written to the movie material
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onLoad1Complete<span style="color: #000000;">&#40;</span>ev<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> mt1<span style="color: #000000; font-weight: bold;">:</span>MovieMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MovieMaterial<span style="color: #000000;">&#40;</span> _imageLoader1 , <span style="color: #0033ff; font-weight: bold;">false</span> , <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
			mt1.smooth = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_cube.replaceMaterialByName<span style="color: #000000;">&#40;</span> mt1 , <span style="color: #990000;">&quot;back&quot;</span> <span style="color: #000000;">&#41;</span>;
			mt1 = <span style="color: #0033ff; font-weight: bold;">null</span>;
			_imageLoader1.<span style="color: #004993;">unload</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_firstFlip<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				TweenLite.from<span style="color: #000000;">&#40;</span> _cube,<span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000;">&#123;</span>z<span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">8000</span> , ease<span style="color: #000000; font-weight: bold;">:</span>Expo.easeOut <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
				startRendering<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onLoad2Complete<span style="color: #000000;">&#40;</span>ev<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> mt2<span style="color: #000000; font-weight: bold;">:</span>MovieMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MovieMaterial<span style="color: #000000;">&#40;</span> _imageLoader2 , <span style="color: #0033ff; font-weight: bold;">false</span> , <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
			mt2.smooth = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_cube.replaceMaterialByName<span style="color: #000000;">&#40;</span> mt2 , <span style="color: #990000;">&quot;front&quot;</span> <span style="color: #000000;">&#41;</span>;
			mt2 = <span style="color: #0033ff; font-weight: bold;">null</span>;
			_imageLoader2.<span style="color: #004993;">unload</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/** 
		 * If the cube isn't flipping already.. flip it!
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onFlip<span style="color: #000000;">&#40;</span>ev<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>_flipping<span style="color: #000000;">&#41;</span> flip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Tween the tween values and make it flip!
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> flip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_flipping = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_firstFlip = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			_tweenObj.tweenValue = 0;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> flipTo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = _tweenObj2.flipValue <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> bendTo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>_tweenObj3.bendValue <span style="color: #000000; font-weight: bold;">&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #000000; font-weight:bold;">3</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">3</span>;
&nbsp;
			TweenLite.to<span style="color: #000000;">&#40;</span> _tweenObj ,<span style="color: #000000; font-weight:bold;">1.5</span> , <span style="color: #000000;">&#123;</span> tween<span style="color: #000000; font-weight: bold;">:</span>Quad.easeIn , tweenValue<span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span>, onComplete<span style="color: #000000; font-weight: bold;">:</span>flipOut <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
			TweenLite.to<span style="color: #000000;">&#40;</span> _tweenObj2 , <span style="color: #000000; font-weight:bold;">3</span> , <span style="color: #000000;">&#123;</span> tween<span style="color: #000000; font-weight: bold;">:</span>Sine.easeInOut , flipValue<span style="color: #000000; font-weight: bold;">:</span>flipTo  <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
			TweenLite.to<span style="color: #000000;">&#40;</span> _tweenObj3 , <span style="color: #000000; font-weight:bold;">1.5</span> , <span style="color: #000000;">&#123;</span> tween<span style="color: #000000; font-weight: bold;">:</span>Quad.easeIn , bendValue<span style="color: #000000; font-weight: bold;">:</span>bendTo <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_side = _tweenObj2.flipValue<span style="color: #000000; font-weight: bold;">%</span>2;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Half way through the flip
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> flipOut<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bendTo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>_tweenObj3.bendValue <span style="color: #000000; font-weight: bold;">&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #000000; font-weight: bold;">-</span>_bendStrength <span style="color: #000000; font-weight: bold;">:</span> _bendStrength;
&nbsp;
			TweenLite.to<span style="color: #000000;">&#40;</span> _tweenObj ,<span style="color: #000000; font-weight:bold;">1.5</span> , <span style="color: #000000;">&#123;</span> tween<span style="color: #000000; font-weight: bold;">:</span>Quad.easeOut, tweenValue<span style="color: #000000; font-weight: bold;">:</span>0 , onComplete<span style="color: #000000; font-weight: bold;">:</span>flipComplete <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
			TweenLite.to<span style="color: #000000;">&#40;</span> _tweenObj3 , <span style="color: #000000; font-weight:bold;">1.5</span> , <span style="color: #000000;">&#123;</span> tween<span style="color: #000000; font-weight: bold;">:</span>Quad.easeIn , bendValue<span style="color: #000000; font-weight: bold;">:</span>bendTo <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_dataIndex<span style="color: #000000; font-weight: bold;">++</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_dataIndex<span style="color: #000000; font-weight: bold;">&gt;</span>_data.image.<span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> _dataIndex =0;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Finish the flip and load the next image on the reverse side
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> flipComplete<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_flipping = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> targetLoader<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #000000;">&#40;</span>_side<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> _imageLoader2 <span style="color: #000000; font-weight: bold;">:</span> _imageLoader1;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> ind<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = _dataIndex<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>ind <span style="color: #000000; font-weight: bold;">&gt;</span> _data.image.<span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> ind = 0;
			targetLoader.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span> BASE_DIR<span style="color: #000000; font-weight: bold;">+</span> _data.image<span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Render the 3D scene every frame
		 */</span>
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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;">super</span>.onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_modified <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				_planeMouseX = <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span> ;
				_planeMouseY = <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_planeMouseX <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> _planeMouseX = <span style="color: #000000; font-weight:bold;">0.99</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_planeMouseX <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> _planeMouseX = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.99</span>;
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_flipping<span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					_cube.rotationY = <span style="color: #000000; font-weight:bold;">180</span><span style="color: #000000; font-weight: bold;">*</span>_tweenObj2.flipValue;
					_planeMouseX <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000; font-weight: bold;">-</span> _tweenObj.tweenValue<span style="color: #000000;">&#41;</span>;
					_bend.force=  _tweenObj3.bendValue;
					camera.<span style="color: #004993;">zoom</span> = <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>_tweenObj.tweenValue <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_effects<span style="color: #000000;">&#41;</span> _blur.<span style="color: #004993;">blurX</span> = _blur.<span style="color: #004993;">blurY</span> = _tweenObj.tweenValue<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">10</span>;
				<span style="color: #000000;">&#125;</span>
&nbsp;
				_tweenX <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> _planeMouseX <span style="color: #000000; font-weight: bold;">-</span> _tweenX <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>;
				_tweenY <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> _planeMouseY <span style="color: #000000; font-weight: bold;">-</span> _tweenY <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
				_bend.<span style="color: #004993;">offset</span> = <span style="color: #000000; font-weight:bold;">0.5</span> <span style="color: #000000; font-weight: bold;">+</span> _tweenX;
&nbsp;
				_bend.<span style="color: #004993;">angle</span> = MathUtils.toRadians<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">90</span> <span style="color: #000000; font-weight: bold;">*</span> _tweenY <span style="color: #000000;">&#41;</span>;
&nbsp;
				_mod.<span style="color: #004993;">apply</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://lab.publicreative.com/2009/01/pv3d-page-flip-with-as3dmod-and-effects/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

