TUIObject

/*

Author

2004 - 2007

Till Bovermann 

Neuroinformatics Group 

Faculty of Technology 

Bielefeld University

Germany

*/


Abstract class. See

TUIObject.subclasses

for implementations.


A representation of a tangible user interface object (TUIO).

Used at [TUIO_OSCServer].

Each object change first sets the changed parameter slots to the new values and 

then calls 

TUIObject:update


Recognized TUIO types are


2Dobj

/tuio/2Dobj set <sessionID> ixyaXYAmr

/tuio/2Dobj alive [sessionID * #numberOfActiveObjects]


3Dobj

/tuio/3Dobj set <sessionID> ixyzabcXYZABCmr

/tuio/3Dobj alive [sessionID * #numberOfActiveObjects]


and a combination of

_[ixyzabcXYZABCmrP]


each object has

sessionID temporary object ID

i class ID

x,y,z position in [0..1]

a,b,c rotation in [0..2pi]

X,Y,Z velocity in float

A,B,C rot. velocity in float

m pos. acceleration

r rot. acceleration

P freely definable


// create a TUIObject, and use it to store messages coming from an [OSCReceiver]

t = TUIObject('2DObj', 4711);


r = OSCReceiver('/tuio/2Dobj', nil);

/*

r = OSCReceiver('/tuio/2Dobj', NetAddr("127.0.0.1", 57120));

*/

r.start;

OSCReceiverFunction(r, \set, {|sessionID, i, x, y, a, dX, dY, dA, m, r| 

[sessionID, i, x, y, a, dX, dY, dA, m, r].postln;

// t.id = sessionID; // not possible; id only settable at instantiation.

t.classID = i;

t.pos = [x,y,a];

t.velocity = [dX, dY, dA];

t.acceleration = [m,r];

});


// send some update messages

a = NetAddr("127.0.0.1", 57120);

a.sendMsg('/tuio/2Dobj', \set, 4711, 42, 0, 1, 2, 3, 4, 5, 6, 7);


(

(

("ID:\t"+t.id) + "\n" ++

("Class:\t"+t.classID) + "\n" ++

("Position:\t"+t.pos) + "\n" ++

("Velocity:\t"+t.velocity) + "\n" ++

("Acceleration:\t" +t.acceleration)

).postln;

)



//testing the parsing

(

var format;

var dict;

var object;


object = TUIObject.new(format);


dict = IdentityDictionary.new;


format = 'ixyzabcXYZABCmrPPP'.asString;

format.do{|item, i|

TUIObject.keyDict[item.asSymbol].value(object, i)

};


(

("ID:\t"+object.id) + "\n" ++

("Class:\t"+object.classID) + "\n" ++

("Position:\t"+object.pos) + "\n" ++

("Velocity:\t"+object.velocity) + "\n" ++

("Acceleration:\t" +object.acceleration)

).postln;

)