<?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>webr3.org &#187; 3D computer graphics</title>
	<atom:link href="http://webr3.org/blog/tag/3d-computer-graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://webr3.org/blog</link>
	<description>brain&#039;s on fire!</description>
	<lastBuildDate>Tue, 19 Jul 2011 15:38:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Sound.extract to create visualizations.</title>
		<link>http://webr3.org/blog/haxe/using-sound-extract-to-create-visualizations/</link>
		<comments>http://webr3.org/blog/haxe/using-sound-extract-to-create-visualizations/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 20:19:35 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[Computer memory]]></category>
		<category><![CDATA[Data buffer]]></category>
		<category><![CDATA[Frame rate]]></category>
		<category><![CDATA[Sampling]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=101</guid>
		<description><![CDATA[
Technically, this is a really stupid thing to do, and move over it isn't the cleverest thing to do, regardless though I've done it just for the hell of it.
The aim of this post is to prevent anybody else from making the same stupid mistakes! end product isn't too bad though.
To give a quick over [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://webr3.org/experiments/sound/sound-extract-visualize/"><img class="alignnone size-full wp-image-102" title="sound" src="http://webr3.org/blog/wp-content/uploads/2009/07/sound.jpg" alt="sound" width="600" height="250" /></a></p>
<p>Technically, this is a really stupid thing to do, and move over it isn't the cleverest thing to do, regardless though I've done it just for the hell of it.</p>
<p>The aim of this post is to prevent anybody else from making the same stupid mistakes! end product isn't too bad though.</p>
<p>To give a quick over view, Sound.extract() gives access to raw sound data, as a ByteArray of floats; typically you setup two sound objects, the first loads the sound data from source, the second requests sound data from the first at regular intervals, extracting 2048-8192 samples per request and then playing it - idea is that in the method that requests the samples you can quickly pre-process it before its played and make some nice effects.</p>
<p>So my illogical train of thought was to visualize the raw sound data in real time as it plays to create some nice effects.</p>
<h3>The Numbers Game</h3>
<p>Music in flash is sampled at 44100 Hz Stereo - 44100 samples per second,  per channel - we're getting it at intervals of either 2048, 4096 or 8192 samples - meaning our visualization can run at either 21.53fps,  10.76fps or 5.45fps - which lets be honest is hardly going to make a nice smooth effect is it.</p>
<p>So our only option is to somehow synchronize the "timeline" (the screen updating) with the raw sound being played.</p>
<h3>The Approach</h3>
<p>I decided the only real way to do this was to make a continual buffer of sound that could be read independently by both the SampleDataEvent and by my own code to do the visualizations - after some playing around with numbers I finally gathered that if one was to run at a framerate of 63fps and render the 700 samples per channel at a time then I'd be consuming (63*700 = 41000 Hz / samples per second) = the data in realtime.</p>
<p>To make this possible I needed some kind of fast buffer to store the data in, obvious choice was fast memory which is a ByteArray and can be read and written to directly.</p>
<p>More number came in to play when the size of the buffer needed calculated, had to be a multiple of both the render speed (700) and the data feed rate (2048); which is a buffer of 358400 samples, or sample requests. (358400/175 = 2048).</p>
<p>To get the data in to the buffer I was finding the next offset at which i should write the data to my buffer, sound.extract'ing the data in to the buffer and using a modulo to create wrap around so after 175 samples data was written back at the start.</p>
<p>This covers getting the sound in to a fast memory buffer without consuming too many resources, next up to get it out and render it!</p>
<h3>The Rendering</h3>
<p>Rendering uses the same idea of requesting samples from the buffer, however this time the magic number is (358400/700 =) 512.</p>
<p>I implemented a simple framecounter that increments each frame and resets to 0 every 512 frames (giving the loop on the buffer), then quickly read 700 pairs of samples from the buffer each frame.</p>
<p>The left channel float value is then scaled by 300 used as an X position, whilst the right channel creates the Y position - both x and y are then fed to setPixel() on BitmapData whilst a simple calculation of 0xFFFFFF*leftChannel / 2 sets the color value.</p>
<p>Each frame the 700 dual channel samples are rendered creating 700 realtime 2D particles (hopefully) in time with the sound, and a simple blur filter is used to clear the previous frame in a nicer way.</p>
<h3>The Point</h3>
<p>It's all stupid, pointless and just stick to computeSpectrum - you only get 256 samples rather than 700 but it's perfectly in time and allows you do something other than exactly 63 fps; further it'll always be in time with the music.</p>
<h3>The Result</h3>
<p>Well, it's here - I've got it tuned in to my other halfs <a href="http://citybeatradio.org/" target="_blank">radio station citybeat radio</a> at the minute (which i wholeheartedly recommend for any electronic / trance music fans) and well.. <a href="http://webr3.org/experiments/sound/sound-extract-visualize/">here it is with source</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/using-sound-extract-to-create-visualizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PixelBender is more useful than I assumed!</title>
		<link>http://webr3.org/blog/general/pixelbender-is-more-useful-than-i-assumed/</link>
		<comments>http://webr3.org/blog/general/pixelbender-is-more-useful-than-i-assumed/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 11:18:25 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[PixelBender]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[Abstract algebra]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Computer graphics]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[image processing algorithms]]></category>
		<category><![CDATA[Linear algebra]]></category>
		<category><![CDATA[Perlin Noise]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=94</guid>
		<description><![CDATA[All too often it's too easy to overlook a technology, or indeed its uses, by mentaly boxing it in to the role it's advertised to fill.
PixelBender is one of these technologies, as advertised "You can use the Pixel Bender kernel language to implement image processing algorithms (filters or effects) in a hardware-independent manner"; however this [...]]]></description>
			<content:encoded><![CDATA[<p>All too often it's too easy to overlook a technology, or indeed its uses, by mentaly boxing it in to the role it's advertised to fill.</p>
<p>PixelBender is one of these technologies, as advertised "You can use the Pixel Bender kernel language to implement image processing algorithms (filters or effects) in a hardware-independent manner"; however this isn't the whole truth of the matter.</p>
<p>PixelBender is a highly under-rated and under-used technology imho. Simply put PixelBender is actually a very fast way of converting or manipulating large sets of numerical data, whether it's image based or not. In this post I'm only going to skim the surface and give some pointers.</p>
<p>The standard input types cover Vector, ByteArray and BitmapData, likewise with output data, additionally many types are supported for parameters, everything from ints up to 4x4 Matrix' of floats.</p>
<p>Some obvious and simple uses include:</p>
<ul>
<li>3D Data Manipulation (Float3 input and output - rgb or xyz)</li>
<li>Raw Sound Data Manipulation (from Sound.extract, you could even build an FFT implementation in PixelBender)</li>
<li>Visual Effects Calculations</li>
<li>Batch Processing and Data Transformation.</li>
</ul>
<p>Starting with Batch Processing and Data Transformation, here is the simplest PixelBender usage and example you could ever get.</p>
<h3>Problem</h3>
<p>Turn a BitmapData in to a Vector of RGB float values where each value is float &lt; 1 and each set of 3 values comprises a pixel.</p>
<p>Doing this with pure AS3 or haXe or anything else is quite intensive, then you add PixelBender in to the equation</p>
<p><strong>Solution</strong><br />
PixelBender Code:</p>
<pre>&lt;languageVersion : 1.0;&gt;
kernel Identity
&lt;   namespace : "org.webr3.pb";
 vendor : "WebR3";
 version : 1;
 description : "Converts BitmapData to Vector Number (rgb)";
&gt;
{
 input image3 src;
 output pixel3 dst;

 void evaluatePixel()
 {
 dst = sampleNearest( src, outCoord() );
 }
}</pre>
<p>And to use this we can create a simple wrapper class in AS3:</p>
<pre>package test
{
 import __AS3__.vec.Vector;

 import flash.display.BitmapData;
 import flash.display.Shader;
 import flash.display.ShaderJob;
 import flash.utils.ByteArray;

 public class ShaderVector
 {
 [Embed("/rgb.pbj", mimeType="application/octet-stream")]
 private var shaderClass : Class;

 private var shader : Shader;

 public function ShaderVector()
 {        
 shader = new Shader(new shaderClass() as ByteArray);
 }

 public function convert( img : BitmapData ) : Vector.&lt;Number&gt;
 {
 var output : Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;( (img.width*img.height) * 3 , false );
 shader.data.src.input = img;
 var job : ShaderJob = new ShaderJob( shader , output , img.width , img.height );
 job.start( true );
 output.fixed = true;
 return output;
 }

 }
}</pre>
<p>Now we've got a kind of worker / utility class which we can farm all the hard work on to; usage is simple:</p>
<pre>var worker : ShaderVector = new ShaderVector();
var rgb : Vector.&lt;Number&gt; = worker.convert( someBitmapData );</pre>
<p>that's it, in one line we've solved the problem.</p>
<p>PixelBender is a lot easier than you may think, the above code is a small model you can easily manipulate just embed different pixel bender files.</p>
<p>Here's another simple kernel file; this one will take a BitmapData of perlin noise and convert it in to Vector of 3D positions for us to use.</p>
<p>It takes the bitmap data, converts every pixels r,g,b values in to float -0.5 to +0.5 values, then scales them up and finally returns back a vector of what are essentially 3D Perlin Noise Particles (like the ones in my <a href="http://webr3.org/blog/haxe/3d-perlin-particle-light-cloud-and-source-haxe-flash-10/">earlier experiments</a>)</p>
<pre>&lt;languageVersion : 1.0;&gt;
kernel Scaler
&lt;   namespace : "org.webr3.pb";
 vendor : "WebR3";
 version : 1;
 description : "For Perlin Noise, Converts BitmapData to 3D x,y,z positions";
&gt;
{
 input image3 src;
 output pixel3 dst;

 parameter float scaleX
 &lt;
 defaultValue : float(1.0);
 minValue     : float(0.1);
 maxValue     : float(100000.0);
 &gt;;

 parameter float scaleY
 &lt;
 defaultValue : float(1.0);
 minValue     : float(0.1);
 maxValue     : float(100000.0);
 &gt;;

 parameter float scaleZ
 &lt;
 defaultValue : float(1.0);
 minValue     : float(0.000001);
 maxValue     : float(100000.0);
 &gt;;

 void evaluatePixel()
 {
 dst = sampleNearest( src, outCoord() );
 dst -= 0.5;
 dst.r *= scaleX;
 dst.g *= scaleY;
 dst.b *= scaleZ;
 }
}</pre>
<p>and the modified shader vector, only 3 new lines to set up the scale values:</p>
<pre>package test
{
 import __AS3__.vec.Vector;

 import flash.display.BitmapData;
 import flash.display.Shader;
 import flash.display.ShaderJob;
 import flash.utils.ByteArray;

 public class ShaderVector
 {
 [Embed("/rgb.pbj", mimeType="application/octet-stream")]
 private var shaderClass : Class;

 private var shader : Shader;

 public function ShaderVector()
 {        
 shader = new Shader(new shaderClass() as ByteArray);
 shader.data.scaleX.value = [200];
 shader.data.scaleY.value = [200];
 shader.data.scaleZ.value = [200];
 }

 public function convert( img : BitmapData ) : Vector.&lt;Number&gt;
 {
 var output : Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;( (img.width*img.height) * 3 , false );
 shader.data.src.input = img;
 var job : ShaderJob = new ShaderJob( shader , output , img.width , img.height );
 job.start( true );
 output.fixed = true;
 return output;
 }

 }
}</pre>
<p>If you're thinking this is complex, it's honestly not - try coding this in pure AS3 and it'll be a lot of complex slow lines, been there and done that!</p>
<p>I'm going to leave the examples there for now, if your looking for a 3D example then <a href="http://bit.ly/JnQzA" target="_blank">check the PixelBender files in Ralphs 3D Particle example</a>.</p>
<h3>Conclusion.</h3>
<p>AS3 together with PixelBender, haXe and Alchemy is fast becoming an immense tech for us developers, have a play around you may be suprised by the results you can achieve by utilizing these techs.</p>
<p>Coming very soon I'll be posting some examples which show what can be done when you use PixelBender, Fast Memory, Vectors and haXe / AS3 together, but in unconventional ways. Until then I hope this is enough to get some more dev's playing with PixelBender.</p>
<p>peace ::</p>
<p><img class="alignnone size-full wp-image-96" title="pb" src="http://webr3.org/blog/wp-content/uploads/2009/07/pb.jpg" alt="pb" width="600" height="250" /></p>
<p>image is a still from <a href="http://www.apple.com/trailers/wb/iamlegendawakening/" target="_self">I am Legend : Awakening</a> a very well made 5 minute short animation.</p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/general/pixelbender-is-more-useful-than-i-assumed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Something about practical usage of flash.Memory in HaXe</title>
		<link>http://webr3.org/blog/haxe/something-about-practical-usage-of-flash-memory-in-haxe/</link>
		<comments>http://webr3.org/blog/haxe/something-about-practical-usage-of-flash-memory-in-haxe/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 17:17:18 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Arrays]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Data types]]></category>
		<category><![CDATA[Fast Memory]]></category>
		<category><![CDATA[flash player]]></category>
		<category><![CDATA[Integer]]></category>
		<category><![CDATA[Lookup table]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=79</guid>
		<description><![CDATA[It's dawned on me that I've completely negated to mention why the haXe implementation of flash.Memory (flash player 10's new opcodes / fastmemory support) is so good.
Other than the really obvious bit that its direct access to a block of ram/fast memory which works extremely quickly, there is one other small but vital detail that's [...]]]></description>
			<content:encoded><![CDATA[<p>It's dawned on me that I've completely negated to mention why the haXe implementation of flash.Memory (flash player 10's new opcodes / fastmemory support) is so good.</p>
<p>Other than the really obvious bit that its direct access to a block of ram/fast memory which works extremely quickly, there is one other small but vital detail that's haXe specific and makes a vast difference between alchemy and haxe.</p>
<h2>The Big Difference</h2>
<p>You can think of flash.Memory as a static ByteArray, thus it is accessible from <em>both</em> static class and instance methods.</p>
<p>Now, another feature which offers huge speed increases in haXe is inlining.</p>
<p>Spelling it out - You can only inline static private methods, flash.Memory is all static access. So stick all your data (or big chunks of it) in flash.Memory and then inline  most of your heavy number crunching class.</p>
<p><strong>All inlined, all using fast memory = very very quick swfs!</strong></p>
<h2>Ideas and Tricks</h2>
<p>First of all, get the thought of only being able to have one chunk or type of data in fast memory at a time, you can partition it up and load everything in there.</p>
<p>A common setup I use is to have the first 1024 bytes as fast storage for float, int, byte, uint variables, the next xxx-thousand bytes as raw bitmap data, then all the other data I may want - like a block of 500k x,y,z floats for 3d data, followed by a few lookup charts.</p>
<p>the first 1024 bytes as fast storage for float, int, byte, uint variables - <em>because</em> you can then access the most commonly used vars using small int offsets (0-255) - and since its a small int your using it avoids all stacks completely, the bytecode will only contain the opcode to get the value from fast memory followed by the offset actually in the bytecode - for anything 256 and over its going to hit the int stack to get the offset first (which is barely noticable, but you know every fraction counts)</p>
<p>the next xxx-thousand bytes as raw bitmap data - <em>because </em>you can then work on your bitmap data ultra fast and write it back to the BitmapData instance using setPixels; very fast indeed, faster than a fixed sized vector even.</p>
<p>then all the other data - this is partially obvious, what may not be is the use of lookup charts, but I'll cover that in a moment.</p>
<h3>Accessing..</h3>
<p>Remember flash.Memory differs from a byte array in that you have to add in the offset for each value you want to grab</p>
<ul>
<li>Byte = 1 Byte</li>
<li>Int = 4 Bytes</li>
<li>Float = 4 Bytes</li>
<li>Double = 8 Bytes</li>
</ul>
<p>To use flash.Memory with functions which require a ByteArray.. [ like BitmapData.getPixels() -  Sound.extract() ] .. you can access it directly from flash.system.ApplicationDomain.currentDomain.domainMemory for example:</p>
<pre>// set position to start of the data we need
flash.system.ApplicationDomain.currentDomain.domainMemory.position = SOME_OFFSET;
// use the fast memory
bitmapData.setPixels( bitmapData.rect , flash.system.ApplicationDomain.currentDomain.domainMemory );</pre>
<p><strong>note:</strong> don't be fooled though, you can't simply call the functions on the bytearray in currentDomain, although <em>it is the data</em> that is in fast memory, it does not use the opcodes, which are what speed it up!</p>
<p><strong>Lookup Charts</strong></p>
<p>Often you'll find yourself calling the same code over and over and over; perhaps without realising just how much; consider we make an animation which uses perlin noise to generate 2d or 3d data - like this example - the example reads about 40k uint values from perlin noise, then converts each pixel to individual r,g,b values, then turns it in to a float -1 to 1 using a simple calculation. Thing is.. that means the same calculation runs 3x40000 times per frame at 50 frames a second.. 6 million times a second!</p>
<p>In this scenario, there are only 256 possible inputs to the calculation and 256 results - so rather than working it out 6 million times we can load it all in to a lookup chart, stick the lookup chart in fast memory and then lookup values rather than calculating - often you can really speed things up by doing this. <a href="http://webr3.org/experiments/perlin-particles/light-cloud/PerlinParticleEffects.hx">Practical example with comments here</a>.</p>
<p>Hope this is of use to somebody and clears things up a bit; I use the methods often so you'll see them in the source of my experiments.</p>
<p><img class="alignnone size-full wp-image-80" title="nopic" src="http://webr3.org/blog/wp-content/uploads/2009/07/nopic.jpg" alt="nopic" width="600" height="250" /></p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/something-about-practical-usage-of-flash-memory-in-haxe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>3D Perlin Particle Light Cloud (and source) - haXe / Flash 10</title>
		<link>http://webr3.org/blog/haxe/3d-perlin-particle-light-cloud-and-source-haxe-flash-10/</link>
		<comments>http://webr3.org/blog/haxe/3d-perlin-particle-light-cloud-and-source-haxe-flash-10/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 17:19:47 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Perlin Noise]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[Environment]]></category>
		<category><![CDATA[Fractals]]></category>
		<category><![CDATA[Noise]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=47</guid>
		<description><![CDATA[
Been doing some more playing with Perlin Particles, this time going for more natural, and indeed more useful!
Full source and comments included with this one: 3D Perlin Particle Light Cloud
]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-51" title="perlincloud" src="http://webr3.org/blog/wp-content/uploads/2009/06/perlincloud1.jpg" alt="perlincloud" width="600" height="250" /></p>
<p>Been doing some more playing with Perlin Particles, this time going for more natural, and indeed more useful!</p>
<p>Full source and comments included with this one: <a href="http://webr3.org/experiments/perlin-particles/light-cloud/">3D Perlin Particle Light Cloud</a></p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/3d-perlin-particle-light-cloud-and-source-haxe-flash-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Mashed Up Spheres</title>
		<link>http://webr3.org/blog/haxe/more-mashed-up-spheres/</link>
		<comments>http://webr3.org/blog/haxe/more-mashed-up-spheres/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:28:57 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Sphere]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=38</guid>
		<description><![CDATA[
Doesn't need much of an introduction, after my previous post "Amazing what happens when you modify a Sphere"; I realised that I'd missed a few combinations, and as such thought it'd be a good idea to finish off the obvious combinations.. you know, to see what they looked like.
One of the best, and the one [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-39" title="morespheres" src="http://webr3.org/blog/wp-content/uploads/2009/06/morespheres.jpg" alt="morespheres" width="600" height="250" /></p>
<p>Doesn't need much of an introduction, after my previous post "Amazing what happens when you modify a Sphere"; I realised that I'd missed a few combinations, and as such thought it'd be a good idea to finish off the obvious combinations.. you know, to see what they looked like.</p>
<p>One of the best, and the one that makes the most sense formula wise is M16.. here's the formula for it</p>
<pre>x = Math.cos(a) * Math.cos(r);
y = Math.cos(a) * Math.sin(r);
z = Math.sin(a) * Math.sin(r);</pre>
<p>makes sense to me! anyway, on with the show - here are the rest:</p>
<ul>
<li><a href="/experiments/basic-3d-particles/mashed-up-8/">M8</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-9/">M9</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-10/">M10</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-11/">M11</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-12/">M12</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-13/">M13</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-14/">M14</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-15/">M15</a></li>
<li><a href="/experiments/basic-3d-particles/mashed-up-16/">M16</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/more-mashed-up-spheres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazing what happens when you modify a Sphere..</title>
		<link>http://webr3.org/blog/haxe/amazing-what-happens-when-you-modify-a-sphere/</link>
		<comments>http://webr3.org/blog/haxe/amazing-what-happens-when-you-modify-a-sphere/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 16:59:35 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[3D computer graphics]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=35</guid>
		<description><![CDATA[
Taking the 3d particle primatives a bit further (and adding color) I've found that some very nice and rather interesting models can be made when you simply change a sphere a little bit.
Normally I'd do these in order, but in this case I'd recommend you checkout M4 first to get a taste (it's certainly my [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-36" title="eyecandyspheres" src="http://webr3.org/blog/wp-content/uploads/2009/06/eyecandyspheres.jpg" alt="eyecandyspheres" width="600" height="250" /></p>
<p>Taking the 3d particle primatives a bit further (and adding color) I've found that some very nice and rather interesting models can be made when you simply change a sphere a little bit.</p>
<p>Normally I'd do these in order, but in this case I'd recommend you checkout <a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-4/">M4</a> first to get a taste (it's certainly my fav).</p>
<p>Before the list, a very brief description; here we have the code to generate a sphere:</p>
<p><code><br />
for( i in 0...PARTICLES ) {<br />
a = (PARTICLES/360)*i;<br />
r = (i/PARTICLES) * Math.PI;<br />
x = Math.cos(a) * Math.cos(r);<br />
y = Math.cos(a) * Math.sin(r);<br />
z = Math.sin(a);<br />
}<br />
</code></p>
<p>now all we are going to be doing is adding in some steps, or changing the odd cos/sin with cos/sin/tan - nothing complex.</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-1/">M1 Variation</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-2/">M2 Variation</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-3/">M3 Variation</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-4/">M4 Variation</a> (my fav)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-5/">M5 Variation</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-6/">M6 Variation</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/mashed-up-7/">M7 Variation<br />
</a></li>
</ul>
<p>Now.. M7 is a rather interesting one.. because it has two very interesting variations (imho) primarily the eye which produces a flat, yet 3d shaded circle..?</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/m7-strange-variation-the-eye/">M7 Strange Variation - The Eye</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/m7-strange-variation-the-feather/">M7 Strange Variation - The Feather</a></li>
</ul>
<p>In addition there are a few more which are created by simply stepping colors or values:</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-abstract-rainbow/">3D Abstract Rainbow</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/one-three-twentyfour/">One, Three, TwentyFour</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/three-six-twelve/">Three, Six, Twelve</a></li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/six-six-twelve/">Six, Six, Twelve</a></li>
</ul>
<p>again, thanks to <a href="http://haxe.org/">haXe</a> for allowing this - remember it's all just particles rendered in realtime.</p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/amazing-what-happens-when-you-modify-a-sphere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Particle Cubes and Spheres</title>
		<link>http://webr3.org/blog/haxe/particle-cubes-and-spheres/</link>
		<comments>http://webr3.org/blog/haxe/particle-cubes-and-spheres/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 16:11:44 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[haXe]]></category>
		<category><![CDATA[3D computer graphics]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Rendering]]></category>

		<guid isPermaLink="false">http://webr3.org/blog/?p=30</guid>
		<description><![CDATA[
Following earlier unpublished work, and my version of 300k particles in flash, I found that I've created a nice little setup for rendering the results of mathematical functions in flash; specifically rendering the results as 300k/500k particles - I'm kind of fascinated with particles and plotting functions, as are many others - my preference is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-31" title="primatives" src="http://webr3.org/blog/wp-content/uploads/2009/06/primatives.jpg" alt="primatives" width="600" height="250" /></p>
<p>Following earlier unpublished work, and <a href="http://webr3.org/blog/haxe/flash-10-massive-amounts-of-3d-particles-with-haxe/">my version of 300k particles</a> in flash, I found that I've created a nice little setup for rendering the results of mathematical functions in flash; specifically rendering the results as 300k/500k particles - I'm kind of fascinated with particles and plotting functions, as are many others - my preference is to work with strange attractors; however I thought I'd shoot right back to basics and see what can be made with primatives and modifications of.</p>
<p><strong>pre-warning, if you're looking for eye candy, forget it </strong>- these are simple practical examples and a bit boring, but useful if you need to know how</p>
<p>Starting with the simplest we have the <strong><a href="http://webr3.org/experiments/basic-3d-particles/random-particle-cube/">Particle Cube</a></strong> - 500k random particles plotted in 3d space within an invisible cube. Then I modified it a bit..</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/sine-modified-x-particle-cube/">Sine Modified Particle Cube</a> (it's all skewed)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/particle-cube-sine-variation/">Sine and Time Modified Particle Cube</a> (double cube with a flow of particles between)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/particle-cube-sin-cos-tan/">Sine, Tan and Cos Modified Particle Cube</a> (one function applied to each axis)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/particle-cube-sin-cos-tan-v1/">Alternative Flattened Sine, Tan, Cos Modified Particle Cube</a> (patchwork circular flattened cube!)</li>
</ul>
<p>Next up the <strong><a href="http://webr3.org/experiments/basic-3d-particles/3d-particle-sphere/">Particle Sphere</a></strong> - another 500k particles in 3d space, all random, and then some modified versions..</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-particle-spherical-circles/">Spherical Circles</a> (evenly distributed particles, creates a single line wrapped around a sphere)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-emphasized-particle-sphere/">Emphasized Particle Sphere</a> (double spaced to create a messy particle sphere - but more like particles)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-particle-half-sphere/">Half a Sphere</a> (go on, guess)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-white-bubble/">White Particle Bubble</a> (evenly distributed to create a kind of bubble effect)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/the-binlid-3d-particles/">Split Sections of a Sphere</a> (two opposing but differing chunks of sphere, again all particles, like a swing bin lid)</li>
</ul>
<p>And finally a couple of simple experiments..</p>
<ul>
<li><a href="http://webr3.org/experiments/basic-3d-particles/atan2-warped-random-plane/">Random Warped Particle Plane</a> (random x, random y, atan2(x,y) for z)</li>
<li><a href="http://webr3.org/experiments/basic-3d-particles/3d-beach-bubble/">Beach Bubble</a> (the white bubble with some colour, like a beach ball but translucent)</li>
</ul>
<p>In summary, it's good to see how easily different effects and primatives can be build, and even better to see how easily they can be modified with basic mathematical functions. (and how good <a href="http://haxe.org/">haXe</a> is :p)</p>
]]></content:encoded>
			<wfw:commentRss>http://webr3.org/blog/haxe/particle-cubes-and-spheres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

