Processing and TUIO (Reactivision)
in
Contributed Library Questions
•
7 months ago
Hello everyone,
I am using the example given with the TUIO_Processing. I would like to ask you how is it possible to check the distance between all markers (tuio object). In the following example any tuio object found is represented as square with a number. I would like to check the distance between each one of them and for those that are closer than e.g. 10px create a much larger square containing them both. Any help is welcome! Thanks!
- // within the draw method we retrieve a Vector (List) of TuioObject and TuioCursor (polling)
- // from the TuioProcessing client and then loop over both lists to draw the graphical feedback.
- void draw()
- {
- background(255);
- textFont(font,18*scale_factor);
- float obj_size = object_size*scale_factor;
- float cur_size = cursor_size*scale_factor;
- Vector tuioObjectList = tuioClient.getTuioObjects();
- for (int i=0;i<tuioObjectList.size();i++) {
- TuioObject tobj = (TuioObject)tuioObjectList.elementAt(i);
- noStroke();
- fill(255,0,0,127);
- pushMatrix();
- translate(tobj.getScreenX(width),tobj.getScreenY(height));
- rotate(tobj.getAngle());
- rect(-obj_size/2,-obj_size/2,obj_size,obj_size);
- popMatrix();
- fill(255);
- text(""+tobj.getSymbolID(), tobj.getScreenX(width), tobj.getScreenY(height)); //object text
- }
- Vector tuioCursorList = tuioClient.getTuioCursors();
- for (int i=0;i<tuioCursorList.size();i++) {
- TuioCursor tcur = (TuioCursor)tuioCursorList.elementAt(i);
- Vector pointList = tcur.getPath();
- if (pointList.size()>0) {
- stroke(0,0,255);
- TuioPoint start_point = (TuioPoint)pointList.firstElement();;
- for (int j=0;j<pointList.size();j++) {
- TuioPoint end_point = (TuioPoint)pointList.elementAt(j);
- line(start_point.getScreenX(width),start_point.getScreenY(height),end_point.getScreenX(width),end_point.getScreenY(height));
- start_point = end_point;
- }
- stroke(192,192,192);
- fill(192,192,192);
- ellipse( tcur.getScreenX(width), tcur.getScreenY(height),cur_size,cur_size);
- fill(0);
- text(""+ tcur.getCursorID(), tcur.getScreenX(width)-5, tcur.getScreenY(height)+5);
- }
- }
- }
1