Once we receive the OSC in Processing we will need to parse that data stream. The column on the left shows how the original format of the data and on the right is how we would like to parse the data into groups of X,Y, and Z coordinates. Keep in mind that the unit of measure for Vicon Tracker is millimeters.
Step 1:
/vicon/frame 989 100 /vicon/marker/Object/Object1 100.878 300.474 150.892 /vicon/marker/Object/Object2 -200.726 600.567 200.387 /vicon/marker/Object/Object3 350.489 -400.575 -300.575
Step 2:
/vicon/frame 989 100
/vicon/marker/Object/Object1 100.878 300.474 150.892 /vicon/marker/Object/Object2 -200.726 600.567 200.387 /vicon/marker/Object/Object3 350.489 -400.575 -300.575
Step 3:
/vicon/marker/Object/Object1 100.878 300.474 150.892
/vicon/marker/Object/Object2 -200.726 600.567 200.387
/vicon/marker/Object/Object3 350.489 -400.575 -300.575
Step 4:
100.878 300.474 150.892
-200.726 600.567 200.387
350.489 -400.575 -300.575
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
/* Address pattern of a specific marker */
String Marker1_address = "/vicon/marker/Object/Object1";
/* Address pattern of a specific marker */
String Marker2_address = "/vicon/marker/Object/Object2";
PVector Marker1_posiiton = new PVector(0,0,0);
void setup() {
size(1400,800);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,14000);
}
void draw() {
background(0);
stroke(255);
strokeWeight(10);
float newx = map(Marker1_posiiton.x, -3000,3000,0,1400);
float newy = map(Marker1_posiiton.y, -6000,6000,0,800);
point(newx,newy);
}
/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
/*find the message for a particular marker in the osc message*/
if(theOscMessage.checkAddrPattern(Marker1_address)==true) {
/* parse theOscMessage and extract the values from the osc message arguments. */
float XPOS = theOscMessage.get(0).floatValue();
float YPOS = theOscMessage.get(1).floatValue();
float ZPOS = theOscMessage.get(2).floatValue();
Marker1_posiiton = new PVector(XPOS,YPOS,ZPOS);
}
if(theOscMessage.checkAddrPattern(Marker2_address)==true) {
/* parse theOscMessage and extract the values from the osc message arguments. */
float XPOS = theOscMessage.get(0).floatValue();
float YPOS = theOscMessage.get(1).floatValue();
float ZPOS = theOscMessage.get(2).floatValue();
println(XPOS);
}
}