ofxTuio + coordinates of cursor

Hey all,

I am having a bit of a difficult time using the TUIO add on wrapper with oF, specifically I am trying to correlate the X/Y coordinate system to feedback (line).

Digging around the API, (http://www.tuio.org/?cpp) I felt my sketch was more then sufficient to achieve my goal, but when compiling the sketch (and it does initially compile fine without errors)

I crash the app when My line of code is implemented. Here is the section I am trying to integrate:

testApp.cpp:

  
  
//--------------------------------------------------------------  
void testApp::draw(){  
    tuioClient.drawCursors();  
    ofSetColor(0);  
    //line.draw();  
      
   // ofSetColor(255);  
    for (int i = 0; i < polylines.size(); i++)  
    {  
        polylines[i].draw();  
    }  
  
      
     
}  
  
void testApp::tuioAdded(ofxTuioCursor &tuioCursor ){  
	ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight());  
	cout << "Point n" << tuioCursor.getSessionId() << " add at " << loc << endl;  
      
      
      
      
}  
  
void testApp::tuioUpdated(ofxTuioCursor &tuioCursor){  
	ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight());  
	cout << "Point n" << tuioCursor.getSessionId() << " updated at " << loc << endl;  
      
  
//////////* THE FAULTY PORTION *//////////  
   polylines[polylines.size() - 1].addVertex(ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()) );  
    ofPolyline polyline;  
    polylines.push_back(polyline);  
      
    ////////////////////////////////  
}  
  
void testApp::tuioRemoved(ofxTuioCursor &tuioCursor){  
	ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight());  
	cout << "Point n" << tuioCursor.getSessionId() << " remove at " << loc << endl;  
      
    
      
  
  
      
  
      
}  
  

Hey danielJay,

You just need to move the following 2 lines from tuioUpdated, and move to tuioAdded to stop the crashing.
ofPolyline polyline;
polylines.push_back(polyline);

Also, the approach you’ve got will only work for a single touch. If you are making a multitouch app, you will need to keep track of the tuioCursors and their session ids. A simple way would be to use a map instead of a vector, then access/create polylines with the session id.

Thanks Trent, did the trick!

Also, this isn’t a multitouch application (but I do have plans to build an LLP table so any suggestions on software appreciated), but a single blob tracking application at night.

Cheers!