We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › oscP5 - data receiving question
Page Index Toggle Pages: 1
oscP5 - data receiving question (Read 781 times)
oscP5 - data receiving question
Jun 11th, 2008, 5:12pm
 
hello, im new to processing and programmming at all and have a question about receiving oss-messages in processing.
what i want to do is very simple. i want to set the x and y postition of an object to the values of an osc-message. the osc-message is sent by GlovePIE (Programmable Input Emulator)and transports the x and y values from a Nintendo Wiimote to processing.

in processing i receive these two values with the oscEvent function. what i cant figure out is how to assign these values to an object in the draw() function. i can only relate to this variables within the oscEvent function. but when i draw a rectangle within the oscEvent function it is blinking or it doesnt show up at all. by setting a delay in the draw() function the blinking stopped, but im sure that this isnt the right way to go.

does somebody have a clue how to solve my problem? i would be thankful

greets jason

heres my code so far:

/**
* osc - object control
*/

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
 size(800,800);
 frameRate(50);
 /* start oscP5, listening for incoming messages at port 3000 */
 oscP5 = new OscP5(this,3000);
 myRemoteLocation = new NetAddress("127.0.0.1",3000);
 
}

void draw() {
 background(222);
 delay(150);
}

void oscEvent(OscMessage theOscMessage) {

int wii1x = theOscMessage.get(0).intValue();
int wii1y = theOscMessage.get(1).intValue();
RECHTECK r1 = new RECHTECK(wii1x,wii1y);
r1.rechteck();

println("IR LED 01 - X : "+ theOscMessage.get(0).intValue() +" IR LED 01 - Y :  " + theOscMessage.get(1).intValue() );
}

class RECHTECK {
 int xpos, ypos;
 RECHTECK (int x, int y) {  
   xpos = x;
   ypos = y;
 }
 void rechteck() {
  rect(xpos,ypos,100,100);
  strokeWeight(7);
  fill(255,255,255,80);

 }
}


Re: oscP5 - data receiving question
Reply #1 - Jun 11th, 2008, 8:00pm
 
There is a possible solution.

import oscP5.*;
import netP5.*;
RECHTECK r1;
int wii1x, wii1y;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
 size(800,800);
 frameRate(50);
 /* start oscP5, listening for incoming messages at port 3000 */
 oscP5 = new OscP5(this,3000);
 myRemoteLocation = new NetAddress("127.0.0.1",3000);
 
 r1 = new RECHTECK();
 
}

void draw() {
 background(222);
 delay(150);
 r1.rechteck(wii1x, wii1y);


}

void oscEvent(OscMessage theOscMessage) {

wii1x = theOscMessage.get(0).intValue();
wii1y = theOscMessage.get(1).intValue();  

println("IR LED 01 - X : "+ theOscMessage.get(0).intValue() +" IR LED 01 - Y :  " + theOscMessage.get(1).intValue() );
}

class RECHTECK {  
 int xpos, ypos;  
 RECHTECK () {  
 }  
 void rechteck(int x, int y) {
   xpos = x;  
   ypos = y;  
  rect(xpos,ypos,100,100);
  strokeWeight(7);
  fill(255,255,255,80);

 }  
}

One last thing, the convention to write the name of the class is "Rechteck" and not "RECHTECK".
     
By
Re: oscP5 - data receiving question
Reply #2 - Jun 11th, 2008, 8:29pm
 
hi, thanks a lot, it works much better now.
now i can start doing crazy stuff with my wiimote and processing.

greets jason
Page Index Toggle Pages: 1