This addon is Tuio1.1 wrapper for openframeworks.
https://www.tuio.org/?specification
It included samples are "server", "client" and "simulator".
ofxOsc
- include "ofxTuio.h" and instance the class
#include "ofxTuio.h"
class ofApp : public ofBaseApp{
void setup();
void update();
void draw();
//event notify classes
void tuioAdded(ofxTuioCursor & tuioCursor);
void tuioRemoved(ofxTuioCursor & tuioCursor);
void tuioUpdated(ofxTuioCursor & tuioCursor);
ofxTuioReceiver tuio;
- setup connect port and notify events
//set up port and chose protocol
tuio.setup(new ofxTuioUdpReceiver(3333));
//or tcp...
//tuio.setup(new ofxTuioTcpReceiver(3333));
//add event listener
ofAddListener(tuio.AddTuioCursor, this, &ofApp::tuioAdded);
ofAddListener(tuio.UpdateTuioCursor, this, &ofApp::tuioUpdated);
ofAddListener(tuio.RemoveTuioCursor, this, &ofApp::tuioRemoved);
//connect
tuio.connect();
- include "ofxTuio.h" and instance the class
#include "ofxTuio.h"
class ofApp : public ofBaseApp{
void setup();
void update();
void draw();
ofxTuioSender tuio;
//mouse click flag for just this example
bool isPress = false;
- setup protocol. address and port.
//setup address, port and server name. basically it is UDP protocol.
tuio.setup(new ofxTuioOscSender("127.0.0.1", 3333), "example");
//add protocol if you want
//tuio.addProtocol(new ofxTuioWebSocketSender(8080));
//tuio.addProtocol(new ofxTuioFlashSender());
//tuio.addProtocol(new ofxTuio::ofxTuioTcpSender(3333));
//auto calculate, fit to range 0.0 - 1.0. ofRectangle is screen size
tuio.setAutoFitRange(true, ofRectangle( 0, 0, 500, 500));
//starting position send
tuio.run();
- adding object. Object is you want send position between begin() - end().
tuio.begin();
{
float x = (float)ofGetMouseX(), y = (float)ofGetMouseY();
bool mouse = ofGetMousePressed(0);
//add object
if(mouse && !isPress){
isPress = true;
tuio.addObject(x, y);
}
//update object
if (isPress) tuio.updateObject(x, y);
//remove object
if (!mouse && isPress) {
isPress = false;
tuio.removeObject(x, y);
}
}
tuio.end();