<?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>toxiclibs &#187; 3d</title>
	<atom:link href="http://toxiclibs.org/tag/3d/feed/" rel="self" type="application/rss+xml" />
	<link>http://toxiclibs.org</link>
	<description>Building blocks for computational design</description>
	<lastBuildDate>Tue, 20 Dec 2011 17:03:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>simutils-0001: Diffusion limited aggregation</title>
		<link>http://toxiclibs.org/2010/02/new-package-simutils/</link>
		<comments>http://toxiclibs.org/2010/02/new-package-simutils/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 11:44:16 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[simutils]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[diffusion]]></category>
		<category><![CDATA[dla]]></category>
		<category><![CDATA[generative]]></category>
		<category><![CDATA[octree]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[rulebased]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=190</guid>
		<description><![CDATA[A few days ago I published some updates to all five existing main packages and also bundled up some other classes from existing projects into a new package, called simutils. As the name indicates, these new classes deal with the simulation of some fairly basic processes inspired by nature, but each of them exhibits some [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I published some updates to all five existing main packages and also bundled up some other classes from existing projects into a new package, called <strong>simutils</strong>. As the name indicates, these new classes deal with the simulation of some fairly basic processes inspired by nature, but each of them exhibits some emergent behaviours which can be (and have been) used for a wide variety of design tasks from 3D printed sculptures to generative music. To help you get started, the package also contains two or three Processing demos for each process showing basic usage patterns. The three processes implemented so far are explained in more detail in this &amp; <a href="http://toxiclibs.org/2010/02/simutils-grayscott/">the next</a> few upcoming posts. Let&#8217;s start with&#8230;</p>
<p><img class="alignnone size-full wp-image-220" title="brownian_sunflow" src="http://toxiclibs.org/wp-content/uploads/2010/02/brownian_sunflow.jpg" alt="brownian motion" width="680" height="382" /></p>
<h2>Diffusion limited aggregation</h2>
<p><a href="http://en.wikipedia.org/wiki/Diffusion-limited_aggregation" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Diffusion-limited_aggregation?referer=');">Diffusion limited aggregation</a>, DLA in short, is a theoretical process describing the clustering of particles through a process of diffusion, like a random walk/<a href="http://en.wikipedia.org/wiki/Brownian_motion" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Brownian_motion?referer=');">Brownian motion</a>. Inspired by the work of <a href="http://www.andylomas.com" onclick="pageTracker._trackPageview('/outgoing/www.andylomas.com?referer=');">Andy Lomas</a> with this process, in 2006 I set out to implement DLA myself from scratch, in order to apply it to structures and literally grow objects not made out of triangles/polygons. At the same time I&#8217;d also just discovered the possibilities of <a href="http://toxi.co.uk/blog/2006_12_01_archive.htm" onclick="pageTracker._trackPageview('/outgoing/toxi.co.uk/blog/2006_12_01_archive.htm?referer=');">rendering huge point clouds with Sunflow</a>, which seemed the perfect combination to explore this all further. By March &#8217;07 I had a system in place which allowed me to grow type and have used it for a commission to produce the &#8220;New Shoots&#8221; title sequence for Channel4.</p>
<p><img class="alignnone size-large wp-image-207" title="New Shoots (still)" src="http://toxiclibs.org/wp-content/uploads/2010/02/456471284_95dc1b9b45_o-680x382.png" alt="" width="680" height="382" /></p>
<p>The basic premise of a DLA simulation is the slow formation of complex structures through the (random) movement of single particles. Once a particle comes close to an existing one, it attaches itself and a new particle is spawned in a sphere around a previous particle. The process then repeats, slowly filling up the simulation space. If the random walk ever takes a particle passed a certain escape radius, the search is restarted with a different initial direction until another particle is hit. Because particles are usually very tiny, a large number of them and even more iterations are required for even very simple structures to emerge. For example, <a href="http://www.flickr.com/photos/toxi/456487319/in/set-72157600200636464/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/456487319/in/set-72157600200636464/?referer=');">the final frame of the New Shoots sequence</a> consisted of 4.5 million particles, whereas the structure for the image below has a &#8220;mere&#8221; 645,000&#8230;</p>
<p><img class="alignnone size-large wp-image-196" title="dlatest_spiral2" src="http://toxiclibs.org/wp-content/uploads/2010/02/dlatest_spiral2-680x382.png" alt="" width="680" height="382" /></p>
<h3>Finding the needle in the haystack</h3>
<p>Searching for particle collisions in sets of such size linearly is super slow &amp; cumbersome, so to make the process more efficient, my version of DLA is using the <a href="http://toxiclibs.org/docs/core/toxi/geom/PointOctree.html">PointOctree</a> class from the core package. This class is recursively (and on-demand) subdividing the simulation space into smaller, nested cubes, which are stored as <a href="http://en.wikipedia.org/wiki/Octree" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Octree?referer=');">tree structure</a>. When new particles are added by the DLA process they&#8217;re also being attached to the leaf nodes of the octree. When the next particle is searching for collisions with existing particles, these can then be found very quickly by querying the octree based on local search criteria using these 2 methods:</p>
<pre class="brush:java">PointOctree octree = new PointOctree(new Vec3D(-50,-50,50),100);
List&lt;Vec3D&gt; points; // in Java
java.util.List points; // in Processing, no support for generics!

// search within a sphere (i.e. all points within a certain distance)
Sphere boundingSphere = new Sphere(new Vec3D(),1);
points = octree.getPointsWithinSphere(boundingSphere); // or
points = octree.getPointsWithinSphere(origin, radius);

// search within an axis-aligned bounding box
AABB boundingBox = AABB.fromMinMax(new Vec3D(-1, -1, -1), new Vec3D(1, 1, 1));
points = octree.getPointsWithinBox(boundingBox);</pre>
<p>For more usage information about the octree also see the <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/DLASpiral/DLASpiral.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/DLASpiral/DLASpiral.pde?referer=');">DLASpiral</a> demo (the screenshot below also shows the adaptive structure of the octree) and the <a href="http://code.google.com/p/toxiclibs/source/browse/#svn/trunk/toxiclibs/examples/core/OctreeDemo" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/_svn/trunk/toxiclibs/examples/core/OctreeDemo?referer=');">OctreeDemo</a> of the core package&#8230;</p>
<p>In the future I&#8217;ll probably refactor this current dependency on the <code>PointOctree</code> class and have the <code>DLA</code> merely depend on a more generic <code>SpatialTree</code> interface, which then can also be implemented by other tree types, e.g. a <a href="http://en.wikipedia.org/wiki/Kd-tree" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Kd-tree?referer=');">kD tree</a>. To compensate, the DLA class so far has an extension point of sorts to allow custom <code>PointOctree</code> sub-classes to be used. In this case you&#8217;ll simply have to also sub-class <code>DLA</code> and overwrite the <code>createOctree</code> method to return an instance of your custom <code>PointOctree</code>.</p>
<p><img class="alignnone size-full wp-image-192" title="DLASpiral004" src="http://toxiclibs.org/wp-content/uploads/2010/02/DLASpiral004.png" alt="" width="680" height="362" /></p>
<h3>Guided growth</h3>
<p>In the above screenshot you can also see the blue spiral shape guideline directing the growth of the particles. These guidelines can either be individual line segments or points lists, e.g. sourced from a <a href="http://toxiclibs.org/docs/core/toxi/geom/Spline3D.html">Spline3D</a> instance or computed otherwise. When passing in a list of points, they&#8217;re connected into successive line segments internally. At least one line segment is required for the DLA process to function and you&#8217;d combine the 2 classes like this:</p>
<pre class="brush:java">// define a spline
Spline3D spline = new Spline3D();
spline.add(new Vec3D()).add(new Vec3D(0,-50,0)).add(new Vec3D(50,0,50)).add(new Vec3D(0,50,0));
DLAGuideLines guides = new DLAGuideLines();
guides.addCurveStrip(spline.computeVertices(8));

// setup DLA in a cubic space of 100 units edge length (always centred around (0,0,0))
DLA dla = new DLA(100);
// assign guideline(s)
dla.setGuideLines(guides);
</pre>
<p>The moment the guidelines are attached, each line segment is sampled at a high resolution and the computed points added to a second octree kept by the <code>DLA</code> class. It&#8217;s these points which are shown in the above screenshot (although only 10% of them are displayed)&#8230;</p>
<p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="680" height="382" src="http://www.youtube.com/embed/yDIh3PVq3RE" frameborder="0" allowFullScreen="true"> </iframe></p>
<h3>Order of growth</h3>
<p>By default the growth of the entire particle system will be in the same order as the guideline segments have been added, however you&#8217;re free to change this by means of custom <a href="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html" onclick="pageTracker._trackPageview('/outgoing/java.sun.com/javase/6/docs/api/java/util/Comparator.html?referer=');">Compatators</a>. The <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAGuideLines.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAGuideLines.java?referer=');">DLAGuideLines</a> class is storing <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLASegment.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLASegment.java?referer=');">DLASegment</a> instances in a sorted <a href="http://java.sun.com/javase/6/docs/api/java/util/TreeSet.html" onclick="pageTracker._trackPageview('/outgoing/java.sun.com/javase/6/docs/api/java/util/TreeSet.html?referer=');">TreeSet</a>. The order of this set can be defined by defining a custom comparator implementation when creating the guidelines and so any possible growth order can be designed/defined. The example below defines one which enforces a bottom-up growth (assuming positive Y is up):</p>
<pre class="brush:java">// define comparator
// (this how to do in Processing, which doesn't support generics...
// in plain Java you'd compare Line3D instance directly
// without the need for casting from Object)
class BottomUpOrder implements Comparator {
  public int compare(Object a, Object b) {
    float ya=((Line3D)a).getMidPoint().y;
    float yb=((Line3D)b).getMidPoint().y;
    if (ya&lt;yb) return -1;
    if (ya&gt;yb) return 1;
    return 0;
  }
}

// now use the comparator for the guidelines
DLAGuideLines guides = new DLAGuideLines(new BottomUpOrder());
</pre>
<p>The next release of this package will contain a few more of those&#8230;</p>
<h3>Parameters of growth</h3>
<p>The final requirement for the whole process to start is a set of configuration parameters. Of these there are many and so they&#8217;re encapsulated in their own class. To use them they&#8217;re simply passed to the DLA like:</p>
<pre class="brush:java">// use default configuration
dla.setConfig(new DLAConfiguration());
</pre>
<p>The default configuration has the following values, also briefly described below:</p>
<pre class="brush:java">// threshold distance below which a particle attaches itself to an older one
float snapDistance = 1.8f;
// threshold distance to attach to a curve/guideline particle
float curveAttachDistance = 2;

// max. radius of the sphere in which a new particle is spawned around a previous one
float spawnRadius = 12;
// max. radius of the sphere when the particle's random walk is interrupted/restarted
float escapeRadius = 36;
// actual size of the particles (currently assumed to be uniform for entire system)
float particleRadius = 0.25f;
// stickiness factor, only 10% of all attachments will be successful
float stickiness = 0.1f;
// using guidelines the growth can be forced into a certain direction
// this parameter defines the impact strength of this direction
// if 0.0 particles grow in all directions, 1.0 = actual segment direction is used
float curveAlign = 0.74f;

// percentage amount to progress along segments after each new particle
float curveSpeed = 0.00045f;
// velocity of the random particle walk
float searchSpeed = snapDistance * 0.66f;
// turn speed when particle changes direction
float particleSpeed = 0.001f;

// progress speed when scanning guidelines to build octree
float guideLineDensity = 0.1;

// chance for existing/already processed segments to continue growing
// evaluated before spawning each new particle
float continousGrowthRatio = 0.1f;
</pre>
<h3>Why a library?</h3>
<p>Whereas this is setup creates very interesting structures (especially when rendered in Sunflow), my idea for this library was not necessarily to have everyone replicate this specific look over &amp; over again, but provide the means to focus more on exploring the actual growth process, to customize it and use it as driver for creating new structures in which the actual particles are only present indirectly/secondary. One key feature for that matter are events emitted by the DLA class at key moments of the process. The <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAEventListener.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAEventListener.java?referer=');">DLAEventListener</a> interface defines the following 3 event hooks:</p>
<pre class="brush:java">public interface DLAEventListener {

    void dlaAllSegmentsProcessed(DLA dla);

    void dlaNewParticleAdded(DLA dla, Vec3D p);

    void dlaSegmentSwitched(DLA dla, DLASegment s);
}
</pre>
<p>You can subscribe to these events by either creating your own class implementing this interface or sub-classing the also supplied <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAEventAdapter.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.sim/toxi/sim/dla/DLAEventAdapter.java?referer=');">DLAEventAdapter</a> (in case you don&#8217;t want to react to all of them):</p>
<pre class="brush:java">class MyDLAListener extends DLAEventAdapter {

  // only get notified when growth is complete
  public  void dlaAllSegmentsProcessed(DLA dla) {
     System.out.println("done");
  }
}

DLA dla=new DLA(100);
// attach listener
dla.addListener(new MyDLAListener());
</pre>
<p>Alternatively, listening to &#8220;new particle&#8221; events allows you to construct elaborate structures not just from particles, but use particle positions to deposit small meshes or use <a href="http://toxiclibs.org/category/volumeutils/">volumeutils</a> to draw with a <code>VolumetricBrush</code> at these positions&#8230; There&#8217;re endless possibilities for further exploration and I hope some of you are excited enough to explore them! If so have fun &amp; share it!</p>
<p><a href="http://www.flickr.com/photos/toxi/tags/dla/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/tags/dla/?referer=');">Some more of my own earlier explorations into this field are on flickr.</a></p>
<p><img class="alignnone size-large wp-image-210" title="dlatest_spiral" src="http://toxiclibs.org/wp-content/uploads/2010/02/dlatest_spiral-680x382.png" alt="" width="680" height="382" /></p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/02/new-package-simutils/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ginger section</title>
		<link>http://toxiclibs.org/2010/01/ginger-section/</link>
		<comments>http://toxiclibs.org/2010/01/ginger-section/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 22:21:08 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Showcase]]></category>
		<category><![CDATA[volumeutils]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[contour]]></category>
		<category><![CDATA[generative]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[volumetric]]></category>

		<guid isPermaLink="false">http://toxiclibs.postspectacular.com/?p=61</guid>
		<description><![CDATA[It&#8217;s always still a nice surprise to spot other people&#8217;s experiments with these libraries in the wild. Just came across this beautiful example of using volumeutils by mariusz0z0Bydgoszczy, a cross section of an imaginary plant. Unfortunately no further info is available about the actual growth process, though it looks like a semi-random particle walk or [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s always still a nice surprise to spot other people&#8217;s experiments with these libraries in the wild. Just came across this beautiful example of using <a href="/category/volumeutils">volumeutils</a> by <a href="http://www.youtube.com/user/mariusz0z0Bydgoszczy" onclick="pageTracker._trackPageview('/outgoing/www.youtube.com/user/mariusz0z0Bydgoszczy?referer=');">mariusz0z0Bydgoszczy</a>, a cross section of an imaginary plant. Unfortunately no further info is available about the actual growth process, though it looks like a semi-random particle walk or <a href="http://en.wikipedia.org/wiki/Diffusion-limited_aggregation" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Diffusion-limited_aggregation?referer=');">DLA</a> method.</p>
<p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="680" height="382" src="http://www.youtube.com/embed/Gqu-2n2hidg" frameborder="0" allowFullScreen="true"> </iframe></p>
<p>I especially like the amount &amp; colours of the contour layers used to visualize different densities. A similar (only in principle) thought also lead to the concept for the <a href="/2009/12/va-decode-generative-identity/">V&amp;A Decode Identity</a> completed recently. Just create a VolumetricSpace instance, use one of the preset VolumetricBrushes (or create your own one through sub-classing), use it to manipulate the &#8220;density&#8221; in the space and then pass the space instance to a IsoSurface to turn it into a TriangleMesh. Et voila! <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/volume/VolumeBrush/VolumeBrush.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/volume/VolumeBrush/VolumeBrush.pde?referer=');">Example code</a> for this basic approach comes with the <a href="http://code.google.com/p/toxiclibs/downloads/list" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/downloads/list?referer=');">volumeutils library download</a>.</p>
<p><strong>UPDATE:</strong> There&#8217;s also an older, alternative version which is using sensor inputs to control its growth (so maybe the above process is related or even the same)&#8230;</p>
<p><iframe src="http://player.vimeo.com/video/7594282" width="680" height="382" frameborder="0"></iframe></p>
<blockquote><p>&#8220;this rhizome grows only if PIR sensor doesn&#8217;t detect movement [either nobody is in the room, or you stay still] amount of light measured by photocell influences branches girth. in this way, resulting form is a diagram of changing environmental conditions.&#8221;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/01/ginger-section/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Happy 2010</title>
		<link>http://toxiclibs.org/2010/01/happy-2010/</link>
		<comments>http://toxiclibs.org/2010/01/happy-2010/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 23:19:58 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Showcase]]></category>
		<category><![CDATA[verletphysics]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://toxiclibs.postspectacular.com/?p=68</guid>
		<description><![CDATA[One of my favourite childhood toys was Vero Construc which helped me to develop a big interest in building little (often pointless) mechanical contraptions. I&#8217;m still having a few salvaged parts of it at home which I passed on to the kids to play with, though it&#8217;s having a hard time to compete with the [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favourite childhood toys was <a href="http://www.flickr.com/photos/toxi/sets/72157600467182633/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157600467182633/?referer=');">Vero Construc</a> which helped me to develop a big interest in building little (often pointless) mechanical contraptions. I&#8217;m still having a few salvaged parts of it at home which I passed on to the kids to play with, though it&#8217;s having a hard time to compete with the more &#8220;modern&#8221; toys &amp; gadgets.</p>
<p><a title="Vero Construc by toxi, on Flickr" href="http://www.flickr.com/photos/toxi/613818768/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/613818768/?referer=');"><img src="http://farm2.static.flickr.com/1176/613818768_7ab8e752d5.jpg" alt="Vero Construc" width="500" height="375" /></a></p>
<p>So over the holidays I&#8217;ve been doing some research about kinetic &amp; mechanical art and then started working on some additions to various classes in the core and physics packages. These in turn needed testing and inspired me to create the little New Year&#8217;s greetings below:</p>
<p><iframe src="http://player.vimeo.com/video/8547987" width="680" height="382" frameborder="0"></iframe></p>
<p>Amongst other things the new additions include:</p>
<ul>
<li><strong>ParticleString</strong> class to automatically connect a list of particles with springs or create a string of particles along a line/ray</li>
<li><strong>ParticlePath</strong> is extending Spline2D/3D and can turn the spline into a ParticleString sampled at an uniform interval</li>
<li>New <strong>ParticleContstraint</strong> implementations and improvements to existing ones:
<ul>
<li><strong>AxisConstraint</strong> locks movement of a single axis</li>
<li><strong>PlaneConstraint</strong> locks movement in a plane (only 1 axis left to move in freely)</li>
<li><strong>CylinderConstraint</strong> creates a cylindrical obstacle in the simulation space</li>
<li><strong>BoxConstraint</strong> turns an axis-aligned box (AABB) into an obstacle</li>
<li><strong>SoftBoxConstraint</strong> uses an AABB as perimeter and slowly forces particles towards its centroid coordinates (per axis)</li>
</ul>
</li>
<li>Reworked (corrected) velocity handling and accessors for contraints to manipulate particle velocities upon collision</li>
</ul>
<p>Even though these updates are not yet part of a new release, you can download the source code (as complete Eclipse project incl. compiled versions of the pre-release libraries) and interactive realtime versions for OSX &amp; Windows from here:</p>
<p><a href="http://xmas.postspectacular.com/2010/" onclick="pageTracker._trackPageview('/outgoing/xmas.postspectacular.com/2010/?referer=');">xmas.postspectacular.com/2010/</a></p>
<p>To get the project into Eclipse, simply use the Import wizard:</p>
<p><em>File &gt; Import&#8230; &gt; Existing projects into workspace &gt; Next &gt; Select archive file &gt; Choose the downloaded zip &gt; Finish</em></p>
<p>Apart from the showing how to use these new classes mentioned above, Processing heads might also be interested in the elegance of XML parsing using <a href="https://jaxb.dev.java.net/" onclick="pageTracker._trackPageview('/outgoing/jaxb.dev.java.net/?referer=');">JAXB</a> (one of my favourite additions to Java 6). Last but not least, the project is also utilizing the custom vector shape alphabet system originally developed for the <a href="http://postspectacular.com/work/onedotzero/" onclick="pageTracker._trackPageview('/outgoing/postspectacular.com/work/onedotzero/?referer=');">onedotzero festival identity</a> last year.</p>
<p>Happy 2010 everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/01/happy-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Additive waves</title>
		<link>http://toxiclibs.org/2009/12/additive-waves/</link>
		<comments>http://toxiclibs.org/2009/12/additive-waves/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 22:28:34 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Showcase]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[terrain]]></category>
		<category><![CDATA[waves]]></category>

		<guid isPermaLink="false">http://toxiclibs.postspectacular.com/?p=50</guid>
		<description><![CDATA[The December release cycle has seen a number of new demos, including this one below using the built-in wave generators to create a dynamic 3D terrain. These generators are actually some of the oldest &#38; most re-usable components of the core library, but they never got much attention on the demo front. This is of [...]]]></description>
			<content:encoded><![CDATA[<p>The December release cycle has seen a number of new demos, including this one below using the built-in wave generators to create a dynamic 3D terrain. These generators are actually some of the oldest &amp; most re-usable components of the core library, but they never got much attention on the demo front. This is of course not right, especially since they also nicely demonstrate the object oriented &#8220;building block&#8221; approach also underlying most of the other available classes.</p>
<p><a title="new toxiclibs demo: AdditiveWaves017 by toxi, on Flickr" href="http://www.flickr.com/photos/toxi/4124850086/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4124850086/?referer=');"><img src="http://farm3.static.flickr.com/2689/4124850086_407814a592_m.jpg" alt="new toxiclibs demo: AdditiveWaves017" width="240" height="140" /></a> <a title="new toxiclibs demo: AdditiveWaves011 by toxi, on Flickr" href="http://www.flickr.com/photos/toxi/4124848628/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4124848628/?referer=');"><img src="http://farm3.static.flickr.com/2709/4124848628_96243ea1e9_m.jpg" alt="new toxiclibs demo: AdditiveWaves011" width="240" height="140" /></a></p>
<p><a title="new toxiclibs demo: AdditiveWaves003 by toxi, on Flickr" href="http://www.flickr.com/photos/toxi/4124075907/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4124075907/?referer=');"><img src="http://farm3.static.flickr.com/2709/4124075907_1de68ca9da_m.jpg" alt="new toxiclibs demo: AdditiveWaves003" width="240" height="140" /></a> <a title="new toxiclibs demo: AdditiveWaves005 by toxi, on Flickr" href="http://www.flickr.com/photos/toxi/4124847486/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4124847486/?referer=');"><img src="http://farm3.static.flickr.com/2804/4124847486_7cf1c98746_m.jpg" alt="new toxiclibs demo: AdditiveWaves005" width="240" height="140" /></a></p>
<p>The Processing source code for generating these meshes is available with the library download, with an excerpt shown also below. But first, here&#8217;s a brief overview of how to use these classes:</p>
<p>Waves &amp; oscillation in general are very flexible &amp; powerful tools for many different design tasks and shouldn&#8217;t always be thought of in an audio context. For example, a square wave can be used to flick between 2 values at a given frequency, without the need for any <code>if()</code> statements. I also often use sine waves to create cyclical, soft, harmonious value changes, be it for interface design, movement, animation or even the time based modulation of behavioural parameters of agents. The core library comes with the following pre-defined wave types:</p>
<ul>
<li>Sine (pure, frequency modulated (FM), amplitude &amp; frequency modulated (AMFM))</li>
<li>Sawtooth (FM)</li>
<li>Square (FM and FM with harmonics)</li>
<li>Triangle (FM)</li>
<li>Constant (only provides a static value, e.g. useful as static source for input as FM)</li>
</ul>
<p>All of these types are expressed as implementations of the <code>AbstractWave</code> class in the <a href="http://toxiclibs.postspectacular.com/docs/core/toxi/math/waves/package-summary.html" onclick="pageTracker._trackPageview('/outgoing/toxiclibs.postspectacular.com/docs/core/toxi/math/waves/package-summary.html?referer=');">toxi.math.waves</a> package. This abstract class defines all commonalities of what constitutes a wave: a phase, a frequency, an amplitude, a centre offset and a bunch of accessors and converters. The actual wave function then needs to be implemented by a concrete sub-class. Using <a href="http://en.wikipedia.org/wiki/Type_polymorphism" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Type_polymorphism?referer=');">poly-morphism</a> and having an <a href="http://en.wikipedia.org/wiki/Abstract_class" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Abstract_class?referer=');">abstract super class</a> makes a lot of sense in this case, since it allows for all this:</p>
<ol>
<li>It frees our main application from having to know which exact wave type we&#8217;re going to use and so allows for easier/faster experimentation and generally more flexibility.</li>
<li>It enables us to plug-in any of the available wave types as input for frequency or amplitude modulation and so create highly (theoretically infinitely) complex waveforms.</li>
<li>It provides the basics of an extensible framework for creating new wave types.</li>
</ol>
<p>These points are hopefully confirmed by you when looking at this method below (taken from the <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/core/AdditiveWaves/AdditiveWaves.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/core/AdditiveWaves/AdditiveWaves.pde?referer=');">AdditveWaves</a> demo, bundled since toxiclibscore-0015):</p>
<pre class="brush:java">AbstractWave createRandomWave() {

  AbstractWave result=null;

  // create a randomized sine wave to be used as
  // FM input for the main wave chosen below
  // the order of parameters is:
  // start phase, frequency (in radians), amplitude, offset value
  AbstractWave fmod=new SineWave(0, random(0.005, 0.02), random(0.1, 0.5), 0);

  // pick a random frequency
  float freq=random(0.005, 0.05);

  // choose a wave type
  switch((int)random(7)) {
  case 0:
    result = new FMTriangleWave(0, freq, 1, 0, fmod);
    break;
  case 1:
    result = new FMSawtoothWave(0, freq, 1, 0, fmod);
    break;
  case 2:
    result = new FMSquareWave(0, freq, 1, 0, fmod);
    break;
  case 3:
    // harmonic square waves are created by
    // adding sine waves upto a number of octaves
    // above the base frequency
    result = new FMHarmonicSquareWave(0, freq, 1, 0, fmod);
    ((FMHarmonicSquareWave)result).maxHarmonics=(int)random(3,30);
    break;
  case 4:
    result = new FMSineWave(0, freq, 1, 0, fmod);
    break;
  case 5:
    AbstractWave amod=new SineWave(0, random(0.01,0.2), random(2, 3), 0);
    result = new AMFMSineWave(0, freq, 0, fmod, amod);
    break;
  case 6:
    result = new ConstantWave(random(-1,1));
    break;
  }
  return result;
}</pre>
<p>The next snippet then quickly shows how this method would be used:</p>
<pre class="brush:java">import toxi.math.waves.*;

AbstractWave wave=createRandomWave();

// updates the wave phase and computes the new function value
// this code doesn't care which wave type we're dealing with
float currValue=wave.update();
</pre>
<p>The generators have another useful feature, though: A state stack. If you&#8217;ve used Processing or OpenGL before, you have likely  come across the concept in the form of <code>pushMatrix()</code>/<code>popMatrix()</code> calls to save and restore the state of the graphical transformation matrix. The wave generators implement the same idea and so can be easily used to create the 3D meshes above.</p>
<pre class="brush:java">// save current wave state
wave.push();

for(int i=0; i<10; i++) {
  float lookahead=wave.update();
  // do something clever
}

// restore wave to previous state
wave.pop();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2009/12/additive-waves/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

