djiamnot / gdosc

OSC module for Godot game engine - it is now discontinued in favor of https://gitlab.com/frankiezafe/gdosc
Other
16 stars 1 forks source link

[proposition] Serialisation of standard types #5

Open frankiezafe opened 6 years ago

frankiezafe commented 6 years ago

In the idea of VVVV osc implementation, adding methods to pack and unpack vector2, vector3, vector4, quaternion, matrix3x3 and matrix4x4, with or without adding special types in the OSC messages.

For instance, you do:

var va = Vector3(1,2,3)
var vb = Vector3(4,5,6)
setAddress("/test")
appendV3(va)
appendV3(vb)

to send and to retrieve, you do:

var va = msg.getAsV3(0)
var vb = msg.getAsV3(3)

If no new types are added, the vectors and matrices are sent as an array of floats. Therefore, it is always possible to retrieve them by doing:

var x = msg.getAsFloat(0)
var y = msg.getAsFloat(1)
var z = msg.getAsFloat(2)

I did something like that in another implementation, and it is quite practical to serialise info from the 3d world.

djiamnot commented 6 years ago

Yeah, it's definitely worth it. Ultimately, it should support the OSC spec (http://opensoundcontrol.org/spec-1_0) and utility function specific for Godot are definitely useful, including serialization.

frankiezafe commented 6 years ago

sending part is done in OSCsender for vector2, vector3, quaternion and transform