# HG changeset patch # User bastiena # Date 1333729933 -7200 # Node ID a7b0e40bcab0597ac713902af32637614e89f627 # Parent 2bdf5d51d434f8fb3d6d5e4917312209466a49b1 Front IDILL : Basic JS TUIO lib loaded diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-npTuioClient/TuioClient/TuioClient.cpp --- a/front_idill/extern/fajran-npTuioClient/TuioClient/TuioClient.cpp Fri Apr 06 11:48:00 2012 +0200 +++ b/front_idill/extern/fajran-npTuioClient/TuioClient/TuioClient.cpp Fri Apr 06 18:32:13 2012 +0200 @@ -189,7 +189,7 @@ delete *closestCursor; } else maxFingerID = f_id; //Modifié par alexandre.bastien@iri.centrepompidou.fr - TuioCursor *addCursor = new TuioCursor((long)s_id,f_id,xpos,ypos); + TuioCursor *addCursor = new TuioCursor((long)s_id,f_id,xpos,ypos,zpos); cursorList.push_back(addCursor); for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++) @@ -197,7 +197,7 @@ //Modifié par alexandre.bastien@iri.centrepompidou.fr } else if ( ((*tcur)->getX()!=xpos) || ((*tcur)->getY()!=ypos) || ((*tcur)->getZ()!=zpos) || ((*tcur)->getXSpeed()!=xspeed) || ((*tcur)->getYSpeed()!=yspeed) || ((*tcur)->getMotionAccel()!=maccel) ) { - (*tcur)->update(xpos,ypos,xspeed,yspeed,maccel); + (*tcur)->update(xpos,ypos,zpos,xspeed,yspeed,maccel); for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++) (*listener)->updateTuioCursor((*tcur)); } diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-npTuioClient/TuioClient/TuioPoint.h --- a/front_idill/extern/fajran-npTuioClient/TuioClient/TuioPoint.h Fri Apr 06 11:48:00 2012 +0200 +++ b/front_idill/extern/fajran-npTuioClient/TuioClient/TuioPoint.h Fri Apr 06 18:32:13 2012 +0200 @@ -108,22 +108,26 @@ return sqrtf(dx*dx+dy*dy+dz*dz); } + /* + * Modifié par alexandre.bastien@iri.centrepompidou.fr + */ float getDistance(TuioPoint *tuioPoint) { float dx = xpos-tuioPoint->getX(); float dy = ypos-tuioPoint->getY(); - return sqrtf(dx*dx+dy*dy); - } - - /* - * Ajouté par alexandre.bastien@iri.centrepompidou.fr - */ - float getDistance3D(TuioPoint *tuioPoint) { - float dx = xpos-tuioPoint->getX(); - float dy = ypos-tuioPoint->getY(); float dz = zpos-tuioPoint->getZ(); return sqrtf(dx*dx+dy*dy+dz*dz); } + /* + * Modifié par alexandre.bastien@iri.centrepompidou.fr + */ + /*float getDistance3D(TuioPoint *tuioPoint) { + float dx = xpos-tuioPoint->getX(); + float dy = ypos-tuioPoint->getY(); + float dz = zpos-tuioPoint->getZ(); + return sqrtf(dx*dx+dy*dy+dz*dz); + }*/ + float getAngle(TuioPoint *tuioPoint) { float side = tuioPoint->getX()-xpos; diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-npTuioClient/npTuioClient.aps Binary file front_idill/extern/fajran-npTuioClient/npTuioClient.aps has changed diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-npTuioClient/npTuioClient.sdf Binary file front_idill/extern/fajran-npTuioClient/npTuioClient.sdf has changed diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-npTuioClient/src/plugin.cpp --- a/front_idill/extern/fajran-npTuioClient/src/plugin.cpp Fri Apr 06 11:48:00 2012 +0200 +++ b/front_idill/extern/fajran-npTuioClient/src/plugin.cpp Fri Apr 06 18:32:13 2012 +0200 @@ -86,7 +86,7 @@ plugInitialized = TRUE; - tuio_start(3333); + tuio_start(80); return NPERR_NO_ERROR; } @@ -326,6 +326,7 @@ ss << event->data.fid << ", "; ss << event->data.x << ", "; ss << event->data.y << ", "; + ss << event->data.z << ", "; ss << event->data.a << ");"; NPN_GetURL(event->instance, ss.str().c_str(), "_self"); @@ -336,7 +337,7 @@ { D("[event] callback: type=" << data.type << ", sid=" << data.sid << ", fid=" << data.fid - << ", x=" << data.x << ", y=" << data.y << ", a=" << data.a); + << ", x=" << data.x << ", y=" << data.y << ", z=" << data.z << ", a=" << data.a); Event* ev = new Event(); ev->instance = _instance; diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/.gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/.gitignore Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,3 @@ +*.swp +*.pyc + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/LICENSE.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/LICENSE.txt Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,19 @@ +Copyright (c) 2009 Fajran Iman Rusadi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/README.md Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,15 @@ +TUIOjs +====== + +Javascript TUIO client library. + +This library uses a connector to receive the TUIO data. Currently, +there are two connectors available: + +* [npTuioClient](http://github.com/fajran/npTuioClient) based + connector. Check it's project page to see how it works. + +* Stomp based connector. This connector uses XHR to get events from a + [Stomp](http://stomp.codehaus.org/) server. + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/npTuioClient/tuiojs.npTuioClient.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/npTuioClient/tuiojs.npTuioClient.js Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,31 @@ + +tuio.setConnector({ + _failmsg: "Unable to initialize npTuioClient plugin.", + _id: "__tuiojs_connector_npTuioClient", + + start: function() { + var el = document.getElementById(this._id); + if (el == undefined) { + var el = document.createElement('object'); + el.setAttribute('id', this._id); + el.setAttribute('type', 'application/x-tuio'); + el.appendChild(document.createTextNode(this._failmsg)); + document.body.appendChild(el); + } + + // TODO: check if the plugin can be loaded. + // if so, hide the plugin (display:none). + }, + + stop: function() { + var el = document.getElementById(this._id); + if (el != undefined) { + document.body.removeChild(el); + } + } +}); + +function tuio_callback(type, sid, fid, x, y, angle) { + tuio.callback(type, sid, fid, x, y, angle); +} + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/stomp/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/stomp/README.md Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,27 @@ +TUIOjs +====== + +A TUIO gateway for javascript. + +Data flow +--------- + +The data flow can be illustrated more or less like the following. + + Tracker =[tuio]=> gateway => message queue =[stomp/http]=> browser. + +Requirements +------------ + +- [orbited](http://orbited.org/) +- [pytuio](http://code.google.com/p/pytuio/) +- [stompy](http://code.google.com/p/stomppy/) +- [jquery](http://jquery.org) +- a fast browser. Tested with safari 4 on mac os x tiger. + +Screencast +---------- + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/stomp/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/stomp/index.html Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,80 @@ + + + + + + + + +
+
+ diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/stomp/orbited.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/stomp/orbited.cfg Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,12 @@ +[listen] +http://:9000 +stomp://:61613 + +[access] +* -> localhost:61613 + +[static] +graph=index.html + +[global] +session.ping_interval = 300 diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/stomp/tuio-gateway.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/stomp/tuio-gateway.py Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,58 @@ +import tuio +import stomp + +s = stomp.Connection() +s.start() +s.connect() + +cnt = 0 + +current = [] +ld = {} + +t = tuio.Tracking() +try: + while True: + t.update() + + active = [] + for c in t.cursors(): + active.append(c.sessionid) + + tbr = [] + for c in current: + if c not in active: + tbr.append(c) + + tba = [] + for c in active: + if c not in current: + tba.append(c) + + current = active + + for c in tbr: + d = ld[c] + # cursor removed = 5 + s.send("5 %d %d %f %f 0" % (c, c, d[1], d[2]), destination="/topic/home") + ld.pop(c) + + # for c in tba: + # s.send("C N %d" % c, destination="/topic/home") + + for c in t.cursors(): + data = (c.sessionid, c.sessionid, c.xpos, c.ypos) + if not ld.get(c.sessionid, None) == data: + if c.sessionid in tba: + # cursor new = 3 + msg = "3 %d %d %f %f 0" % data + else: + # cursor update = 4 + msg = "4 %d %d %f %f 0" % data + s.send(msg, destination="/topic/home") + ld[c.sessionid] = data + cnt += 1 + +except KeyboardInterrupt: + t.stop() + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/connector/stomp/tuio.stomp.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/connector/stomp/tuio.stomp.js Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,49 @@ + +tuio.setConnector({ + _host: 'localhost', + _port: 61613, + _user: 'guest', + _pass: 'guest', + _topic: '/topic/home', + + _client: undefined, + + start: function() { + var self = this; + var sc = new STOMPClient(); + self._client = sc; + + sc.onopen = function() { + } + sc.onclose = function(code) { + } + sc.onerror = function(err) { + } + sc.onerrorframe = function(frame) { + } + sc.onconnectedframe = function() { + sc.subscribe(self._topic, {exchange:''}); + } + sc.onmessageframe = function(frame) { + self._process(frame.body.split(" ")); + } + setTimeout(function() { + sc.connect(self._host, self._port, self._user, self._pass); + }, 10); + }, + + stop: function() { + this._client.reset(); + }, + + _process: function(data) { + var type = parseInt(data[0]); + var sid = parseInt(data[1]); + var fid = parseInt(data[2]); + var x = parseFloat(data[3]); + var y = parseFloat(data[4]); + var angle = parseFloat(data[5]); + + tuio.callback(type, sid, fid, x, y, angle); + } +}); diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/dump.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/dump.html Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,48 @@ + + + + + + + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/fire.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/fire.html Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,74 @@ + + +TUIO Client plugin test + + + + + + + + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/log.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/log.js Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,23 @@ + +var logs = []; +var max = 20; + +function updateLog() { + if (logs.length > max) { + logs = logs.splice(logs.length - max); + } + + var text = logs.join("\n"); + document.getElementById('log').innerHTML = text; +} + +function log(msg) { + if (console.log) { + console.log(msg); + } + else { + logs.push(msg); + updateLog(); + } +} + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/paint.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/paint.html Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,54 @@ + + +TUIO Client plugin test + + + + + + + + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/processingjs/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/processingjs/README.txt Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,6 @@ +Before you can start using the examples, download the processingjs and +its initialization script first. Put them inside this directory. + +- http://github.com/jeresig/processing-js/raw/master/processing.js +- http://github.com/jeresig/processing-js/raw/master/examples/init.js + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/processingjs/paint.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/processingjs/paint.html Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/examples/processingjs/tuio.processing.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/examples/processingjs/tuio.processing.js Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,95 @@ + +// add hooks +(function(){ +this.Processing.addTuioObject = undefined; +this.Processing.updateTuioObject = undefined; +this.Processing.removeTuioObject = undefined; +this.Processing.addTuioCursor = undefined; +this.Processing.updateTuioCursor = undefined; +this.Processing.removeTuioCursor = undefined; +})(); + +(function(){ + +var tuio = this.tuio; + +function wrapPath(d) { + var i, len = d.path.length; + var res = []; + for (i=0; i + +TUIO Client plugin test + + + + + + + + + + + diff -r 2bdf5d51d434 -r a7b0e40bcab0 front_idill/extern/fajran-tuiojs/src/tuio.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_idill/extern/fajran-tuiojs/src/tuio.js Fri Apr 06 18:32:13 2012 +0200 @@ -0,0 +1,148 @@ + +(function() { + var TUIO = function() { + // Listener class + + this.Listener = function(impl) { + if (impl != undefined) { + // override original method implementation + for (var key in impl) { + this[key] = impl[key]; + } + } + } + this.Listener.prototype = { + object_add: function(data) { }, + object_update: function(data) { }, + object_remove: function(data) { }, + cursor_add: function(data) { }, + cursor_update: function(data) { }, + cursor_remove: function(data) { } + } + + // Instance variables + + this.objects = []; + this.cursors = []; + + this._data = {}; + + this._default_listener = new this.Listener(); + this._listeners = [this._default_listener]; + + this._connector = undefined; + + }; + TUIO.prototype = { + start: function(name) { + var c = this._connector; + if (c != undefined) { + if (c.start != undefined) { + c.start(); + } + } + }, + + stop: function() { + var c = this._connector; + if (c != undefined) { + if (c.stop != undefined) { + c.stop(); + } + } + }, + + setConnector: function(connector) { + this._connector = connector; + }, + + addListener: function(listener) { + this._listeners.push(listener); + }, + removeListener: function(listener) { + this._listeners.splice(this._listeners.indexOf(listener), 1); + }, + + _invoke: function(method, data) { + var i, len = this._listeners.length; + for (i=0; i