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