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 & HelpPrograms › Osc exemple
Page Index Toggle Pages: 1
Osc exemple (Read 343 times)
Osc exemple
Jan 9th, 2009, 12:47am
 
Hello, I want to use oscp5  on a small sample (turn a cube), but when the message is send, the cube is not turning.
Here's the code:


 int sval=0,cnd=0;

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
 size(600, 400, P3D);
 noStroke();
 frameRate(25);

 oscP5 = new OscP5(this,12000);
 
 
 
 myRemoteLocation = new NetAddress("127.0.0.1",12000);
}


void draw() {
 lights();
 background(#1E90FF);
 translate(300,200,0);
 fill(#00FF00);

 if (cnd==1) sval+=1;
 rotateY(sval*0.01);
 box(80);
}

void keyPressed() {
switch(key) {
   case('r'):


 OscMessage myMessage = new OscMessage("/test");
 


 myMessage.add("Tourner"); /* add a string to the osc message */


 /* send the messacge */
 oscP5.send(myMessage, myRemoteLocation);
 break;
 
  case('t'):

 /* in the following different ways of creating osc messages are shown by example */
 OscMessage myMessage1 = new OscMessage("/test");
 


 myMessage1.add("Arreter"); /* add a string to the osc message */


 /* send the messacge */
 oscP5.send(myMessage1, myRemoteLocation);
 break;
}
}


/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
 /* print the address pattern and the typetag of the received OscMessage */
 print("### received an osc message.");
 print(" addrpattern: "+theOscMessage.addrPattern());
 println(" typetag: "+theOscMessage.typetag());
 String Value = theOscMessage.get(0).stringValue();
   if (Value=="Tourner")  cnd=1;
 
}

Re: Osc exemple
Reply #1 - Jan 9th, 2009, 11:40am
 
try

Code:

if (Value.equals("Tourner")) {
cnd=1;
}

instead of
Code:

if (Value=="Tourner") cnd=1;


Strings are Objects. by using == you compare the objects not their content (content in this case is "Tourner"). String.equals compares the content of Strings. try searching the forum for "string equals" and you get more information.

best,
andreas




Re: Osc exemple
Reply #2 - Jan 9th, 2009, 3:15pm
 
Thank you for help.
Page Index Toggle Pages: 1