<rss version="2.0" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel>
	<title>openFrameworks.info</title>
	<link>http://www.openframeworks.info</link>
	<description>openFramework.info: programming techniques, projects made with openFrameworks, community news</description>
	<generator>WAFCMS</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
<item>
		<title>openFrameworks Freakday 2</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>1c383cd30b7c298ab50293adfecb7b18guid</guid>
		<description><![CDATA[<p>Hi fellow openFrameworks freaks, enthusiasts and fanatics!</p>

<p>On <strong>November the  15th</strong> we'll have our first openFrameworks Freakday. On this day we will come together with a group of openFrameworks fanatics! We'll  discuss projects and try to help eachother where we can.  After our first freakday we introduced interest-groups where you work with a group on a certain project/topic which you are interested in.</p>

<p>The meeting/workshop will start at <strong>10.00-10.30</strong> in the morning an will be held at:</p>

<p>Duintjer CS<br />
Vijzelstraat 72, 4th floor,  room 4.10<br />
1017 HL,  Amsterdam</p>

<p><strong>Make sure you take your laptop with you and try to install openFrameworks</strong></p>

<p>The meeting/workshop is free, though we ask you to donate something for the 
food and drinks we provide.  <strong><em>Sign up below; we're looking forward to meet you!</em></strong></p>

<p><a href="http://wiki.openframeworks.info/doku.php?id=workshop_freakday">We created a wiki for the freakDays!!</a></p>]]></description>
</item><item>
		<title>openFrameworks Freakday</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>182be0c5cdcd5072bb1864cdee4d3d6eguid</guid>
		<description><![CDATA[<h2>2009.10.18 - Workshop</h2>

<p>Last weekend we had our first <strong>openFrameworks FreakDay</strong> with a group of ~14 creative-developers. Some did already amazing things with oF others just came to learn to use it.  After a wonderful introduction on oF by Theo everyone started with examples applications or their own projects.  This was our first meeting so we had to figure out the format.. for the next meeting we're thinking to create interest-groups where you can participate on 
a certain subject and work as a group on a problem and try to help/figure out how to create things with oF. You can think of a interest-group "hardware&lt;>of" or visualisation/3D/openGL.  We'll think about this format and start a 
mailing list where everyone can participate on this discussion.</p>

<h2>2009.09.10 - Invitation</h2>

<p>Hi fellow openFrameworks freaks, enthusiasts and fanatics!</p>

<p>On <strong>October the  18th</strong> we'll have our first openFrameworks Freakday. On this day we will come together with a group of openFrameworks fanatics! We'll  discuss projects and try to help eachother where we can.</p>

<p>The idea of this meeting is to share knowlegde and have fun with openFrameworks.  As this is the first <strong>openFrameworks Freakday</strong> we hope to see you <strong>18 October</strong>.  Example topics we can talk about are:</p>

<ul>
<li>openCV / computer vision</li>
<li>trigonometry</li>
<li>openGL</li>
<li>programming animation</li>
<li>hardware (?)</li>
<li>... <em>any other interesting topics</em>...</li>
</ul>

<p>The meeting/workshop will start at <strong>10.00</strong> in the morning an will be held at:</p>

<p>Duintjer CS<br />
Vijzelstraat 72, 4th floor,  room 4.10<br />
1017 HL,  Amsterdam</p>

<p><strong>Make sure you take your laptop with you and try to install openFrameworks</strong></p>

<p>The meeting/workshop is free, though we ask you to donate something for the 
food and drinks we provide.  <strong><em>Sign up below; we're looking forward to meet you!</em></strong></p>]]></description>
</item><item>
		<title>YouCube at Lowlands 2009</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>6364d3f0f495b6ab9dcf8d3b5c6e0b01guid</guid>
		<description><![CDATA[<p>From 20 untill 23 august 2009, we were at <a href="http://www.lowlands.nl">Lowlands 2009</a> with the project for which <a href="http://www.apollomedia.nl">we</a> created the  software / game for <a href="http://www.thijseerens.com">Thijs Eerens</a>.  Visitors of the Lowlands festival would jump in and play a game of Tetirs with real boxes.  After building a box you could jump around an position the piece on screen by jumping on huge buttons.  We used <a href="http://www.openframeworks.cc">openFrameworks</a> for the game and <a href="http://www.arduino.cc">arduino</a> for the hardware.</p>

<p><object width="600" height="340"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6314871&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ff9933&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6314871&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ff9933&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="340"></embed></object></p>

<p><a href="http://vimeo.com/6314871">Youcube @ Lowlands 2009 Benthuizen</a> from <a href="http://vimeo.com/user1790965">roxlu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>ofAqua</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c16a5320fa475530d9583c34fd356ef5guid</guid>
		<description><![CDATA[<p>....Using advanced computer vision techniques, swarm behaviors and audio/visual analysis created within openFrameworks v006 (a C++ library for creative coding), Woohoo creates an experience that attempts to look at the playful, beautiful and destructive interaction between people and our environment.</p>

<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3880280&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3880280&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/3880280">ofAgua Medusae v2</a> from <a href="http://vimeo.com/drwoohoo">dr woohoo</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>Creating HD video from application for Vimeo (and others)</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>34173cb38f07f89ddbebc2ac9128303fguid</guid>
		<description><![CDATA[<p>This article describes how you can create a HD video from your openFrameworks application which you can put online on <a href="http://www.vimeo.com">Vimeo</a> or <a href="http://ww.youtube.com">Youtube</a> or any other of your favorite video site. When I started I tried to use After Effects to create a HD video though the quality and size were not as I expected. Also, creating a video from the visualisation I did was not just a couple of clicks as I hoped for.  For the <a href="http://openframeworks.info/prog_tech/flocking/28">flocking</a> tutorial I needed to create a good looking video which is on <a href="http://vimeo.com/5352863">vimeo</a>.</p>

<p>These are the steps you need to do:</p>

<ol>
<li>Create png images from each frame </li>
<li>Create a HD movie from these stills / image sequence.</li>
</ol>

<h1>1. Create png images from each frame</h1>

<p>In your application you should add this code which writes each frame to an image file sequence.</p>

<pre class="c"><span style="color: #808080; font-style: italic;">// img_saver is of type ofImage</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">char</span> file_name<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#93;</span>;
sprintf<span style="color: #66cc66;">&#40;</span>file_name, <span style="color: #ff0000;">&quot;output/output_%0.4i.png&quot;</span>, saved_image_num<span style="color: #66cc66;">&#41;</span>;
img_saver.<span style="color: #202020;">grabScreen</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, ofGetWidth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, ofGetHeight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Saving file: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, file_name<span style="color: #66cc66;">&#41;</span>;
img_saver.<span style="color: #202020;">saveImage</span><span style="color: #66cc66;">&#40;</span>file_name<span style="color: #66cc66;">&#41;</span>;
saved_image_num++;</pre>

<p>This saves each frame to a file named output_001.png, output_002.png etc.. <strong>Make sure you create the output directory in your bin/data/ folder.</strong>.  <strong>saved_image_num</strong> is of type int and a member of the testApp class.  I also tried to use <a href="http://www.memo.tv">memo's</a> threaded image saver, but this one skipped some frames. I got files like 001, 003, 004, 006 etc..</p>

<p>Also make sure your application has a window which is conform HD:</p>

<pre class="c"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    ofAppGlutWindow window;
    ofSetupOpenGL<span style="color: #66cc66;">&#40;</span>&amp;window, <span style="color: #cc66cc;">1280</span>,<span style="color: #cc66cc;">720</span>, OF_WINDOW<span style="color: #66cc66;">&#41;</span>;        
    ofRunApp<span style="color: #66cc66;">&#40;</span> new testApp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>

<h1>2. Create a HD movie from these stills / image sequence.</h1>

<p>Now, download <a href="http://fixounet.free.fr/avidemux/download.html">Avidemux</a>  and make sure you've got the <a href="http://www.xvid.org/">Xvid</a> codec installed.  Once you've installed Avidemux, run it. 
Now follow these steps:</p>

<ul>
<li>File > Open and select the first file of the image sequence  </li>
<li>At the video selectbox, select MPEG-4 ASP (XVid4)<br />
<img src="/assets/uploaded/94-vimeo_hd_video_codec.png" alt="vimeo_hd_video_codec.png" class="" title="vimeo_hd_video_codec.png"></li>
<li><p>Click on "Configure" under Video and use these settings:
<img src="/assets/uploaded/95-vimeo_hd_video_settings.png" alt="vimeo_hd_video_settings.png" class="" title="vimeo_hd_video_settings.png"></p></li>
<li><p>Click on the "Filters" button > Interlacing > Add the "yadiff" (click green plus sign to add it)<br />
<img src="/assets/uploaded/96-vimeo_hd_video_yadiff.png" alt="vimeo_hd_video_yadiff.png" class="" title="vimeo_hd_video_yadiff.png"></p></li>
<li><p>Than you only need to save the video and it starts rendering. That's all! So  File > Save> Save Video...</p></li>
<li>As format I used "avi"  </li>
</ul>]]></description>
</item><item>
		<title>ofxVectorMath</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>6ea9ab1baa0efb9e19094440c317e21bguid</guid>
		<description><![CDATA[<h1>ofxVectorMath</h1>

<p>Vector math addon for openFrameworks.</p>

<p><a href="http://www.openframeworks.cc/download">Download the ofxVectorMath addon</a><br />
which  is part of the FAT package. (click this link to open the download page of openFrameworks)</p>]]></description>
</item><item>
		<title>Flocking</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>33e75ff09dd601bbe69f351039152189guid</guid>
		<description><![CDATA[<h1>Flocking behavior</h1>

<p>In this article I'll explain how to simulate the movements of birds which is called flocking.  The article is based on the wonderful paper of <a href="http://www.red3d.com/cwr/boids/">Graig Reynolds</a> whom's name is always used in the same sentence with flocking behavior. Graig did a wonderful
job on the research of movement of birds.  This behavior can be used in you visualisations, simulations, etc..   A couple of days ago I found a 
fantastic implementation of flocking behavior in a logo. Have a look at <a href="http://blprnt.com/">BLPRNT.com</a> (wait untill the logo has loaded).</p>

<h1>Keypoints in flocking</h1>

<p>Basically to implement flocking behavior you'll need to following things:</p>

<ol>
<li>A good working vector class which openframeworks has.  </li>
<li>Implementation of: Separation</li>
<li>Implementation of: Alignment</li>
<li>Implementation of: Cohesion</li>
</ol>

<p><strong>Flocking video, based on the code described in this article</strong></p>

<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5352863&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5352863&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/5352863">Flocking with openFrameworks</a> from <a href="http://vimeo.com/user1790965">roxlu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<h2>1. A good working vector class.</h2>

<p>Here I mean a vector class which does all the vector operations for you. A vector is something which has a length and a direction.  You can find numerous  tutorials on vector math but to implement flocking you don't need lots of fancy things. Most of the math is extremely simple, like addition, subtraction, multiplication and averaging.  'All'of the flocking implementations use a vector class, though it can be done without. In this article we <strong>do</strong> use  vectors.   Let me quickly explain how this vector class is used.</p>

<p>In our simulation we have a couple of "boids", which represent the birds.  A bird has a position and velocity.  Multiple forces which influence the velocity and therefore the position are applied on thes boids. Like in most physics implementations we calculate the resulting position based on the current forces, velocity and position.  The new position is simply calculated by adding all the forces to the velocity and then adding the velocity to the current position.</p>

<pre class="c">velocity += force;
position += velocity;</pre>

<p><em>Note</em> that the above code is not 100% working as we need to limit the force and velocity.</p>

<h2>2. Implementation of: Separation</h2>

<p>We use separation to avoid that all boids group together at one position. They need to keep a certain distance from eachother.  For this implementation we created two classes, Boid and Boids. Boid represents a single bird, and Boids a 'flock'.</p>

<p><img src="/assets/uploaded/91-flocking_with_openframeworks_separation.png" alt="flocking_with_openframeworks_separation.png" class="" title="flocking_with_openframeworks_separation.png"></p>

<p>The Boids class implements the flocking behaviour. It has a method "flock()" which handles the separation. Roughly the separation works like this (in pseudo code):</p>

<pre>
Loop through all boids (i)
    Loop through all other boids (j)
          Check if i != j (we don't check the current boid with itself)
          Calculate the distance of the current boid (i) with the other boids (j)
          If the other boid is too close move away 
   End loop
End loop
</pre>

<p><strong>The implementation of cohesion for our flocking algorithm</strong>:<br />
<em>note: I left out the other part like cohesion and alignment for clearity.</em></p>

<pre class="c"><span style="color: #993333;">void</span> Boids::<span style="color: #202020;">flock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #993333;">float</span> too_close_dist = <span style="color: #cc66cc;">90</span>.0f;
    <span style="color: #993333;">float</span> in_sight_dist = <span style="color: #cc66cc;">150</span>.0f;
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> j = <span style="color: #cc66cc;">0</span>; j &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++j<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>j == i<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">continue</span>;
            <span style="color: #993333;">float</span> dist = <span style="color: #66cc66;">&#40;</span>boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #202020;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// separate</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dist &lt;= in_sight_dist <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// This is where we move away. We &quot;Flee&quot; away from the other Boid.</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dist &lt;= too_close_dist<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;flee<span style="color: #66cc66;">&#40;</span>boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h2>3. Implementation of: Alignment</h2>

<p>As described by <a href="http://www.red3d.com/cwr/boids/">Craig Reynolds</a>, alignment is the behavior of birds when they steer towards the average heading of local flockmates. This means we check which birds are in range and remember the velocity of each of these in-range birds. When we've found all birds in range we average this velocity and steer towards it.</p>

<p><strong>Alignment in openFrameworks</strong></p>

<pre class="c"><span style="color: #993333;">void</span> Boids::<span style="color: #202020;">flock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #993333;">float</span> too_close_dist = <span style="color: #cc66cc;">90</span>.0f;
    <span style="color: #993333;">float</span> in_sight_dist = <span style="color: #cc66cc;">150</span>.0f;
    <span style="color: #993333;">int</span> insight_count = <span style="color: #cc66cc;">0</span>;
    ofxVec3f average_vel, average_pos;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        average_vel.<span style="color: #202020;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
        average_pos.<span style="color: #202020;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
        insight_count = <span style="color: #cc66cc;">0</span>;
&nbsp;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> j = <span style="color: #cc66cc;">0</span>; j &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++j<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>j == i<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">continue</span>;
            <span style="color: #993333;">float</span> dist = <span style="color: #66cc66;">&#40;</span>boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #202020;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dist &lt;= in_sight_dist <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                average_vel += boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getVelocity<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                insight_count++;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>insight_count &gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            average_vel /= insight_count;
            boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;addForce<span style="color: #66cc66;">&#40;</span>average_vel - boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;getVelocity<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h2>4. Implementation of: Cohesion</h2>

<p>When we've got a group of birds they tend to fly into a direction as a whole. This is because of cohesion; each bird positions himself to a average direction.  A bird looks at the birds which are in sight and adjusts his position to the average position of the birds in sight.</p>

<p><img src="/assets/uploaded/92-flocking_with_openframeworks_cohesion.png" alt="Flocking with openframeworks: cohesion" class="" title="Flocking with openframeworks: cohesion"></p>

<p>Technically we achieve this (like with separation) for each bird to check the distance to the other birds and when they are in a given range we remember their position.  When we've looped through all position for lets say the first bird, we calculate the average position and we let the bird seek this point.</p>

<p>In pseudo code:</p>

<pre>
Loop through all boids (i)
    Loop through all other boids (j)
          Check if i != j (we don't check the current boid with itself)
          Calculate the distance of the current boid (i) with the other boids (j)
          If the other boid is in range
               Add the position to our average postion vector (ofxVec3f)
               Increase the "insight counter" that is used to average the position
          End if
   End loop
   Average the position
   Let boid "i" seek to the average position
End loop
</pre>

<p><strong>Implementation of the cohesion for the flocking algorithm.</strong></p>

<pre class="c"><span style="color: #993333;">void</span> Boids::<span style="color: #202020;">flock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #993333;">float</span> in_sight_dist = <span style="color: #cc66cc;">150</span>.0f;
    <span style="color: #993333;">int</span> insight_count = <span style="color: #cc66cc;">0</span>;
    ofxVec3f average_vel, average_pos;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        average_vel.<span style="color: #202020;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
        average_pos.<span style="color: #202020;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
        insight_count = <span style="color: #cc66cc;">0</span>;
&nbsp;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> j = <span style="color: #cc66cc;">0</span>; j &lt; boids.<span style="color: #202020;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ++j<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>j == i<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">continue</span>;
            <span style="color: #993333;">float</span> dist = <span style="color: #66cc66;">&#40;</span>boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #202020;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dist &lt;= in_sight_dist <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                average_pos += boids<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>-&gt;getPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                insight_count++;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>insight_count &gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            average_pos /= insight_count;
            boids<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>-&gt;seek<span style="color: #66cc66;">&#40;</span>average_pos<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<h1>Additional information about flocking</h1>

<p>As you see we use a method "seek" which implements a seeking steering behavior. I've attaced the source code with some other parts that are used to create a simple flock.</p>

<h1>Resources</h1>

<p><a href="http://www.red3d.com/cwr/boids/">Craig Reynolds Boids</a><br />
<a href="/assets/uploaded/93-flocking_with_openframeworks.zip"
                                     title="Download the source code of the flocking algorithm">Download the source code of the flocking algorithm</a></p>]]></description>
</item><item>
		<title>Memory</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>02e74f10e0327ad868d138f2b4fdd6f0guid</guid>
		<description><![CDATA[<p><em>From the author</em>:
t's a bit tricky trying to film the piece since it uses projection onto glass. Sadly I'm left with only a few images that try to portray what went on.</p>

<p><a href="http://ccrma.stanford.edu/~pkmital/share/Memory.zip">Here's the code</a> It makes use of the openframeworks library so you will need to be familiar with how to setup an XCode project with the openframeworks library if you plan on using it.</p>

<p>The original idea was to use glass balls so that's why all the code says glassBalls instead of say glassNeurons. If you manage to get it running, press 'd' to see the live video input. As it collects faces, it fills up the image buffers with each "glassBalls". Once all the glassBalls are loaded with images of faces, then the visualization begins. Neurons will "fire" and brightness values of each neuron will go up and down based on Gaussian functions and these values are sent to the brightness shader.</p>

<p>It was a bit of a sculptural challenge placing all the glass pieces within view of the projector, avoiding any other glass pieces or chains in the line of sight of it, having it fit within our view of what we wanted, and also within the amount of time we had. We did the projection mapping by just creating the object with a bounding box. Once you moused over an image of a person's face, you could drag it around, use '-', '=', '_', or '+' to resize it. I used a text file to store ('w') and read ('r') the positions of the faces in case I had to reload the program. I think memo has some MSAInteractiveObject class now which would be 1000x nicer to use.</p>

<p>Just a note as well, I wrote this against of573. I also ended up extending ofxCvColorImage with a few functions so I've just included all of ofxCv* files in the project. There may very well be other functions that I've edited and forgotten about so please let me know if you have any problems with it. Have a look through and please let me know what you think!</p>]]></description>
</item><item>
		<title>Verlet integration</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>4e732ced3463d06de0ca9a15b6153677guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>Portrait Machine</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c4ca4238a0b923820dcc509a6f75849bguid</guid>
		<description><![CDATA[<p><a href="http://impssble.com/photos/PM">More photos</a></p>]]></description>
</item><item>
		<title>People on Pop</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c81e728d9d4c2f636f067f89cc14862cguid</guid>
		<description><![CDATA[<p><a href="http://www.peopleonpop.org/">http://www.peopleonpop.org/</a></p>]]></description>
</item><item>
		<title>Dangerous Australians</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>eccbc87e4b5ce2fe28308fd9f2a7baf3guid</guid>
		<description><![CDATA[<p><a href="http://www.lightwell.com.au/project.php?id=57&amp;c=105&amp;iid=1">External site</a></p>]]></description>
</item><item>
		<title>Tessella</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>a87ff679a2f3e71d9181a67b7542122cguid</guid>
		<description><![CDATA[<p><a href="http://www.cybunk.com/blog2/tessella-video/">External site</a></p>]]></description>
</item><item>
		<title>Parque</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>e4da3b7fbbce2345d7772b0674a318d5guid</guid>
		<description><![CDATA[<p><a href="http://www.teknikus.dk/tj/gdc2001.htm">Article on the physics used in this visualisation</a></p>]]></description>
</item><item>
		<title>Lassa</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>1679091c5a880faf6fb5e6087eb1b2dcguid</guid>
		<description><![CDATA[<p><a href="http://www.flickr.com/photos/30589069@N00/sets/72157604712645209/">More photos on Flickr</a></p>]]></description>
</item><item>
		<title>Lights On</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>8f14e45fceea167a5a36dedd4bea2543guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>Smart Launch</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c9f0f895fb98ab9159f51fd0297e236dguid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>Elektronisk Transcendens</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>45c48cce2e2d7fbdea1afc51c7c6ad26guid</guid>
		<description><![CDATA[<p>The canvas was tracked by a camera in the roof when holding it in the light, and when my program saw that it was stable in the frame, a photo was taken inside the square that the canvas formed. At the same time a sound was triggered, and the whole sound universe (designed by my friend Rasmus Kreiner, a theater sound designer) changed.
Afterwards the audience could hold the canvas against the 4x8m big backprojected wall, where a infrared camera behind could track where it was, and how it was rotated. And again, when my program saw it was not moving, it attached the photo to the wall, where it moved in a physics simulator (pushing to other photos) and slowly moving upwards before it was deleted again.</p>

<p>The software is developed in OpenFrameworks, using alot of OpenCV code. The tracking of the canvas on the wall was done with tBeta.</p>

<p>The installation ran for 7 hours during the party, and there was taken more then 500 pictures, and the audience really liked it. People understood the concenpt (even drunk) right away, and told it to each other when passing by. Many came back later and took some more photos</p>]]></description>
</item><item>
		<title>Gegenlicht</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>d3d9446802a44259755d38e6d163e820guid</guid>
		<description><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3324904&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3324904&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/3324904">Gegenlicht (back-light) - Audio Reactive realtime video</a> from <a href="http://vimeo.com/user320217">moka</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>Swarm</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>6512bd43d9caa6e02c990b0a82652dcaguid</guid>
		<description><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2083865&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2083865&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/2083865">Swarm</a> from <a href="http://vimeo.com/blendid">Blendid</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>TouchMe</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c20ad4d76fe97759aa27a0c99bff6710guid</guid>
		<description><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2436557&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2436557&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/2436557">TouchMe - China 2008</a> from <a href="http://vimeo.com/blendid">Blendid</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<p><a href="http://www.blendid.nl/index.php?id=6">External site</a></p>]]></description>
</item><item>
		<title>The Visitation</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>c51ce410c124a10e0db5e4b97fc2af39guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>Multitouch Physics Game</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>aab3238922bcc25a6f606eb525ffdc56guid</guid>
		<description><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4921004&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4921004&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/4921004">Multitouch Physics Game</a> from <a href="http://vimeo.com/user1480226">Patch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>Carnival</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>6f4922f45568161a8cdf4ad2299f6d23guid</guid>
		<description><![CDATA[<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3747070&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3747070&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object></p>

<p><a href="http://vimeo.com/3747070">Carnival Interactive Aquarium</a> from <a href="http://vimeo.com/vanderlin">vanderlin</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<p><a href="http://www.flickr.com/photos/vanderlin/sets/72157615828765044/">More photos</a></p>]]></description>
</item><item>
		<title>Green Sense</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>1f0e3dad99908345f7439f8ffabdffc4guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>ofxBox2d</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>98f13708210194c475687be6106a3b84guid</guid>
		<description><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4157466&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4157466&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>

<p><a href="http://vimeo.com/4157466">Mounds</a> from <a href="http://vimeo.com/vanderlin">vanderlin</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>ofxRuiPhysics2d</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>3c59dc048e8850243be8079a5c74d079guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>ofxMSAPhysics</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>b6d767d2f8ed5d21a44b0e5886680cb9guid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>ofxNoise</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>37693cfc748049e45d87b8c7d8b9aacdguid</guid>
		<description><![CDATA[]]></description>
</item><item>
		<title>ofxMSAFluid</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>1ff1de774005f8da13f42943881c655fguid</guid>
		<description><![CDATA[<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4446798&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4446798&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object></p>

<p><a href="http://vimeo.com/4446798">ofxMSAFluid for openFrameworks</a> from <a href="http://vimeo.com/memotv">Memo Akten</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
</item><item>
		<title>ofxSimpleGuiToo</title>
		<link>http://www.openframeworks.info</link>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0100</pubDate>
		<guid>8e296a067a37563370ded05f5a3bf3ecguid</guid>
		<description><![CDATA[]]></description>
</item></channel>
</rss>
