<?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>Stefan Goodchild &#187; iPhone</title>
	<atom:link href="http://stefangoodchild.com/tag/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://stefangoodchild.com</link>
	<description>Old Enough To Know Better</description>
	<lastBuildDate>Fri, 25 Jun 2010 09:01:06 +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>TouchOSC and Processing Accelerometer Example Code</title>
		<link>http://stefangoodchild.com/journal/2008/12/touchosc-and-processing-accelerometer-example-code/</link>
		<comments>http://stefangoodchild.com/journal/2008/12/touchosc-and-processing-accelerometer-example-code/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 00:23:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Journal]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[TouchOSC]]></category>

		<guid isPermaLink="false">http://stefangoodchild.com/?p=194</guid>
		<description><![CDATA[Playing with my iPhone and Processing v1 on the train last night I started messing with TouchOSC and thought that this super simple (and fairly rough) example code using the oscP5 library may help someone on their way to interactive wobbly&#160;nirvana.
Code after the&#160;jump.


import processing.opengl.*;
import oscP5.*;

OscP5 oscP5;

float xrot = 0;
float zrot = 0;

float xrot_targ = 0;
float [...]]]></description>
			<content:encoded><![CDATA[<p>Playing with my iPhone and <a href="http://processing.org/">Processing v1</a> on the train last night I started messing with <a href="http://hexler.net/touchosc">TouchOSC</a> and thought that this super simple (and fairly rough) example code using the <a href="http://www.sojamo.de/libraries/oscP5/">oscP5</a> library may help someone on their way to interactive wobbly&nbsp;nirvana.</p>
<p>Code after the&nbsp;jump.</p>
<p><span id="more-194"></span></p>
<pre class="brush: java">
import processing.opengl.*;
import oscP5.*;

OscP5 oscP5;

float xrot = 0;
float zrot = 0;

float xrot_targ = 0;
float zrot_targ = 0;
float orientation = 0;

float dampSpeed = 5;

void setup() {
  size(400,400, OPENGL);
  oscP5 = new OscP5(this,8000);
  smooth();
}

void draw() {
  camera(  0, 0, 300,
         0, 0, 0,
         0.0, 1.0, 0.0
     );
  background(0); 

  // Basic value smoothing

  if (xrot_targ &gt; xrot) {
    xrot = xrot + ((xrot_targ - xrot) / dampSpeed);
  } else {
    xrot = xrot - ((xrot - xrot_targ) / dampSpeed);
  }

  if (zrot_targ &gt; zrot) {
    zrot = zrot + ((zrot_targ - zrot) / dampSpeed);
  } else {
    zrot = zrot - ((zrot - zrot_targ) / dampSpeed);
  }

 // Detection for if the iPhone is upsidedown or not

  if (orientation &lt; 0) {
    fill(255,0,0);
    rotateX(radians(xrot));
    rotateZ(radians(zrot));
  } else {
    fill(255,255,0);
    rotateX(radians(xrot*-1));
    rotateZ(radians(zrot*-1));
  }
  box(130,10,60);

}

void oscEvent(OscMessage theOscMessage) {
  if(theOscMessage.checkAddrPattern(&quot;/accxyz&quot;)==true) {
      xrot_targ = (theOscMessage.get(0).floatValue()*90);
      zrot_targ = (theOscMessage.get(1).floatValue()*90)*-1;
      orientation = theOscMessage.get(2).floatValue();
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://stefangoodchild.com/journal/2008/12/touchosc-and-processing-accelerometer-example-code/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
