|
25
|
1 |
|
|
|
2 |
// add hooks |
|
|
3 |
(function(){ |
|
|
4 |
this.Processing.addTuioObject = undefined; |
|
|
5 |
this.Processing.updateTuioObject = undefined; |
|
|
6 |
this.Processing.removeTuioObject = undefined; |
|
|
7 |
this.Processing.addTuioCursor = undefined; |
|
|
8 |
this.Processing.updateTuioCursor = undefined; |
|
|
9 |
this.Processing.removeTuioCursor = undefined; |
|
27
|
10 |
this.Processing.addTuioString = undefined; |
|
|
11 |
this.Processing.updateTuioString = undefined; |
|
|
12 |
this.Processing.removeTuioString = undefined; |
|
25
|
13 |
})(); |
|
|
14 |
|
|
|
15 |
(function(){ |
|
|
16 |
|
|
|
17 |
var tuio = this.tuio; |
|
|
18 |
|
|
26
|
19 |
/* |
|
|
20 |
* Modifié par alexandre.bastien@iri.centrepompidou.fr |
|
|
21 |
*/ |
|
25
|
22 |
function wrapPath(d) { |
|
|
23 |
var i, len = d.path.length; |
|
|
24 |
var res = []; |
|
|
25 |
for (i=0; i<len; i++) { |
|
|
26 |
var pos = d.path[i]; |
|
|
27 |
res.push({ |
|
|
28 |
getX: function() { return pos[0]; }, |
|
|
29 |
getY: function() { return pos[1]; }, |
|
26
|
30 |
getZ: function() { return pos[2]; }, |
|
25
|
31 |
|
|
|
32 |
getScreenX: function(width) { return width * pos[0]; }, |
|
|
33 |
getScreenY: function(height) { return height * pos[1]; }, |
|
|
34 |
}); |
|
|
35 |
} |
|
|
36 |
return res; |
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
function wrapObject(d) { |
|
|
40 |
return { |
|
|
41 |
getSessionID: function() { return d.sid; }, |
|
|
42 |
getSymbolID: function() { return d.fid; }, |
|
|
43 |
getX: function() { return d.x; }, |
|
|
44 |
getY: function() { return d.y; }, |
|
|
45 |
getAngle: function() { return d.angle; }, |
|
|
46 |
|
|
|
47 |
getScreenX: function(width) { return width * d.x; }, |
|
|
48 |
getScreenY: function(height) { return height * d.y; }, |
|
|
49 |
|
|
|
50 |
getPath: function() { return wrapPath(d); }, |
|
|
51 |
}; |
|
|
52 |
} |
|
|
53 |
|
|
26
|
54 |
/* |
|
|
55 |
* Modifié par alexandre.bastien@iri.centrepompidou.fr |
|
|
56 |
*/ |
|
25
|
57 |
function wrapCursor(d) { |
|
|
58 |
return { |
|
|
59 |
getSessionID: function() { return d.sid; }, |
|
|
60 |
getCursorId: function() { return d.fid; }, |
|
|
61 |
getX: function() { return d.x; }, |
|
|
62 |
getY: function() { return d.y; }, |
|
26
|
63 |
getZ: function() { return d.z; }, |
|
25
|
64 |
|
|
|
65 |
getScreenX: function(width) { return width * d.x; }, |
|
|
66 |
getScreenY: function(height) { return height * d.y; }, |
|
|
67 |
|
|
|
68 |
getPath: function() { return wrapPath(d); }, |
|
26
|
69 |
getPosition: function() { return wrapPosition(d); }, |
|
|
70 |
}; |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
/* |
|
|
74 |
* Ajouté par alexandre.bastien@iri.centrepompidou.fr |
|
|
75 |
*/ |
|
|
76 |
function wrapPosition(d) { |
|
|
77 |
return { |
|
|
78 |
getX: function() { return d.x; }, |
|
|
79 |
getY: function() { return d.y; }, |
|
|
80 |
getZ: function() { return d.z; }, |
|
25
|
81 |
}; |
|
|
82 |
} |
|
|
83 |
|
|
27
|
84 |
/* |
|
|
85 |
* Ajouté par alexandre.bastien@iri.centrepompidou.fr |
|
|
86 |
*/ |
|
|
87 |
function wrapString(d) { |
|
|
88 |
return { |
|
|
89 |
getCode: function() { return d.code; }, |
|
|
90 |
}; |
|
|
91 |
} |
|
|
92 |
|
|
25
|
93 |
tuio.TuioProcessing = function(p) { |
|
|
94 |
var listener = new tuio.Listener({ |
|
|
95 |
object_add: function(d) { if (p.addTuioObject) p.addTuioObject(wrapObject(d)); }, |
|
|
96 |
object_update: function(d) { if (p.updateTuioObject) p.updateTuioObject(wrapObject(d)); }, |
|
|
97 |
object_remove: function(d) { if (p.removeTuioObject) p.removeTuioObject(wrapObject(d)); }, |
|
|
98 |
cursor_add: function(d) { if (p.addTuioCursor) p.addTuioCursor(wrapCursor(d)); }, |
|
|
99 |
cursor_update: function(d) { if (p.updateTuioCursor) p.updateTuioCursor(wrapCursor(d)); }, |
|
27
|
100 |
cursor_remove: function(d) { if (p.removeTuioCursor) p.removeTuioCursor(wrapCursor(d)); }, |
|
|
101 |
string_add: function(d) { if (p.addTuioString) p.addTuioString(wrapString(d)); }, |
|
|
102 |
string_update: function(d) { if (p.updateTuioString) p.updateTuioString(wrapString(d)); }, |
|
|
103 |
string_remove: function(d) { if (p.removeTuioString) p.removeTuioString(wrapString(d)); } |
|
25
|
104 |
}); |
|
|
105 |
tuio.addListener(listener); |
|
|
106 |
tuio.start(); |
|
|
107 |
}; |
|
|
108 |
|
|
|
109 |
tuio.TuioProcessing.prototype = { |
|
|
110 |
getTuioObjects: function() { |
|
|
111 |
var res = []; |
|
|
112 |
var i, len = tuio.objects.length; |
|
|
113 |
for (i=0; i<len; i++) { |
|
|
114 |
res.push(wrapObject(tuio.objects[i])); |
|
|
115 |
} |
|
|
116 |
return res; |
|
|
117 |
}, |
|
|
118 |
|
|
|
119 |
getTuioCursors: function() { |
|
|
120 |
var res = []; |
|
|
121 |
var i, len = tuio.cursors.length; |
|
|
122 |
for (i=0; i<len; i++) { |
|
|
123 |
res.push(wrapCursor(tuio.cursors[i])); |
|
|
124 |
} |
|
|
125 |
return res; |
|
27
|
126 |
}, |
|
|
127 |
|
|
|
128 |
getTuioStrings: function() { |
|
|
129 |
var res = []; |
|
|
130 |
var i, len = tuio.strings.length; |
|
|
131 |
for (i=0; i<len; i++) { |
|
|
132 |
res.push(wrapString(tuio.strings[i])); |
|
|
133 |
} |
|
|
134 |
return res; |
|
25
|
135 |
} |
|
|
136 |
}; |
|
|
137 |
|
|
|
138 |
})(); |
|
|
139 |
|