Skip to content

Instantly share code, notes, and snippets.

@elliotwoods
Created July 2, 2016 02:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elliotwoods/8198b4d2803f457870b8a8ab854ecc69 to your computer and use it in GitHub Desktop.
Save elliotwoods/8198b4d2803f457870b8a8ab854ecc69 to your computer and use it in GitHub Desktop.
ofxMultiTrack test osc subscrier
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
this->receiver.setup(4444);
this->subscriber.setup("localhost", 2046);
{
ofxOscMessage message;
message.setAddress("/addClient");
//OPTIONAL : send to address (defaults to port it hears the 'addClient' message come from)
message.addInt32Arg(4444);
//OPTIONAL : send to address (defaults to address it hears the 'addClient' message come from)
//message.addStringArg("127.0.0.1");
this->subscriber.sendMessage(message);
}
}
//--------------------------------------------------------------
void ofApp::update(){
while (this->receiver.hasWaitingMessages()) {
ofxOscMessage message;
if (this->receiver.getNextMessage(message)) {
//print out all incoming messages to console
{
cout << message.getAddress() << " : ";
for (int i = 0; i < message.getNumArgs(); i++) {
cout << message.getArgTypeName(i) << " ";
}
cout << endl;
}
//handle messages about bodies
if (message.getAddress() == "/combined/bodies/indices") {
vector<int> bodyIndices;
for (int i = 0; i < message.getNumArgs(); i++) {
bodyIndices.push_back(message.getArgAsInt(i));
}
}
}
}
}
//--------------------------------------------------------------
void ofApp::draw(){
this->camera.begin();
{
}
this->camera.end();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include "ofxOsc.h"
class ofApp : public ofBaseApp{
struct Body {
map<string, ofVec3f> joints;
};
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxOscSender subscriber;
ofxOscReceiver receiver;
ofEasyCam camera;
map<int, Body> bodies;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment