<?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>pv3d.org &#187; snippets</title>
	<atom:link href="http://pv3d.org/category/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://pv3d.org</link>
	<description>Papervision3D, ActionScript, and Flex examples and tutorials by John Lindquist</description>
	<lastBuildDate>Tue, 25 May 2010 14:01:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Papervision3D in MXML</title>
		<link>http://pv3d.org/2009/03/18/papervision3d-in-mxml/</link>
		<comments>http://pv3d.org/2009/03/18/papervision3d-in-mxml/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 04:15:50 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[MXML]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=478</guid>
		<description><![CDATA[This falls under the &#8220;just because I can&#8221; category  
Just copy and paste this code into any Flex project with the Papervision3D.swc in the libs and you&#8217;re good to go!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;view:BasicView 
	xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; 
	xmlns:view=&#34;org.papervision3d.view.*&#34; 
	xmlns:scenes=&#34;org.papervision3d.scenes.*&#34; 
	xmlns:primitives=&#34;org.papervision3d.objects.primitives.*&#34; 
	xmlns:materials=&#34;org.papervision3d.materials.*&#34; 
	opaqueBackground=&#34;#ffffff&#34;
	added=&#34;startRendering();&#34;
	&#62;
	&#60;view:scene&#62;
		&#60;scenes:Scene3D&#62;
			&#60;scenes:objects&#62;
				&#60;primitives:Sphere x=&#34;300&#34;&#62;
					&#60;primitives:material&#62;
						&#60;materials:ColorMaterial fillColor=&#34;0xcc0000&#34;/&#62;
					&#60;/primitives:material&#62;
				&#60;/primitives:Sphere&#62;
			&#60;/scenes:objects&#62;
		&#60;/scenes:Scene3D&#62;
	&#60;/view:scene&#62;
&#60;/view:BasicView&#62;

]]></description>
		<wfw:commentRss>http://pv3d.org/2009/03/18/papervision3d-in-mxml/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Carousel with Forward Facing Planes</title>
		<link>http://pv3d.org/2009/02/16/carousel-with-forward-facing-planes/</link>
		<comments>http://pv3d.org/2009/02/16/carousel-with-forward-facing-planes/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 04:54:50 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=374</guid>
		<description><![CDATA[Yes, it&#8217;s another Carousel post, but people just seem to keep on asking for them.
Instead of going through all the trig, I just used the handy Casa Lib for the circle management. There are some other great utility classes with Casa, so make sure to check it out.

source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package &#123;
	import flash.events.Event;
	import flash.geom.Point;
&#160;
	import org.casalib.math.geom.Ellipse;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
&#160;
	&#91;SWF&#40;width=&#34;900&#34;, [...]]]></description>
		<wfw:commentRss>http://pv3d.org/2009/02/16/carousel-with-forward-facing-planes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Distance between two Number3Ds</title>
		<link>http://pv3d.org/2008/11/30/distance-between-two-number3ds/</link>
		<comments>http://pv3d.org/2008/11/30/distance-between-two-number3ds/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 14:59:13 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=136</guid>
		<description><![CDATA[
var n1:Number3D = new Number3D&#40;500, 0, 0&#41;;
var n2:Number3D = new Number3D&#40;0, 0, 500&#41;;
var distance:Number = Number3D.sub&#40;n1, n2&#41;.modulo;

]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/30/distance-between-two-number3ds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding a BasicView to a Flex UIComponent</title>
		<link>http://pv3d.org/2008/11/29/adding-a-basicview-to-a-flex-uicomponent/</link>
		<comments>http://pv3d.org/2008/11/29/adding-a-basicview-to-a-flex-uicomponent/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 06:33:12 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=126</guid>
		<description><![CDATA[While I would always encourage to separate your code into separate classes to follow best OOP practices, the example below will &#8220;get the job done&#8221;. 
Since the Flex framework is based off UIComponents and you can&#8217;t directly add Sprites (or BasicViews) to a UIComponent, you have to dig into the UIComponents rawChildren (meaning Sprites) to [...]]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/29/adding-a-basicview-to-a-flex-uicomponent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Distance to Mouse using a dummy 3d object</title>
		<link>http://pv3d.org/2008/11/29/distance-to-mouse-using-a-dummy-3d-object/</link>
		<comments>http://pv3d.org/2008/11/29/distance-to-mouse-using-a-dummy-3d-object/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 23:42:11 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mouse]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=116</guid>
		<description><![CDATA[
package
&#123;
	import flash.events.Event;
&#160;
	import org.papervision3d.core.math.Number3D;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
&#160;
	&#91;SWF&#40;width=&#34;640&#34;, height=&#34;480&#34;, backgroundColor=&#34;#000000&#34;, frameRate=&#34;60&#34;&#41;&#93;
	public class DistanceFrom3DMouse extends BasicView
	&#123;
		private var sphere:Sphere = new Sphere&#40;&#41;;
		private var mouseDO3D:DisplayObject3D = new Sphere&#40;&#41;;
&#160;
		public function DistanceFrom3DMouse &#40;&#41;
		&#123;
			sphere.x = -500;
			sphere.y = 200;
&#160;
//			scene.addChild(mouseDO3D); uncomment to see mouse sphere
			scene.addChild&#40;sphere&#41;;
&#160;
			startRendering&#40;&#41;;
		&#125;
&#160;
		override protected function onRenderTick&#40;event:Event=null&#41;:void
		&#123;
			var ray:Number3D = camera.unproject&#40;viewport.containerSprite.mouseX, viewport.containerSprite.mouseY&#41;;
			ray.normalize&#40;&#41;;
			ray.multiplyEq&#40;sphere.distanceTo&#40;camera&#41;&#41;;
			ray = Number3D.add&#40;ray, camera.position&#41;;
&#160;
			mouseDO3D.position = ray;
&#160;
			var distance:Number = sphere.distanceTo&#40;mouseDO3D&#41;;
&#160;
			renderer.renderScene&#40;scene, camera, viewport&#41;;
		&#125;
	&#125;
&#125;

I&#8217;m open to suggestions [...]]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/29/distance-to-mouse-using-a-dummy-3d-object/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Distance from Mouse using screen coordinates</title>
		<link>http://pv3d.org/2008/11/29/distance-from-mouse-using-screen-coordinates/</link>
		<comments>http://pv3d.org/2008/11/29/distance-from-mouse-using-screen-coordinates/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 21:16:46 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mouse]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=113</guid>
		<description><![CDATA[
package
&#123;
	import flash.events.Event;
&#160;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
&#160;
	&#91;SWF&#40;width=&#34;640&#34;, height=&#34;480&#34;, backgroundColor=&#34;#000000&#34;, frameRate=&#34;60&#34;&#41;&#93;
	public class DistanceFrom2DMouse extends BasicView
	&#123;
		private var sphere:Sphere = new Sphere&#40;&#41;;
&#160;
		public function DistanceFrom2DMouse&#40;&#41; 
		&#123;
			sphere.x = -500;
			sphere.y = -300;
&#160;
			sphere.autoCalcScreenCoords = true;
			scene.addChild&#40;sphere&#41;;	
&#160;
			startRendering&#40;&#41;;
		&#125;
&#160;
		override protected function onRenderTick&#40;event:Event=null&#41;:void
		&#123;
			var distanceX:Number = viewport.containerSprite.mouseX - sphere.screen.x;
			var distanceY:Number = viewport.containerSprite.mouseY - sphere.screen.y;
			var distance:Number = Math.sqrt&#40;distanceX * distanceX + distanceY * distanceY&#41;;
&#160;
			renderer.renderScene&#40;scene, camera, viewport&#41;;
		&#125;
	&#125;
&#125;

]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/29/distance-from-mouse-using-screen-coordinates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Glow Filter on a ViewportLayer</title>
		<link>http://pv3d.org/2008/11/26/glow-filter-on-a-viewportlayer/</link>
		<comments>http://pv3d.org/2008/11/26/glow-filter-on-a-viewportlayer/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 04:44:06 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[viewportLayer]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=105</guid>
		<description><![CDATA[
package
&#123;
	import flash.filters.GlowFilter;
&#160;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.layer.ViewportLayer;
&#160;
	&#91;SWF&#40;width=&#34;640&#34;, height=&#34;480&#34;, backgroundColor=&#34;#000000&#34;, frameRate=&#34;60&#34;&#41;&#93;
	public class GlowSnippet extends BasicView
	&#123;
&#160;
		public function GlowSnippet&#40;&#41;
		&#123;
			var material:ColorMaterial = new ColorMaterial&#40;0xcc0000&#41;;
			var sphere:Sphere = new Sphere&#40;material&#41;;
&#160;
			var viewportLayer:ViewportLayer = new ViewportLayer&#40;viewport, sphere&#41;;
			viewport.containerSprite.addLayer&#40;viewportLayer&#41;;
&#160;
			var glowFilter:GlowFilter = new GlowFilter&#40;0xcccc00, 1, 20, 20, 4, 3&#41;;
			viewportLayer.filters = &#91;glowFilter&#93;;
&#160;
			scene.addChild&#40;sphere&#41;;
&#160;
			singleRender&#40;&#41;;
		&#125;
	&#125;
&#125;

]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/26/glow-filter-on-a-viewportlayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Waiting for an image to load &#8211; BitmapFileMaterial</title>
		<link>http://pv3d.org/2008/11/21/waiting-for-a-image-to-load/</link>
		<comments>http://pv3d.org/2008/11/21/waiting-for-a-image-to-load/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 17:46:42 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[material]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=58</guid>
		<description><![CDATA[
package
&#123;
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
&#160;
	&#91;SWF&#40;width=&#34;640&#34;, height=&#34;480&#34;, backgroundColor=&#34;#000000&#34;, frameRate=&#34;60&#34;&#41;&#93;
	public class WaitForAnImageToLoad extends BasicView
	&#123;
&#160;
		public function WaitForAnImageToLoad&#40;&#41;
		&#123;
			var url:String = &#34;http://content.screencast.com/media/1676f247-e7f0-4035-a826-06e2d7885731_089125cc-8776-47ed-92d7-280330071c15_static_0_0_00000149.png&#34;;
			var bitmapFileMaterial:BitmapFileMaterial = new BitmapFileMaterial&#40;url&#41;;
			bitmapFileMaterial.addEventListener&#40;FileLoadEvent.LOAD_COMPLETE, loadCompleteHandler&#41;;
		&#125;
&#160;
		private function loadCompleteHandler&#40;event:FileLoadEvent&#41;:void
		&#123;
			var plane:Plane = new Plane&#40;BitmapFileMaterial&#40;event.target&#41;&#41;;
			scene.addChild&#40;plane&#41;;
			singleRender&#40;&#41;;
		&#125;
	&#125;
&#125;

]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/21/waiting-for-a-image-to-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Points along a displacement vector &#8211; Part 2</title>
		<link>http://pv3d.org/2008/11/18/points-along-a-displacement-vector-part-2/</link>
		<comments>http://pv3d.org/2008/11/18/points-along-a-displacement-vector-part-2/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 01:07:34 +0000</pubDate>
		<dc:creator>John Lindquist</dc:creator>
				<category><![CDATA[snippets]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://pv3d.org/?p=27</guid>
		<description><![CDATA[While the last example was supposed to be simple to read and understand, this shows how to do the same thing with much less code by using the built-in vector methods:

Number3D.add&#40;vectorA, vectorB&#41;; //adds two vectors
//which is much faster than writing
vector = vectorA.x + vectorB.x;
vector = vectorA.y + vectorB.y;
vector = vectorA.z + vectorB.z;
&#160;
Number3D.sub&#40;vectorA, vectorB&#41;; //subtracts two [...]]]></description>
		<wfw:commentRss>http://pv3d.org/2008/11/18/points-along-a-displacement-vector-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
