/** * osc, processing and the wiimote, using OSCulator * based on oscReceiveWiiIR by andreas schlegel, andi@sojamo.de */ import oscP5.*; import netP5.*; OscP5 osc; float[][] xyz; void setup() { size(400,400); frameRate(25); // open an up port for listening to incoming osc messages from OSCulator osc = new OscP5(this,"localhost",9000); // osc.plug(this,"xyz_1","/wii/1/accel/xyz"); // osc.plug(this,"xyz_2","/wii/2/accel/xyz"); osc.plug(this,"pry","/wii/1/accel/pry"); xyz = new float[8][3]; } // void xyz_1(float _x, float _y, float _z) { xyz(0, _x, _y, _z); } // void xyz_2(float _x, float _y, float _z) { xyz(1, _x, _y, _z); } // void xyz(int _index, float _x, float _y, float _z) { // xyz[_index][0] = _x; // xyz[_index][1] = _y; // xyz[_index][2] = _z; // } float pitch; float roll; float yaw; float accel; void pry(float _pitch, float _roll, float _yaw, float _accel) { pitch = _pitch; roll = _roll; yaw = _yaw; accel = _accel; } void draw() { background(0); noStroke(); fill(125); rect(100, 125, 200, 150); // PITCH // Pitch Bottom if(pitch>0.25) { float pitchBottom = map(pitch, 0.25, 1, 0, 255); fill(pitchBottom); ellipse(width/6, height-height/4, 50, 50); ellipse(width-width/6, height-height/4, 50, 50); } // Pitch Middle if(pitch>0.5) { float pitchMiddle = map(pitch, 0.5, 1, 0, 255); fill(pitchMiddle); ellipse(width-width/6, height/2, 50, 50); ellipse(width/6, height/2, 50, 50); } // Pitch Top if(pitch>0.75) { float pitchTop = map(pitch, 0.75, 1, 0, 255); fill(pitchTop); ellipse(width/6, height/4, 50, 50); ellipse(width-width/6, height/4, 50, 50); } // ROLL // Roll Left if(roll<0.5) { float rollLeft = map(roll, 0, 0.5, 255, 0); fill(0, rollLeft); rect(0, 0, 100, height); } //Roll Right if(roll>0.5) { float rollRight = map(roll, 0.5, 1, 0, 255); fill(0, rollRight); rect(300, 0, 100, height); } }