gravitacija-perspektive/danijela.scd

66 lines
1.1 KiB
Plaintext

// Namestitev
// SLIP -> OSC
Quarks.install("https://git.kompot.si/g1smo/SLIPDecoder.git");
// Quaternioni
Quarks.install("MathLib");
// Zlistaj serijske naprave
SerialPort.listDevices;
// Zacni
(
var receiver;
OSCFunc.trace(false);
~wwS = SLIPDecoder.new("/dev/ttyUSB0", 115200, "/ww/0");
~wwS.stop;
~wwS.start;
~eX = 0;
~eY = 0;
~eZ = 0;
~refQ = Quaternion.new();
~zadnjiQ = Quaternion.new(1, 0, 0, 0);
~gumbi = Array.fill(4, false);
// Pucamo star listener
thisProcess.removeOSCRecvFunc(~sprejemnik);
~sprejemnik = {|msg|
//msg.postln;
msg[0].switch(
'/ww/0/quaternion', {
var novQ, diffQ, euler;
//msg[(1..4)].postln;
"novQ!".postln;
novQ = Quaternion.new(*msg[(1..4)]);
//novQ.postln;
//(novQ * ~zadnjiQ.conjugate).postln;
diffQ = novQ / ~zadnjiQ.conjugate;
diffQ.postln;
~zadnjiQ = novQ;
}
);
};
thisProcess.addOSCRecvFunc(~sprejemnik);
)
(
~a = Quaternion(1, 0.5, 0.5, 0.5);
~b = Quaternion(1, 0.4, 0.6, 0.5);
(~a / Quaternion.new()).postln;
)
// Ustavi
~wwS.stop;
// Zacni
~wwS.start;
thisProcess.listOscRecvFunc();