GMU:Tutorials/Networking/Controlling Processing with The Captury: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
Line 22: Line 22:
Data sending and receiving between the Captury and Processing over a network connection require OSC (Open Sound Control) protocol. The following is the anatomy of OSC in Processing.<br>
Data sending and receiving between the Captury and Processing over a network connection require OSC (Open Sound Control) protocol. The following is the anatomy of OSC in Processing.<br>
<br>
<br>
'''PART 01 – Connect the Captury and Processing'''
*To build a connection between the Captury and Processing, the listening port and the port of the remote location address need to be same. This could basically any number, and using a 4- or 5-digit number to stay out of the range of most common ports.
*To build a connection between the Captury and Processing, the listening port and the port of the remote location address need to be same. This could basically any number, and using a 4- or 5-digit number to stay out of the range of most common ports.
<source lang="Java" line start= "18">
<source lang="Java" line start= "18">
Line 37: Line 38:
remote = new NetAddress("kosmos.medien.uni-weimar.de", remoteport);
remote = new NetAddress("kosmos.medien.uni-weimar.de", remoteport);
</source>
</source>
<br>
 
'''PART 02 – Receive data from the Captury'''
*Inform Processing the name of the skeleton and the bone in use.  
*Inform Processing the name of the skeleton and the bone in use.  
<source lang="Java" line start= "25">
<source lang="Java" line start= "25">
Line 43: Line 45:
String bone1 = "Root";  //The bone in use  
String bone1 = "Root";  //The bone in use  
</source>
</source>
<br>
 
*capture all OSC events
<source lang="Java" line start= "78">
void oscEvent(OscMessage msg) {
  if(debug) {
    print("### received an osc message.");
    print(" addrpattern: "+msg.addrPattern());
    println(" typetag: "+msg.typetag());
  }
}
</source>
 
*To make sure that all the bone in use can be refreshed every second or so.
*To make sure that all the bone in use can be refreshed every second or so.
<source lang="Java" line start= "53">
refreshSubscriptions();
</source>
<source lang="Java" line start= "58">
<source lang="Java" line start= "58">
void refreshSubscriptions() {
void refreshSubscriptions() {
Line 53: Line 63:
}
}
</source>
</source>
<source lang="Java" line start= "71">
<source lang="Java" line start= "71">
if (frameCount % 10 == 0) {
if (frameCount % 10 == 0) {
Line 58: Line 69:
}
}
</source>
</source>
<source lang="Java" line start= "103">
<source lang="Java" line start= "103">
void subscribeBone(String skeletonId, String bone) {
void subscribeBone(String skeletonId, String bone) {
Line 68: Line 80:
</source>
</source>


*capture all OSC events
'''PART 03 – Pass data to the object'''
<source lang="Java" line start= "78">
void oscEvent(OscMessage msg) {
  if(debug) {
    print("### received an osc message.");
    print(" addrpattern: "+msg.addrPattern());
    println(" typetag: "+msg.typetag());
  }
}
</source>
 
*plug a specific bone
*plug a specific bone
<source lang="Java" line start= "88">
<source lang="Java" line start= "88">
Line 86: Line 88:
}
}
</source>
</source>
*objects in space
*objects in space
<source lang="Java" line start= "22">
<source lang="Java" line start= "22">
Line 93: Line 96:
sphere1 = new Sphere(1);
sphere1 = new Sphere(1);
</source>
</source>
*pass position of Asha's root bone to the first sphere object
*pass position of Asha's root bone to the first sphere object
<source lang="Java" line start= "50">
<source lang="Java" line start= "50">
Line 98: Line 102:
</source>
</source>


<source lang="Java">
'''PART 04 – Use the data as a variable'''
class Sphere {
*position of the sphere
  // position of the sphere
<source lang="Java" line start= "3">
  float x, y, z;
float x, y, z;
  Sphere( color c) {
    this.c = c;
  }
  // draw the sphere
  void draw() {
 
  }
  // update the position of the root node
  // (this function will be plugged to OSC) 
  public void updateRoot(float x, float y, float z) {
    this.x = map(x, 0, 100, -width/2, width/2);
    this.y = map(y, -100, 100, -height/2, height/2);
    this.z = map(z, 0, 100, 0, depth);}} 
</source>
</source>


<source lang="Java">
*update the position of the root node // (this function will be plugged to OSC) 
 
<source lang="Java" line start= "48">
public void updateRoot(float x, float y, float z) {
  this.x = map(x, 0, 100, -width/2, width/2);
  this.y = map(y, -100, 100, -height/2, height/2);
  this.z = map(z, 0, 100, 0, depth);
}
</source>
</source>
== Play The Video By Processing ==


'''PART 01 – ''' <br>


<source lang="Java">


== Play The Video By Processing ==
</source>


'''STEP 01 – ''' <br>


<br style="clear:both">
<br style="clear:both">