« CTIN 511 Blogorama Aftermath - Changing Perspectives | Main | The GDC Experience »

Wii Controller + Processing

You need Darwiin remote and a wii remote and a bluetooth adapter. This reads a text file from the Darwiin and then utilizes it in processing and it shows up as movement.

PImage wiimote_top, wiimote_front;
int accX, accY, accZ, orientation;

void setup()
{
size(600, 400);
frameRate(60 );

smooth();

//wiimote_top = loadImage("shake.jpg");
//wiimote_front = loadImage("turn.jpg");
}

void draw()
{
background(0);
fill(255);
ellipse(400.0,300.0, 50, 50);

// load the textfile generated from DarwiinRemote and converts it into strings
String [] wiimote_file = loadStrings("/wiimote.txt");

if (wiimote_file.length == 1)//this if statement reads the TXT file and converts
//it into movement.
{
String [] wiimote_values = wiimote_file[0].split(";");

accX = Integer.parseInt(wiimote_values[0]);
accY = Integer.parseInt(wiimote_values[1]);
accZ = Integer.parseInt(wiimote_values[2]);

orientation = Integer.parseInt(wiimote_values[3]);
}

ellipse(132-accX/2.0, 190-accY/2.0, 300,400);

translate(width/2, 70);
if(orientation == 1)
rotate(-PI/2);
else if(orientation == 2)
rotate(PI);
else if(orientation == 3)
rotate(PI/2);
//rect(wiimote_front, -wiimote_front.width/2, -wiimote_front.height/2);
}

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on January 29, 2009 8:53 PM.

The previous post in this blog was CTIN 511 Blogorama Aftermath - Changing Perspectives.

The next post in this blog is The GDC Experience.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31