diff -r 11234537653b -r 92f19af39024 front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java Fri Mar 09 18:15:12 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java Thu Mar 15 13:33:21 2012 +0100 @@ -38,6 +38,8 @@ */ public class TuioClient implements OSCListener { + public String comm; + private int port = 3333; private OSCPortIn oscPort; private boolean connected = false; @@ -47,13 +49,20 @@ private Hashtable cursorList = new Hashtable(); private Vector aliveCursorList = new Vector(); private Vector newCursorList = new Vector(); + private Hashtable stringList = new Hashtable(); + private Vector aliveStringList = new Vector(); + private Vector newStringList = new Vector(); private Vector frameObjects = new Vector(); private Vector frameCursors = new Vector(); + private Vector frameStrings = new Vector(); private Vector freeCursorList = new Vector(); private int maxCursorID = -1; + private Vector freeStringList = new Vector(); + private int maxStringID = -1; + private long currentFrame = 0; private TuioTime currentTime; @@ -86,7 +95,8 @@ try { oscPort = new OSCPortIn(port); oscPort.addListener("/tuio/2Dobj",this); - oscPort.addListener("/tuio/2Dcur",this); + oscPort.addListener("/tuio/3Dcur",this); + oscPort.addListener("/tuio/_siP",this); oscPort.startListening(); connected = true; } catch (Exception e) { @@ -153,7 +163,16 @@ */ public Vector getTuioCursors() { return new Vector(cursorList.values()); - } + } + + /** + * Returns a Vector of all currently active TuioStrings + * + * @return a Vector of all currently active TuioStrings + */ + public Vector getTuioStrings() { + return new Vector(stringList.values()); + } /** * Returns the TuioObject corresponding to the provided Session ID @@ -173,6 +192,16 @@ */ public TuioCursor getTuioCursor(long s_id) { return cursorList.get(s_id); + } + + /** + * Returns the TuioString corresponding to the provided Session ID + * or NULL if the Session ID does not refer to an active TuioString + * + * @return an active TuioString corresponding to the provided Session ID or NULL + */ + public TuioString getTuioString(long s_id) { + return stringList.get(s_id); } /** @@ -305,30 +334,31 @@ } frameObjects.clear(); } - } else if (address.equals("/tuio/2Dcur")) { + } else if (address.equals("/tuio/3Dcur")) { if (command.equals("set")) { long s_id = ((Integer)args[1]).longValue(); float xpos = ((Float)args[2]).floatValue(); float ypos = ((Float)args[3]).floatValue(); - float xspeed = ((Float)args[4]).floatValue(); - float yspeed = ((Float)args[5]).floatValue(); - float maccel = ((Float)args[6]).floatValue(); + float zpos = ((Float)args[4]).floatValue(); + float xspeed = ((Float)args[5]).floatValue(); + float yspeed = ((Float)args[6]).floatValue(); + float maccel = ((Float)args[7]).floatValue(); if (cursorList.get(s_id) == null) { - TuioCursor addCursor = new TuioCursor(s_id, -1 ,xpos,ypos); + TuioCursor addCursor = new TuioCursor(s_id, -1 ,xpos,ypos,zpos); frameCursors.addElement(addCursor); } else { TuioCursor tcur = cursorList.get(s_id); if (tcur==null) return; - if ((tcur.xpos!=xpos) || (tcur.ypos!=ypos) || (tcur.x_speed!=xspeed) || (tcur.y_speed!=yspeed) || (tcur.motion_accel!=maccel)) { + if ((tcur.xpos!=xpos) || (tcur.ypos!=ypos) || (tcur.zpos!=zpos) || (tcur.x_speed!=xspeed) || (tcur.y_speed!=yspeed) || (tcur.motion_accel!=maccel)) { - TuioCursor updateCursor = new TuioCursor(s_id,tcur.getCursorID(),xpos,ypos); - updateCursor.update(xpos,ypos,xspeed,yspeed,maccel); + TuioCursor updateCursor = new TuioCursor(s_id,tcur.getCursorID(),xpos,ypos,zpos); + updateCursor.update(xpos,ypos,zpos,xspeed,yspeed,maccel); frameCursors.addElement(updateCursor); } } @@ -420,7 +450,7 @@ freeCursorList.removeElement(closestCursor); } else maxCursorID = c_id; - TuioCursor addCursor = new TuioCursor(currentTime,tcur.getSessionID(),c_id,tcur.getX(),tcur.getY()); + TuioCursor addCursor = new TuioCursor(currentTime,tcur.getSessionID(),c_id,tcur.getX(),tcur.getY(),tcur.getZ()); cursorList.put(addCursor.getSessionID(),addCursor); for (int i=0;i0) { + if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); + if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq; + else lateFrame = true; + } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { + currentTime = TuioTime.getSessionTime(); + } + if (!lateFrame) { + + Enumeration frameEnum = frameStrings.elements(); + while(frameEnum.hasMoreElements()) { + TuioString tstr = frameEnum.nextElement(); + + switch (tstr.getTuioState()) { + case TuioString.TUIO_REMOVED: + + TuioString removeString = tstr; + removeString.remove(currentTime); + + for (int i=0;i0) { + Enumeration slist = stringList.elements(); + while (slist.hasMoreElements()) { + int sl_id = slist.nextElement().getStringID(); + if (sl_id>maxStringID) maxStringID=sl_id; + } + + Enumeration flist = freeStringList.elements(); + while (flist.hasMoreElements()) { + int sl_id = flist.nextElement().getStringID(); + if (sl_id>=maxStringID) freeStringList.removeElement(sl_id); + } + } else freeStringList.clear(); + } else if (removeString.getStringID()0)) { + TuioString closestString = freeStringList.firstElement(); + Enumeration testList = freeStringList.elements(); + while (testList.hasMoreElements()) { + TuioString testString = testList.nextElement(); + //if (testString.getDistance(tstr) buffer = aliveStringList; + aliveStringList = newStringList; + // recycling the vector + newStringList = buffer; + } + + frameStrings.clear(); + } } + + } }