From 023db85b1be156236e73e2a1773ba9fb29055b28 Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Wed, 16 Aug 2023 19:40:16 -0400 Subject: [PATCH] add ToMessage() for VmcExtDevicePos, fix a few typos --- VmcMessages/VmcExtDevicePos.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/VmcMessages/VmcExtDevicePos.cs b/VmcMessages/VmcExtDevicePos.cs index ace7df9..d6349f9 100644 --- a/VmcMessages/VmcExtDevicePos.cs +++ b/VmcMessages/VmcExtDevicePos.cs @@ -18,6 +18,7 @@ using Godot; using godotOscSharp; +using System.Collections.Generic; namespace godotVmcSharp { @@ -30,12 +31,12 @@ namespace godotVmcSharp { if (m.Data.Count != 8) { - GD.Print($"Invalid number of arguments for {base.addr}. Expected 8 or 14, received {m.Data.Count}."); + GD.Print($"Invalid number of arguments for {base.addr}. Expected 8, received {m.Data.Count}."); return; } if (m.Data[0].Type != 's') { - GD.Print(InvalidArgumentType.GetErrorString(addr, "name", 's', m.Data[0].Type)); + GD.Print(InvalidArgumentType.GetErrorString(addr, "serial", 's', m.Data[0].Type)); return; } if (m.Data[1].Type != 'f') @@ -82,5 +83,20 @@ namespace godotVmcSharp serial = _serial; transform = _transform; } + + public godotOscSharp.OscMessage ToMessage() + { + var quat = transform.Basis.GetRotationQuaternion(); + return new godotOscSharp.OscMessage(addr, new List{ + new godotOscSharp.OscArgument(serial, 's'), + new godotOscSharp.OscArgument(transform.Origin.X, 'f'), + new godotOscSharp.OscArgument(transform.Origin.Y, 'f'), + new godotOscSharp.OscArgument(transform.Origin.Z, 'f'), + new godotOscSharp.OscArgument(quat.X, 'f'), + new godotOscSharp.OscArgument(quat.Y, 'f'), + new godotOscSharp.OscArgument(quat.Z, 'f'), + new godotOscSharp.OscArgument(quat.W, 'f') + }); + } } } \ No newline at end of file