HELP with TUIO cursor
Posted: 24 March 2014 04:40 AM   [ Ignore ]
Rank
Joined  2014-03-23
Total Posts:  1
New Member

I’m trying to make an app that does some blob tracking and sends all the data for Unity3D using TUIO cursor messages, just like CCV does.
This is what i have regarding the messages (”media” is a button to switch between sending all blob’s position/id’s or sending the average):

void testApp::blobOnint xint yint idint order )
        
{
            cout 
<< "blobOn() - id:" << id << " order:" << order << endl;
        
        
ofxOscMessage m;
        
m.setAddress("/tuio2/2Dcur");
        
m.addStringArg("set");
        
        if(
media == false){
            m
.addIntArg(id);
            
m.addFloatArg(newX);
            
m.addFloatArg(newY);
            
cout << "Posicao x: " << newX << endl;
            
cout << "Posicao y: " << newY << endl;
        
}
        else{
            m
.addIntArg(0);
            
m.addFloatArg(newMediaX);
            
m.addFloatArg(newMediaY);
        
}
        
        m
.addFloatArg(0);
        
m.addFloatArg(0);
        
m.addFloatArg(0);
        
m.addFloatArg(0);
        
        
ofxOscMessage l;
        
l.setAddress("/tuio/2Dcur");
        
l.addStringArg("alive");
        
        if (
blobList.size() > 0)
        
{
            
if(media == false){
                
for (std::map<int,blob>::iterator it=blobList.begin(); it!=blobList.end(); ++it){
                    l
.addIntArg(it -> first);
                    
cout << "it first: " << it -> first << endl;
                
}
        }else{
            l
.addIntArg(0);
            
}
        }
        
        sender
.sendMessage(l);
        
sender.sendMessage(m);
    
}
    
    
     
//--------------------------------------------------------------

        
    
    
void testApp::blobMovedint xint yint idint order)
    
{
        cout 
<< "blobMoved() - id:" << id << " order:" << order << endl;
        
        
ofCvTrackedBlob blob_ blobTracker.getByIdid );        
     
        
ofxOscMessage m;
        
m.setAddress("/tuio/2Dcur");
        
m.addStringArg("set");
        if(
media == false){
            m
.addIntArg(id);
            
m.addFloatArg(newX);
            
m.addFloatArg(newY);
            
cout << "Posicao x: " << newX << endl;
            
cout << "Posicao y: " << newY << endl;
        
}
        else{
            m
.addIntArg(0);
            
m.addFloatArg(newMediaX);
            
m.addFloatArg(newMediaY);
        
}
        
    
        m
.addFloatArg(0);
        
m.addFloatArg(0);
        
m.addFloatArg(0);
        
m.addFloatArg(0);
        
        
ofxOscMessage n;
        
n.setAddress("/tuio/2Dcur");
        
n.addStringArg("alive");
        
        if (
blobList.size() > 0)
        
{
            
            
if(media == false){
                
for (std::map<int,blob>::iterator it=blobList.begin(); it!=blobList.end(); ++it){
                    n
.addIntArg(it -> first);
                
}
            }
            
else {
                n
.addIntArg(0);
            
}
        }
            
        sender
.sendMessage(n);
        
sender.sendMessage(m);
    
}
    
        
    
//--------------------------------------------------------------
        
        
    
void testApp::blobOffint xint yint idint order )
    
{
        cout 
<< "blobOff() - id:" << id << " order:" << order << endl;
        
        
ofxOscMessage m;
        
m.setAddress("/tuio/2Dcur");
        
m.addStringArg("alive");
        
        
blobList.erase(id);
        
        
        if (
blobList.size() > 0)
        
{
            
if(media == false){
                
for (std::map<int,blob>::iterator it=blobList.begin(); it!=blobList.end(); ++it){
                    m
.addIntArg(it -> first);
                
}
            }
            
else {
                m
.addIntArg(0);
            
}
        }
            
        sender
.sendMessage(m);
    
}

My Unity app dont receive my messages/blobs, so i think they are badly formatted. Can someone tell me what may be wrong?

Profile