<?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>Chris Herring &#187; papervision</title>
	<atom:link href="http://blog.chrisherring.co.uk/tag/papervision/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chrisherring.co.uk</link>
	<description>Interaction, development and everything in between...</description>
	<lastBuildDate>Thu, 10 Mar 2011 09:34:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Placing Particles</title>
		<link>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:07:51 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[particles particles]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=481</guid>
		<description><![CDATA[Papervision is great but I sometimes feel that I would be a lot better off with a greater understanding of 3D Math. Therefore this post based upon an experiment I did a little while ago, with the aim of generating a sphere of particles and improving my 3D Math. The following picture is close to [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision </a>is great but I sometimes feel that I would be a lot better off with a greater understanding of 3D Math. Therefore this post based upon an experiment I did a little while ago, with the aim of generating a sphere of particles and improving my 3D Math.</p>
<p>The following picture is close to what I intended to achieve, however due to the very high number of particles with the sphere Papervision struggles render it. In this case switching to <a title="Flint Particle System" href="http://flintparticles.org/" target="_blank">Flint</a>, and using their 3D particle system would probably be a better idea. </p>
<p style="margin-left:15px;"><img class="center" title="Particle Globe" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/globe.gif" alt="" width="550" height="306" /></p>
<p>Time to get gritty! The block of code below creates a sphere of Particles. The for loops below increase in specified steps for latitude and longitude, unlike your normal for loop which counts from 0 to whatever in single increments this stepped process enables us to distribute the Particles at an even distance. The sine wave calculation Math.sin(lat*Math.PI/180) is important for placing the particles in a spherical shape. A positive sine wave multiplied by PI  divided by 180 creates us a semi-circle, combined with a negative <a title="Sine Wave" href="http://en.wikipedia.org/wiki/Sine_wave" target="_blank">sine wave</a> we get a full circle. With in the two for loops I&#8217;ve also added a random if statement so that Papervision doesn&#8217;t struggle to render a high number of Particles, but still keeps the shape of a high density particle sphere. It&#8217;s also worth noting that I&#8217;ve created a class which extends the Particle class in Paperivision called Dot,  to which I&#8217;m passing the calculated x y z values, these are then stored so that the Particles can be tweened from a random x y z to form a sphere. I&#8217;ve done this only for visual reasons!</p>
<p><code><br />
for (var lat:Number = -90; lat<90; lat+=(360/dens))<br />
{<br />
     var radius:Number = Math.cos(lat * Math.PI / 180) * size;<br />
     var circumference:Number = (2*Math.PI*radius);<br />
     var numberOfDots:Number = Math.floor(dens*circumference)/size;</p>
<p>     for (var long:Number = 0; long<360; long+=(360/numberOfDots))<br />
     {<br />
          if (Math.floor(Math.random()*8) == 1)<br />
          {<br />
               part =  new Dot(Math.cos(long*Math.PI/180)*radius,<br />
                                       Math.sin(lat*Math.PI/180)*size,<br />
                                       Math.sin(long*Math.PI/180)*radius );<br />
               this.particleArray.push(part);<br />
               this.particleHolder.addParticle(part);<br />
          }<br />
     }<br />
}<br />
</code><br />
Click below in order to activate the Flash movie.</p>
<p id="PlacingParticles" style="margin-left:15px;">The following is a no flash image</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s3 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/swf/PlacingParticles.swf','player','550','400','9'); s3.write('PlacingParticles');
// --></script></p>
<p>In end the outcome above is close to what I intended to achieve, however the density of the dots around the latitude axis is exactly the same at the poles as the equator. I've tried to resolve the density problem but without success, mainly due to Papervision struggling to render such a high density of Particles.  I'm realistically on the edge of Math skills and perhaps purchasing a 3D Math primer would be a good idea.  Anyway this was an interesting experiment which I got very close to getting it right.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>workspace.cleanup();</title>
		<link>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 11:08:14 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=394</guid>
		<description><![CDATA[My project workspace at home and at work is full of little experiments or mini projects which never get finished or tidied up, and consequently not seen. Therefore I&#8217;ve decided to do a little cleanup and post them up here in whatever state or standard they are. A couple of months ago I created a [...]]]></description>
			<content:encoded><![CDATA[<p>My project workspace at home and at work is full of little experiments or mini projects which never get finished or tidied up, and consequently not seen. Therefore I&#8217;ve decided to do a little cleanup and post them up here in whatever state or standard they are.</p>
<p>A couple of months ago I created a couple of classes to handle xml from Twitter for a potential flash feed thingy. The classes consisted of a model class which creates business objects like tweets and user, making the data easily mangaged/accessible within a project. Using these classes I&#8217;ve just added a bit of <a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision</a>, the text is displayed via the <a title="Text3D" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/typography/Text3D.html" target="_blank">Text3D</a> class which is really nice class if your project uses <a title="Helvetica" href="http://en.wikipedia.org/wiki/Helvetica" target="_blank">Helvetica</a> and some what devoid if it doesn&#8217;t.</p>
<p id="TwitterPV" style="margin-left:15px;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s3 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/experiments/twitter/swf/App.swf','player','550','200','9');
s3.addVariable("basePath", "http://blog.chrisherring.co.uk/wp-content/experiments/twitter/")
s3.write('TwitterPV');
// --></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Papervision: Mapping 2D in 3D</title>
		<link>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/</link>
		<comments>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 20:46:42 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=344</guid>
		<description><![CDATA[There are many ways to improve the performance of your Papervision application, and in my first blog post in a few months I&#8217;ll cover the technique of mapping a 2D sprite to an object in 3D Papervision. The main concept of this technique is two reduce the number of elements rendered in 3D to a [...]]]></description>
			<content:encoded><![CDATA[<p>There are many ways to improve the performance of your <a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision</a> application, and in my first blog post in a few months I&#8217;ll cover the technique of mapping a 2D sprite to an object in 3D Papervision. The main concept of this technique is two reduce the number of elements rendered in 3D to a minimum, naturally this is only applicable to certain situations. The yellow triangle below is a standard Sprite, and by clicking upon it will map the triangle to a red particle within the rotating sphere.</p>
<p id="Mapping2Din3D" style="margin-left:15px;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s2 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/swf/Mapping2Din3D.swf','player','550','400','9');
s2.write('Mapping2Din3D');
// --></script></p>
<p><span style="text-decoration: underline;">Step 1</span><br />
After setting up a basic Papervision environment with a sphere, the next thing to do is add a particle to the edge of the sphere. Within Papervision its not possible to just create a new <a title="Particle" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/core/geom/renderables/Particle.html" target="_blank">Particle</a>, and it add it the scene, instead the <a title="Particles" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/core/geom/Particles.html" target="_blank">Particle</a> must be added to an instantiation of the Particles class, which acts as holding container for a Particle. It is worth noting that thousands of individual Particles can be added to the Particles container and then added to the scene to be rendered.</p>
<p><code> var material = new ParticleMaterial(0xFF3333, 1);<br />
var particle = new Particle(material, 15);<br />
this.particles = new Particles();<br />
this.particles.x =-294.8020952990483;<br />
this.particles.z = -44.981004334405526;<br />
this.particles.y = 47.67005198611658;<br />
this.particles.addParticle(particle);<br />
this.sphere.addChild(this.particles);<br />
</code></p>
<p><span style="text-decoration: underline;">Step 2</span><br />
In order to map a 2D Sprite to a 3D object we need to calculate the 3D objects relative position in x and y to the screen. Luckily by adding the following line to the previous code block this functionally can be switched on. The method <a title="autoCalcScreenCoords" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/objects/DisplayObject3D.html#autoCalcScreenCoords" target="_blank">autoCalcScreenCoords</a><span> is </span>available to any class which extends <a title="DisplayObject3D" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/objects/DisplayObject3D.html" target="_blank">DisplayObject3D</a>, however user must be careful as extra calculations are made with the potential for a performance drop if used with out.</p>
<p><code> this.particles.autoCalcScreenCoords = true;<br />
</code></p>
<p><span style="text-decoration: underline;">Step 3</span><br />
The screen x and y are always calculated relative to the size of the viewport being used. I&#8217;ve added the following couple of lines of code, within the render EnterFrame only so that the 2D Sprite is always mapped to the 3D object but of course could exist elsewhere.</p>
<p><code> this.triangle.x = ( this.particles.screen.x ) + (this.viewport.width  / 2);<br />
this.triangle.y = ( this.particles.screen.y ) + (this.viewport.height / 2);</code></p>
<p>And that&#8217;s it, pretty basic stuff yet can still be very useful.</p>
<p><a href="http://blog.chrisherring.co.uk/wp-content/code/Mapping2Din3D.as">Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

