feat!: add exceptions and support type safe getting OscArgument values

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-10-21 09:15:37 -04:00
parent 9201215b06
commit 87d903619e
31 changed files with 517 additions and 1126 deletions

View File

@ -0,0 +1,17 @@
using System;
using godotOscSharp;
namespace godotVmcSharp
{
public class DataOutOfRangeException : ArgumentOutOfRangeException
{
public DataOutOfRangeException(String address, int index, String name, String expected, object actual): base($"{address}[{index}] {name}", actual, expected)
{}
public DataOutOfRangeException(String address, int index, String name, String expected, object actual, Exception inner): base($"{address}[{index}] {name} has data out of range. Received '{actual}', expected within range '{expected}'.", inner)
{}
public DataOutOfRangeException(OscAddress address, int index, String name, String expected, object actual): base($"{address.ToString()}[{index}] {name}", actual, expected)
{}
public DataOutOfRangeException(OscAddress address, int index, String name, String expected, object actual, Exception inner): base($"{address.ToString()}[{index}] {name} has data out of range. Received '{actual}', expected within range '{expected}'.", inner)
{}
}
}

View File

@ -0,0 +1,16 @@
using System;
using godotOscSharp;
namespace godotVmcSharp
{
public class MissingArgumentsException : ArgumentNullException
{
public MissingArgumentsException() : base("Missing parameters.") {}
public MissingArgumentsException(String message): base(message) {}
public MissingArgumentsException(String message, Exception inner): base(message, inner) {}
public MissingArgumentsException(String address, String expected, int actual) : base($"{address}", "Missing parameters: expecting {expected}, received {actual}.") {}
public MissingArgumentsException(String address, String expected, int actual, Exception inner) : base($"Missing parameters for {address}: expecting {expected}, received {actual}.", inner) {}
public MissingArgumentsException(OscAddress address, String expected, int actual) : base($"{address.ToString()}", "Missing parameters: expecting {expected}, received {actual}.") {}
public MissingArgumentsException(OscAddress address, String expected, int actual, Exception inner) : base($"Missing parameters for {address.ToString()}: expecting {expected}, received {actual}.", inner) {}
}
}

View File

@ -1,32 +0,0 @@
/*
godotVmcSharp
Copyright (C) 2023 Cassandra de la Cruz-Munoz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace godotVmcSharp
{
public class InvalidArgumentType
{
public static string GetErrorString(string address, string name, char expected, char actual)
{
return $"Invalid argument type for argument \"{name}\" of \"{address}\". Expected {expected}, received {actual}.";
}
public static string GetErrorString(godotOscSharp.OscAddress address, string name, char expected, char actual)
{
return GetErrorString(address.ToString(), name, expected, actual);
}
}
}

View File

@ -20,12 +20,14 @@ using System.Net;
using godotOscSharp;
using Godot;
#nullable enable
namespace godotVmcSharp
{
public class Marionette
{
private OscReceiver receiver;
private OscSender sender;
private OscSender? sender;
private CameraReceiver cam;
private DeviceReceiver devices;
private DirectionalLightReceiver lights;
@ -55,40 +57,40 @@ namespace godotVmcSharp
switch (m.Address.ToString())
{
case "/VMC/Ext/OK":
new VmcExtOk(m);
VmcExtOk.CreateFromMessage(m);
break;
case "/VMC/Ext/T":
new VmcExtT(m);
VmcExtT.CreateFromMessage(m);
break;
case "/VMC/Ext/Root/Pos":
new VmcExtRootPos(m);
VmcExtRootPos.CreateFromMessage(m);
break;
case "/VMC/Ext/Bone/Pos":
new VmcExtBonePos(m);
VmcExtBonePos.CreateFromMessage(m);
break;
case "/VMC/Ext/Blend/Val":
new VmcExtBlendVal(m);
VmcExtBlendVal.CreateFromMessage(m);
break;
case "/VMC/Ext/Blend/Apply":
new VmcMessage(m.Address);
break;
case "/VMC/Ext/Cam":
this.cam.ProcessMessage(new VmcExtCam(m));
this.cam.ProcessMessage(VmcExtCam.CreateFromMessage(m));
break;
case "/VMC/Ext/Con":
new VmcExtCon(m);
VmcExtCon.CreateFromMessage(m);
break;
case "/VMC/Ext/Key":
new VmcExtKey(m);
VmcExtKey.CreateFromMessage(m);
break;
case "/VMC/Ext/Midi/Note":
new VmcExtMidiNote(m);
VmcExtMidiNote.CreateFromMessage(m);
break;
case "/VMC/Ext/Midi/CC/Val":
new VmcExtMidiCcVal(m);
VmcExtMidiCcVal.CreateFromMessage(m);
break;
case "/VMC/Ext/Midi/CC/Bit":
new VmcExtMidiCcBit(m);
VmcExtMidiCcBit.CreateFromMessage(m);
break;
case "/VMC/Ext/Hmd/Pos":
case "/VMC/Ext/Con/Pos":
@ -96,31 +98,31 @@ namespace godotVmcSharp
case "/VMC/Ext/Hmd/Pos/Local":
case "/VMC/Ext/Con/Pos/Local":
case "/VMC/Ext/Tra/Pos/Local":
this.devices.ProcessMessage(new VmcExtDevicePos(m));
this.devices.ProcessMessage(VmcExtDevicePos.CreateFromMessage(m));
break;
case "/VMC/Ext/Rcv":
new VmcExtRcv(m);
VmcExtRcv.CreateFromMessage(m);
break;
case "/VMC/Ext/Light":
this.lights.ProcessMessage(new VmcExtLight(m));
this.lights.ProcessMessage(VmcExtLight.CreateFromMessage(m));
break;
case "/VMC/Ext/VRM":
new VmcExtVrm(m);
VmcExtVrm.CreateFromMessage(m);
break;
case "/VMC/Ext/Remote":
new VmcExtRemote(m);
VmcExtRemote.CreateFromMessage(m);
break;
case "/VMC/Ext/Opt":
new VmcExtOpt(m);
VmcExtOpt.CreateFromMessage(m);
break;
case "/VMC/Ext/Setting/Color":
new VmcExtSettingColor(m);
VmcExtSettingColor.CreateFromMessage(m);
break;
case "/VMC/Ext/Setting/Win":
new VmcExtSettingWin(m);
VmcExtSettingWin.CreateFromMessage(m);
break;
case "/VMC/Ext/Config":
new VmcExtConfig(m);
VmcExtConfig.CreateFromMessage(m);
break;
}
}

View File

@ -55,46 +55,46 @@ namespace godotVmcSharp
case "/VMC/Ext/Hmd/Pos":
case "/VMC/Ext/Con/Pos":
case "/VMC/Ext/Tra/Pos":
this.devices.ProcessMessage(new VmcExtDevicePos(m));
this.devices.ProcessMessage(VmcExtDevicePos.CreateFromMessage(m));
break;
case "/VMC/Ext/Set/Period":
new VmcExtSetPeriod(m);
VmcExtSetPeriod.CreateFromMessage(m);
break;
case "/VMC/Ext/Midi/CC/Val":
new VmcExtMidiCcVal(m);
VmcExtMidiCcVal.CreateFromMessage(m);
break;
case "/VMC/Ext/Cam":
this.cam.ProcessMessage(new VmcExtCam(m));
this.cam.ProcessMessage(VmcExtCam.CreateFromMessage(m));
break;
case "/VMC/Ext/Blend/Val":
new VmcExtBlendVal(m);
VmcExtBlendVal.CreateFromMessage(m);
break;
case "/VMC/Ext/Blend/Apply":
new VmcMessage(m.Address);
break;
case "/VMC/Ext/Set/Eye":
new VmcExtSetEye(m);
VmcExtSetEye.CreateFromMessage(m);
break;
case "/VMC/Ext/Set/Req":
new VmcMessage(m.Address);
break;
case "/VMC/Ext/Set/Res":
new VmcExtSetRes(m);
VmcExtSetRes.CreateFromMessage(m);
break;
case "/VMC/Ext/Set/Calib/Ready":
new VmcMessage(m.Address);
break;
case "/VMC/Ext/Set/Calib/Exec":
new VmcExtSetCalibExec(m);
VmcExtSetCalibExec.CreateFromMessage(m);
break;
case "/VMC/Ext/Set/Config":
new VmcExtSetConfig(m);
VmcExtSetConfig.CreateFromMessage(m);
break;
case "/VMC/Ext/Light":
this.lights.ProcessMessage(new VmcExtLight(m));
this.lights.ProcessMessage(VmcExtLight.CreateFromMessage(m));
break;
case "/VMC/Ext/Set/Shortcut":
new VmcExtSetShortcut(m);
VmcExtSetShortcut.CreateFromMessage(m);
break;
}
}

View File

@ -16,92 +16,83 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
using System;
#nullable enable
namespace godotVmcSharp
{
public class VmcExtBlendVal : VmcMessage
{
public readonly string Name;
public readonly string? Name;
public readonly float Value;
public VmcExtBlendVal(OscMessage m) : base(m.Address)
public static VmcExtBlendVal CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 2)
if (m.Data.Count <= 2)
{
GD.Print($"Invalid number of arguments for /VMC/Ext/Blend/Val. Expected 2, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "2", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[0].Type));
return;
var blendShape = m.Data[0].GetAsString();
var value = m.Data[1].GetAsFloat();
if (value < 0 || value > 1) {
throw new DataOutOfRangeException(m.Address, 1, "value", "0 <= value <= 1", value);
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "value", 'f', m.Data[1].Type));
return;
}
var blendShape = (string)m.Data[0].Value;
if (IsVrm0BlendShape(blendShape))
{
Name = blendShape;
Value = (float)m.Data[1].Value;
return;
return new VmcExtBlendVal(blendShape, value);
}
if (IsVrm1Expression(blendShape))
{
Name = blendShape;
Value = (float)m.Data[1].Value;
return;
return new VmcExtBlendVal(blendShape, value);
}
if (IsArkitBlendShape(blendShape))
{
Name = blendShape;
Value = (float)m.Data[1].Value;
return;
return new VmcExtBlendVal(blendShape, value);
}
GD.Print($"Invalid argument for {Addr}. BlendShape \"{blendShape}\" not in list.");
throw new DataOutOfRangeException(m.Address, 0, "name", "name in valid blendshape names", blendShape);
}
public VmcExtBlendVal(string name, float value) : base(new OscAddress("VMC/Ext/Blend/Val"))
public static VmcExtBlendVal CreateFromParams(string name, float value)
{
if (value < 0 || value > 1) {
throw new DataOutOfRangeException("VMC/Ext/Blend/Val", 1, "value", "0 <= value <= 1", value);
}
if (IsVrm0BlendShape(name))
{
Name = name;
Value = value;
return;
return new VmcExtBlendVal(name, value);
}
if (IsVrm1Expression(name))
{
Name = name;
Value = value;
return;
return new VmcExtBlendVal(name, value);
}
if (IsArkitBlendShape(name))
{
Name = name;
Value = value;
return;
return new VmcExtBlendVal(name, value);
}
GD.Print($"Invalid argument for {Addr}. BlendShape \"{name}\" not in list.");
throw new DataOutOfRangeException("VMC/Ext/Blend/Val", 0, "name", "name in valid blendshape names", name);
}
private bool IsVrm0BlendShape(string name)
private VmcExtBlendVal(String name, float value): base(new OscAddress("VMC/Ext/Blend/Val")) {
Name = name;
Value = value;
}
private static bool IsVrm0BlendShape(string name)
{
return name == "Joy" || name == "Angry" || name == "Sorrow" || name == "Fun" ||
name == "A" || name == "I" || name == "U" || name == "E" || name == "O" ||
name == "Blink_L" || name == "Blink_R";
}
private bool IsVrm1Expression(string name)
private static bool IsVrm1Expression(string name)
{
return name == "happy" || name == "angry" || name == "sad" || name == "relaxed" ||
name == "aa" || name == "ih" || name == "ou" || name == "ee" || name == "oh" ||
name == "blinkLeft" || name == "blinkRight";
}
private bool IsArkitBlendShape(string name)
private static bool IsArkitBlendShape(string name)
{
return name == "browInnerUp" ||
name == "browDownLeft" || name == "browDownRight" ||
@ -135,9 +126,9 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument> {
new OscArgument(Name, 's'),
new OscArgument(Value, 'f')
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Value, 'f')!
});
}
}
}
}

View File

@ -26,55 +26,13 @@ namespace godotVmcSharp
public readonly string Name;
public readonly Transform3D Transform;
public VmcExtBonePos(OscMessage m) : base(m.Address)
public static VmcExtBonePos CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 8)
if (m.Data.Count < 8)
{
GD.Print($"Invalid number of arguments for {Addr}. Expected 8, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "8", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', m.Data[3].Type));
return;
}
if (m.Data[4].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.x", 'f', m.Data[4].Type));
return;
}
if (m.Data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.y", 'f', m.Data[5].Type));
return;
}
if (m.Data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.z", 'f', m.Data[6].Type));
return;
}
if (m.Data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.w", 'f', m.Data[7].Type));
return;
}
Name = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
return new VmcExtBonePos((string)m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())));
}
public VmcExtBonePos(string name, Transform3D transform) : base(new OscAddress("/VMC/Ext/Bone/Pos"))
@ -87,15 +45,15 @@ namespace godotVmcSharp
{
var quat = Transform.Basis.GetRotationQuaternion();
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Name, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f'),
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!,
});
}
}
}
}

View File

@ -28,61 +28,13 @@ namespace godotVmcSharp
public readonly Transform3D Transform;
public readonly float Fov;
public VmcExtCam(OscMessage m) : base(m.Address)
public static VmcExtCam CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 9)
if (m.Data.Count < 9)
{
GD.Print($"Invalid number of arguments for /VMC/Ext/Cam. Expected 9, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "9", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', m.Data[3].Type));
return;
}
if (m.Data[4].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.x", 'f', m.Data[4].Type));
return;
}
if (m.Data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.y", 'f', m.Data[5].Type));
return;
}
if (m.Data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.z", 'f', m.Data[6].Type));
return;
}
if (m.Data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.w", 'f', m.Data[7].Type));
return;
}
if (m.Data[8].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString("VMC/Ext/Cam", "fov", 'f', m.Data[8].Type));
return;
}
Name = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
Fov = (float)m.Data[8].Value;
return new VmcExtCam(m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())), m.Data[8].GetAsFloat());
}
public VmcExtCam(string name, Transform3D transform, float fov) : base(new OscAddress("/VMC/Ext/Cam"))
@ -96,15 +48,15 @@ namespace godotVmcSharp
{
var quat = Transform.Basis.GetRotationQuaternion();
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Name, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f'),
new OscArgument(Fov, 'f')
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!,
OscArgument.CreateFromParams(Fov, 'f')!
});
}
}

View File

@ -30,67 +30,31 @@ namespace godotVmcSharp
public readonly int IsAxis;
public readonly Vector3 Axis;
public VmcExtCon(OscMessage m) : base(m.Address)
public static VmcExtCon CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 8)
if (m.Data.Count < 8)
{
GD.Print($"Invalid number of arguments for /VMC/Ext/Con. Expected 8, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "8", m.Data.Count);
}
if (m.Data[0].Type != 'i')
var active = m.Data[0].GetAsInt32();
if (active < 0 || active > 2)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "active", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 0, "active", "{0, 1, 2}", active);
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "IsLeft", 'i', m.Data[2].Type));
}
if (m.Data[3].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "IsTouch", 'i', m.Data[3].Type));
}
if (m.Data[4].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "IsAxis", 'i', m.Data[4].Type));
}
if (m.Data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "Axis.x", 'f', m.Data[5].Type));
}
if (m.Data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "Axis.y", 'f', m.Data[6].Type));
}
if (m.Data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "Axis.z", 'f', m.Data[7].Type));
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 2)
{
GD.Print($"Invalid value for \"active\" 'i' argument of /VMC/Ext/Con. Expected 0-2, received {(int)m.Data[0].Value}");
return;
}
Active = (int)m.Data[0].Value;
Name = (string)m.Data[1].Value;
IsLeft = (int)m.Data[2].Value;
IsTouch = (int)m.Data[3].Value;
IsAxis = (int)m.Data[4].Value;
Axis = new Vector3((float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value);
return new VmcExtCon(active, m.Data[1].GetAsString(), m.Data[2].GetAsInt32(), m.Data[3].GetAsInt32(), m.Data[4].GetAsInt32(), new Vector3(m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat()));
}
public VmcExtCon(int active, string name, int isLeft, int isTouch, int isAxis, Vector3 axis) : base(new OscAddress("/VMC/Ext/Con"))
public static VmcExtCon CreateFromParams(int active, string name, int isLeft, int isTouch, int isAxis, Vector3 axis)
{
if (active < 0 || active > 2)
{
GD.Print($"Invalid value for \"active\" 'i' argument of {Addr}. Expected 0-2, received {active}");
return;
throw new DataOutOfRangeException("/VMC/Ext/Con", 0, "active", "{0, 1, 2}", active);
}
return new VmcExtCon(active, name, isLeft, isTouch, isAxis, axis);
}
private VmcExtCon(int active, string name, int isLeft, int isTouch, int isAxis, Vector3 axis) : base(new OscAddress("/VMC/Ext/Con"))
{
Active = active;
Name = name;
IsLeft = isLeft;
@ -99,18 +63,19 @@ namespace godotVmcSharp
Axis = axis;
}
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Active, 'i'),
new OscArgument(Name, 's'),
new OscArgument(IsLeft, 'i'),
new OscArgument(IsTouch, 'i'),
new OscArgument(IsAxis, 'i'),
new OscArgument(Axis.X, 'i'),
new OscArgument(Axis.Y, 'i'),
new OscArgument(Axis.Z, 'i'),
OscArgument.CreateFromParams(Active, 'i')!,
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(IsLeft, 'i')!,
OscArgument.CreateFromParams(IsTouch, 'i')!,
OscArgument.CreateFromParams(IsAxis, 'i')!,
OscArgument.CreateFromParams(Axis.X, 'i')!,
OscArgument.CreateFromParams(Axis.Y, 'i')!,
OscArgument.CreateFromParams(Axis.Z, 'i')!,
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,19 +24,13 @@ namespace godotVmcSharp
{
public readonly string Path;
public VmcExtConfig(OscMessage m) : base(m.Address)
public static VmcExtConfig CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "1", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "path", 's', m.Data[0].Type));
return;
}
Path = (string)m.Data[0].Value;
return new VmcExtConfig(m.Data[0].GetAsString());
}
public VmcExtConfig(string path) : base(new OscAddress("/VMC/Ext/Config"))
@ -47,7 +40,7 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument> { new OscArgument(Path, 's') });
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument> { OscArgument.CreateFromParams(Path, 's') });
}
}
}
}

View File

@ -26,55 +26,13 @@ namespace godotVmcSharp
public readonly string Serial;
public readonly Transform3D Transform;
public VmcExtDevicePos(OscMessage m) : base(m.Address)
public static VmcExtDevicePos CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 8)
if (m.Data.Count < 8)
{
GD.Print($"Invalid number of arguments for {base.Addr}. Expected 8, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "{8}", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "serial", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', m.Data[3].Type));
return;
}
if (m.Data[4].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.x", 'f', m.Data[4].Type));
return;
}
if (m.Data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.y", 'f', m.Data[5].Type));
return;
}
if (m.Data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.z", 'f', m.Data[6].Type));
return;
}
if (m.Data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.w", 'f', m.Data[7].Type));
return;
}
Serial = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
return new VmcExtDevicePos(m.Address, m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())));
}
public VmcExtDevicePos(OscAddress Addr, string serial, Transform3D transform) : base(Addr)
@ -87,15 +45,15 @@ namespace godotVmcSharp
{
var quat = Transform.Basis.GetRotationQuaternion();
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Serial, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f')
OscArgument.CreateFromParams(Serial, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -26,40 +25,27 @@ namespace godotVmcSharp
public readonly int Active;
public readonly string Name;
public readonly int Keycode;
public VmcExtKey(OscMessage m) : base(m.Address)
public static VmcExtKey CreateFromMessage(OscMessage m)
{
if (m.Data[0].Type != 'i')
var active = m.Data[0].GetAsInt32();
if (active < 0 || active > 1)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "active", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 0, "active", "{0, 1}", active);
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "keycode", 'i', m.Data[2].Type));
return;
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 1)
{
GD.Print($"Invalid value for \"active\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[0].Value}");
return;
}
Active = (int)m.Data[0].Value;
Name = (string)m.Data[1].Value;
Keycode = (int)m.Data[2].Value;
return new VmcExtKey(active, m.Data[1].GetAsString(), m.Data[2].GetAsInt32());
}
public VmcExtKey(int active, string name, int keycode) : base(new OscAddress("/VMC/Ext/Key"))
public static VmcExtKey CreateFromParams(int active, string name, int keycode)
{
if (active < 0 || active > 1)
{
GD.Print($"Invalid value for \"active\" 'i' argument of {Addr}. Expected 0 or 1, received {active}");
return;
throw new DataOutOfRangeException("/VMC/Ext/Key", 0, "active", "{0, 1}", active);
}
return new VmcExtKey(active, name, keycode);
}
private VmcExtKey(int active, string name, int keycode) : base(new OscAddress("/VMC/Ext/Key"))
{
Active = active;
Name = name;
Keycode = keycode;
@ -68,10 +54,10 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Active, 'i'),
new OscArgument(Name, 's'),
new OscArgument(Keycode, 'i')
OscArgument.CreateFromParams(Active, 'i')!,
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Keycode, 'i')!
});
}
}
}
}

View File

@ -18,7 +18,6 @@
using Godot;
using godotOscSharp;
using System.Collections.Generic;
namespace godotVmcSharp
{
@ -28,76 +27,13 @@ namespace godotVmcSharp
public readonly Transform3D Transform;
public readonly Color Color;
public VmcExtLight(OscMessage m) : base(m.Address)
public static VmcExtLight CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 12)
if (m.Data.Count < 12)
{
GD.Print($"Invalid number of arguments for {base.Addr}. Expected 12, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "12", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', m.Data[3].Type));
return;
}
if (m.Data[4].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.x", 'f', m.Data[4].Type));
return;
}
if (m.Data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.y", 'f', m.Data[5].Type));
return;
}
if (m.Data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.z", 'f', m.Data[6].Type));
return;
}
if (m.Data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.w", 'f', m.Data[7].Type));
return;
}
if (m.Data[8].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "color.red", 'f', m.Data[8].Type));
return;
}
if (m.Data[9].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "color.blue", 'f', m.Data[9].Type));
return;
}
if (m.Data[10].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "color.green", 'f', m.Data[10].Type));
return;
}
if (m.Data[11].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "color.alpha", 'f', m.Data[11].Type));
return;
}
Name = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
Color = new Color((float)m.Data[8].Value, (float)m.Data[9].Value, (float)m.Data[10].Value, (float)m.Data[11].Value);
return new VmcExtLight(m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())), new Color(m.Data[8].GetAsFloat(), m.Data[9].GetAsFloat(), m.Data[10].GetAsFloat(), m.Data[11].GetAsFloat()));
}
public VmcExtLight(string name, Transform3D transform, Color color) : base(new OscAddress("/VMC/Ext/Light"))
@ -110,20 +46,20 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
var quat = Transform.Basis.GetRotationQuaternion();
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Name, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f'),
new OscArgument(Color.R, 'f'),
new OscArgument(Color.G, 'f'),
new OscArgument(Color.B, 'f'),
new OscArgument(Color.A, 'f')
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!,
OscArgument.CreateFromParams(Color.R, 'f')!,
OscArgument.CreateFromParams(Color.G, 'f')!,
OscArgument.CreateFromParams(Color.B, 'f')!,
OscArgument.CreateFromParams(Color.A, 'f')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,34 +24,27 @@ namespace godotVmcSharp
{
public readonly int Knob;
public readonly int Active;
public VmcExtMidiCcBit(OscMessage m) : base(m.Address)
public static VmcExtMidiCcBit CreateFromMessage(OscMessage m)
{
if (m.Data[0].Type != 'i')
var active = m.Data[1].GetAsInt32();
if (active < 0 || active > 1)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "knob", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 1, "active", "{0, 1}", active);
}
if (m.Data[1].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "active", 'i', m.Data[1].Type));
return;
}
if ((int)m.Data[1].Value < 0 || (int)m.Data[1].Value > 1)
{
GD.Print($"Invalid value for \"active\" argument of {Addr}. Expected 0 or 1, received {(int)m.Data[1].Value}.");
return;
}
Knob = (int)m.Data[0].Value;
Active = (int)m.Data[1].Value;
return new VmcExtMidiCcBit(m.Data[0].GetAsInt32(), active);
}
public VmcExtMidiCcBit(int knob, int active) : base(new OscAddress("/VMC/Ext/Midi/CC/Bit"))
public static VmcExtMidiCcBit CreateFromParams(int knob, int active)
{
if (active < 0 || active > 1)
{
GD.Print($"Invalid value for \"active\" argument of {Addr}. Expected 0 or 1, received {active}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Midi/CC/Bit", 1, "active", "{0, 1}", active);
}
return new VmcExtMidiCcBit(knob, active);
}
private VmcExtMidiCcBit(int knob, int active) : base(new OscAddress("/VMC/Ext/Midi/CC/Bit"))
{
Knob = knob;
Active = active;
}
@ -60,9 +52,9 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Knob, 'i'),
new OscArgument(Active, 'i')
OscArgument.CreateFromParams(Knob, 'i')!,
OscArgument.CreateFromParams(Active, 'i')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,20 +24,13 @@ namespace godotVmcSharp
{
public readonly int Knob;
public readonly float Value;
public VmcExtMidiCcVal(OscMessage m) : base(m.Address)
public static VmcExtMidiCcVal CreateFromMessage(OscMessage m)
{
if (m.Data[0].Type != 'i')
if (m.Data.Count < 2)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "knob", 'i', m.Data[0].Type));
return;
throw new MissingArgumentsException(m.Address, "{2}", m.Data.Count);
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "value", 'f', m.Data[1].Type));
return;
}
Knob = (int)m.Data[0].Value;
Value = (int)m.Data[1].Value;
return new VmcExtMidiCcVal(m.Data[0].GetAsInt32(), m.Data[1].GetAsFloat());
}
public VmcExtMidiCcVal(int knob, float value) : base(new OscAddress("/VMC/Ext/Midi/CC/Val"))
@ -50,9 +42,9 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Knob, 'i'),
new OscArgument(Value, 'f')
OscArgument.CreateFromParams(Knob, 'i')!,
OscArgument.CreateFromParams(Value, 'f')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -28,46 +27,31 @@ namespace godotVmcSharp
public readonly int Note;
public readonly float Velocity;
public VmcExtMidiNote(OscMessage m) : base(m.Address)
public static VmcExtMidiNote CreateFromMessage(OscMessage m)
{
if (m.Data[0].Type != 'i')
if (m.Data.Count < 4)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "active", 'i', m.Data[0].Type));
return;
throw new MissingArgumentsException(m.Address, "{4}", m.Data.Count);
}
if (m.Data[1].Type != 'i')
var active = m.Data[0].GetAsInt32();
if (active < 0 || active > 1)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "channel", 'i', m.Data[1].Type));
return;
throw new DataOutOfRangeException(m.Address, 0, "active", "{0, 1}", active);
}
if (m.Data[2].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "note", 'i', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "velocity", 'f', m.Data[4].Type));
return;
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 1)
{
GD.Print($"Invalid value for \"active\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[0].Value}");
return;
}
Active = (int)m.Data[0].Value;
Channel = (int)m.Data[1].Value;
Note = (int)m.Data[2].Value;
Velocity = (int)m.Data[3].Value;
return new VmcExtMidiNote(active, m.Data[1].GetAsInt32(), m.Data[2].GetAsInt32(), m.Data[3].GetAsFloat());
}
public VmcExtMidiNote(int active, int channel, int note, float velocity) : base(new OscAddress("/VMC/Ext/Midi/Note"))
public static VmcExtMidiNote CreateFromParams(int active, int channel, int note, float velocity)
{
if (active < 0 || active > 1)
{
GD.Print($"Invalid value for \"active\" 'i' argument of {Addr}. Expected 0 or 1, received {Active}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Midi/Note", 0, "active", "{0, 1}", active);
}
return new VmcExtMidiNote(active, channel, note, velocity);
}
private VmcExtMidiNote(int active, int channel, int note, float velocity) : base(new OscAddress("/VMC/Ext/Midi/Note"))
{
Active = active;
Channel = channel;
Note = note;
@ -77,11 +61,11 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Active, 'i'),
new OscArgument(Channel, 'i'),
new OscArgument(Note, 'i'),
new OscArgument(Velocity, 'f')
OscArgument.CreateFromParams(Active, 'i')!,
OscArgument.CreateFromParams(Channel, 'i')!,
OscArgument.CreateFromParams(Note, 'i')!,
OscArgument.CreateFromParams(Velocity, 'f')!
});
}
}
}
}

View File

@ -17,7 +17,6 @@
*/
using godotOscSharp;
using Godot;
using System.Collections.Generic;
namespace godotVmcSharp
@ -29,163 +28,120 @@ namespace godotVmcSharp
public readonly int? CalibrationMode;
public readonly int? TrackingStatus;
public VmcExtOk(int loaded) : base(new OscAddress("/VMC/Ext/OK"))
public static VmcExtOk CreateFromParams(int loaded)
{
if (loaded < 0 || loaded > 1)
{
GD.Print($"Invalid value for loaded status. Expected 0 or 1, received {loaded}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 0, "loaded", "{0, 1}", loaded);
}
return new VmcExtOk(loaded);
}
private VmcExtOk(int loaded): base(new OscAddress("/VMC/Ext/OK"))
{
Loaded = loaded;
}
public VmcExtOk(int loaded, int calibrationState, int calibrationMode) : base(new OscAddress("/VMC/Ext/OK"))
public static VmcExtOk CreateFromParams(int loaded, int calibrationState, int calibrationMode)
{
if (loaded < 0 || loaded > 1)
{
GD.Print($"Invalid value for loaded status. Expected 0 or 1, received {loaded}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 0, "loaded", "{0, 1}", loaded);
}
if (calibrationState < 0 || calibrationState > 3)
{
GD.Print($"Invalid value for calibration state. Expected 0-3, received {calibrationState}");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 1, "calibrationState", "{0..3}", calibrationState);
}
if (calibrationMode < 0 || calibrationMode > 2)
{
GD.Print($"Invalid value for calibration mode. Expected 0-2, received {calibrationMode}");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 2, "calibrationMode", "{0..2}", calibrationMode);
}
return new VmcExtOk(loaded, calibrationState, calibrationMode);
}
private VmcExtOk(int loaded, int calibrationState, int calibrationMode) : base(new OscAddress("/VMC/Ext/OK"))
{
Loaded = loaded;
CalibrationState = calibrationState;
CalibrationMode = calibrationMode;
}
public VmcExtOk(int loaded, int calibrationState, int calibrationMode, int trackingStatus) : base(new OscAddress("/VMC/Ext/OK"))
public static VmcExtOk CreateFromParams(int loaded, int calibrationState, int calibrationMode, int trackingStatus)
{
if (loaded < 0 || loaded > 1)
{
GD.Print($"Invalid value for loaded status. Expected 0 or 1, received {loaded}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 0, "loaded", "{0, 1}", loaded);
}
if (calibrationState < 0 || calibrationState > 3)
{
GD.Print($"Invalid value for calibration state. Expected 0-3, received {calibrationState}");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 1, "calibrationState", "{0..3}", calibrationState);
}
if (calibrationMode < 0 || calibrationMode > 2)
{
GD.Print($"Invalid value for calibration mode. Expected 0-2, received {calibrationMode}");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 2, "calibrationMode", "{0..2}", calibrationMode);
}
if (trackingStatus < 0 || trackingStatus > 1)
{
GD.Print($"Invalid value for tracking status. Expected 0-1, received {trackingStatus}");
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 3, "trackingStatus", "{0, 1}", trackingStatus);
}
return new VmcExtOk(loaded, calibrationState, calibrationMode, trackingStatus);
}
private VmcExtOk(int loaded, int calibrationState, int calibrationMode, int trackingStatus) : base(new OscAddress("/VMC/Ext/OK"))
{
Loaded = loaded;
CalibrationState = calibrationState;
CalibrationMode = calibrationMode;
TrackingStatus = trackingStatus;
}
public VmcExtOk(OscMessage m) : base(m.Address)
public static VmcExtOk CreateFromMessage(OscMessage m)
{
switch (m.Data.Count)
{
case 1:
if (!OkParam0(m.Data[0]))
{
return;
}
Loaded = (int)m.Data[0].Value;
break;
return new VmcExtOk(getLoaded(m));
case 3:
if (!OkParam1And2(m.Data[0], m.Data[1], m.Data[2]))
{
return;
}
Loaded = (int)m.Data[0].Value;
CalibrationState = (int)m.Data[1].Value;
CalibrationMode = (int)m.Data[2].Value;
break;
return new VmcExtOk(getLoaded(m), getCalibrationState(m), getCalibrationMode(m));
case 4:
if (!OkParam3(m.Data[0], m.Data[1], m.Data[2], m.Data[3]))
var trackingStatus = m.Data[3].GetAsInt32();
if (trackingStatus < 0 || trackingStatus > 1)
{
return;
throw new DataOutOfRangeException("/VMC/Ext/OK", 3, "trackingStatus", "{0, 1}", trackingStatus);
}
Loaded = (int)m.Data[0].Value;
CalibrationState = (int)m.Data[1].Value;
CalibrationMode = (int)m.Data[2].Value;
TrackingStatus = (int)m.Data[3].Value;
break;
return new VmcExtOk(getLoaded(m), getCalibrationState(m), getCalibrationMode(m), trackingStatus);
default:
GD.Print($"Invalid number of arguments for /VMC/Ext/OK message. Expected 1, 3, or 4 but received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{1, 3, 4}", m.Data.Count);
}
}
private bool OkParam0(OscArgument arg)
private static int getLoaded(OscMessage m)
{
if (arg.Type != 'i')
var loaded = m.Data[0].GetAsInt32();
if (loaded < 0 || loaded > 1)
{
GD.Print($"Invalid argument type for /VMC/Ext/OK message. Expected int in argument 0, received {arg.Type}");
return false;
throw new DataOutOfRangeException("/VMC/Ext/OK", 0, "loaded", "{0, 1}", loaded);
}
if ((int)arg.Value < 0 && (int)arg.Value > 1)
{
GD.Print($"Invalid value for loaded status. Expected 0-1, received {(int)arg.Value}");
return false;
}
return true;
return loaded;
}
private bool OkParam1And2(OscArgument arg0, OscArgument arg1, OscArgument arg2)
private static int getCalibrationState(OscMessage m)
{
if (!OkParam0(arg0))
var calibrationState = m.Data[1].GetAsInt32();
if (calibrationState < 0 || calibrationState > 3)
{
return false;
throw new DataOutOfRangeException("/VMC/Ext/OK", 1, "calibrationState", "{0..3}", calibrationState);
}
if (arg1.Type != 'i')
{
GD.Print($"Invalid argument type for /VMC/Ext/OK message. Expected int in argument 1, received {arg1.Type}");
return false;
}
if (arg2.Type != 'i')
{
GD.Print($"Invalid argument type for /VMC/Ext/OK message. Expected int in argument 2, received {arg2.Type}");
return false;
}
if ((int)arg1.Value < 0 && (int)arg1.Value > 3)
{
GD.Print($"Invalid value for calibration state. Expected 0-3, received {(int)arg1.Value}");
return false;
}
if ((int)arg2.Value < 0 && (int)arg2.Value > 2)
{
GD.Print($"Invalid value for calibration mode. Expected 0-2, received {(int)arg2.Value}");
return false;
}
return true;
return calibrationState;
}
private bool OkParam3(OscArgument arg0, OscArgument arg1, OscArgument arg2, OscArgument arg)
private static int getCalibrationMode(OscMessage m)
{
if (!OkParam1And2(arg0, arg1, arg2))
var calibrationMode = m.Data[2].GetAsInt32();
if (calibrationMode < 0 || calibrationMode > 2)
{
return false;
throw new DataOutOfRangeException("/VMC/Ext/OK", 2, "calibrationMode", "{0..2}", calibrationMode);
}
if (arg.Type != 'i')
{
GD.Print($"Invalid argument type for /VMC/Ext/OK message. Expected int in argument 3, received {arg.Type}");
return false;
}
if ((int)arg.Value < 0 && (int)arg.Value > 1)
{
GD.Print($"Invalid value for tracking status. Expected 0-1, received {(int)arg.Value}");
return false;
}
return true;
return calibrationMode;
}
public new OscMessage ToMessage()
@ -193,23 +149,23 @@ namespace godotVmcSharp
if (CalibrationState == null)
{
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Loaded, 'i')
OscArgument.CreateFromParams(Loaded, 'i')!
});
}
if (TrackingStatus == null)
{
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Loaded, 'i'),
new OscArgument(CalibrationState, 'i'),
new OscArgument(CalibrationMode, 'i')
OscArgument.CreateFromParams(Loaded, 'i')!,
OscArgument.CreateFromParams(CalibrationState, 'i')!,
OscArgument.CreateFromParams(CalibrationMode, 'i')!
});
}
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Loaded, 'i'),
new OscArgument(CalibrationState, 'i'),
new OscArgument(CalibrationMode, 'i'),
new OscArgument(TrackingStatus, 'i')
OscArgument.CreateFromParams(Loaded, 'i')!,
OscArgument.CreateFromParams(CalibrationState, 'i')!,
OscArgument.CreateFromParams(CalibrationMode, 'i')!,
OscArgument.CreateFromParams(TrackingStatus, 'i')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,19 +24,13 @@ namespace godotVmcSharp
{
public readonly string option;
public VmcExtOpt(OscMessage m) : base(m.Address)
public static VmcExtOpt CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "1", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "option", 's', m.Data[0].Type));
return;
}
option = (string)m.Data[0].Value;
return new VmcExtOpt(m.Data[0].GetAsString());
}
public VmcExtOpt(string _option) : base(new OscAddress("/VMC/Ext/Opt"))
@ -47,7 +40,7 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{new OscArgument(option, 's')});
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{OscArgument.CreateFromParams(option, 's')!});
}
}
}
}

View File

@ -16,88 +16,82 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
using System.Collections.Generic;
#nullable enable
namespace godotVmcSharp
{
public class VmcExtRcv : VmcMessage
{
public readonly int Enable;
public readonly int Port;
public readonly string IpAddress;
public readonly string? IpAddress;
public VmcExtRcv(OscMessage m) : base(m.Address)
public static VmcExtRcv CreateFromMessage(OscMessage m)
{
if (m.Data.Count > 3 || m.Data.Count < 2)
if (m.Data.Count < 2)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 2 or 3, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{2, 3}", m.Data.Count);
}
if (m.Data[0].Type != 'i')
var enable = m.Data[0].GetAsInt32();
if (enable < 0 || enable > 1)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "enable", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 0, "enable", "{0, 1}", enable);
}
if (m.Data[1].Type != 'i')
var port = m.Data[1].GetAsInt32();
if (port < 0 || port > 65535)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "port", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 1, "port", "{0..65535}", port);
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 1)
{
GD.Print($"Invalid value for \"enable\" argument of {Addr}. Expected 0 or 1, received {(int)m.Data[0].Value}.");
return;
if (m.Data.Count >= 2) {
return new VmcExtRcv(enable, port);
}
if ((int)m.Data[1].Value < 0 || (int)m.Data[1].Value > 65535)
{
GD.Print($"Invalid value for \"port\" argument of {Addr}. Expected 0-65535, received {(int)m.Data[1].Value}.");
return;
}
Enable = (int)m.Data[0].Value;
Port = (int)m.Data[1].Value;
if (m.Data.Count != 3)
{
IpAddress = "";
return;
}
if (m.Data[2].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "IpAddress", 's', m.Data[2].Type));
return;
}
IpAddress = (string)m.Data[2].Value;
return new VmcExtRcv(enable, port, m.Data[2].GetAsString());
}
public VmcExtRcv(int enable, int port) : base(new OscAddress("/VMC/Ext/Rcv"))
public static VmcExtRcv CreateFromParams(int enable, int port)
{
if (enable < 0 || enable > 1)
{
GD.Print($"Invalid value for \"enable\" argument of {Addr}. Expected 0 or 1, received {enable}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 0, "enable", "{0, 1}", enable);
}
if (port < 0 || port > 65535)
{
GD.Print($"Invalid value for \"port\" argument of {Addr}. Expected 0-65535, received {port}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 1, "port", "{0..65535}", port);
}
return new VmcExtRcv(enable, port);
}
private VmcExtRcv(int enable, int port) : base(new OscAddress("/VMC/Ext/Rcv"))
{
Enable = enable;
Port = port;
IpAddress = "";
}
public VmcExtRcv(int enable, int port, string ipAddress) : base(new OscAddress("/VMC/Ext/Rcv"))
public static VmcExtRcv CreateFromMessage(int enable, int port, string ipAddress)
{
if (enable < 0 || enable > 1)
{
GD.Print($"Invalid value for \"enable\" argument of {Addr}. Expected 0 or 1, received {enable}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 0, "enable", "{0, 1}", enable);
}
if (port < 0 || port > 65535)
{
GD.Print($"Invalid value for \"port\" argument of {Addr}. Expected 0-65535, received {port}.");
return;
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 1, "port", "{0..65535}", port);
}
return new VmcExtRcv(enable, port, ipAddress);
}
private VmcExtRcv(int enable, int port, string ipAddress) : base(new OscAddress("/VMC/Ext/Rcv"))
{
if (enable < 0 || enable > 1)
{
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 0, "enable", "{0, 1}", enable);
}
if (port < 0 || port > 65535)
{
throw new DataOutOfRangeException("/VMC/Ext/Rcv", 1, "port", "{0..65535}", port);
}
Enable = enable;
Port = port;
@ -106,18 +100,18 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
if (IpAddress == "")
if (IpAddress == null)
{
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Enable, 'i'),
new OscArgument(Port, 'i'),
OscArgument.CreateFromParams(Enable, 'i')!,
OscArgument.CreateFromParams(Port, 'i')!,
});
}
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Enable, 'i'),
new OscArgument(Port, 'i'),
new OscArgument(IpAddress, 's'),
OscArgument.CreateFromParams(Enable, 'i')!,
OscArgument.CreateFromParams(Port, 'i')!,
OscArgument.CreateFromParams(IpAddress, 's')!,
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -26,25 +25,13 @@ namespace godotVmcSharp
public readonly string Service;
public readonly string Json;
public VmcExtRemote(OscMessage m) : base(m.Address)
public static VmcExtRemote CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 2)
if (m.Data.Count < 2)
{
GD.Print($"Invalid number of arguments for {Addr} message. Expected 2 but received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "2", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "service", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "json", 's', m.Data[1].Type));
return;
}
Service = (string)m.Data[0].Value;
Json = (string)m.Data[1].Value;
return new VmcExtRemote(m.Data[0].GetAsString(), m.Data[1].GetAsString());
}
public VmcExtRemote(string service, string json) : base(new OscAddress("/VMC/Ext/Remote"))
@ -56,9 +43,9 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Service, 's'),
new OscArgument(Json, 's')
OscArgument.CreateFromParams(Service, 's')!,
OscArgument.CreateFromParams(Json, 's')!
});
}
}
}
}

View File

@ -30,31 +30,16 @@ namespace godotVmcSharp
public readonly Vector3? Scale;
public readonly Vector3? Offset;
public VmcExtRootPos(OscMessage m) : base(m.Address)
public static VmcExtRootPos CreateFromMessage(OscMessage m)
{
switch (m.Data.Count)
{
case 8:
if (!Transform8(m.Data))
{
return;
}
Name = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
break;
return new VmcExtRootPos(m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())));
case 14:
if (!Transform14(m.Data))
{
return;
}
Name = (string)m.Data[0].Value;
Transform = new Transform3D(new Basis(new Quaternion((float)m.Data[4].Value, (float)m.Data[5].Value, (float)m.Data[6].Value, (float)m.Data[7].Value)), new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value));
Scale = new Vector3((float)m.Data[8].Value, (float)m.Data[9].Value, (float)m.Data[10].Value);
Offset = new Vector3((float)m.Data[11].Value, (float)m.Data[12].Value, (float)m.Data[13].Value);
break;
return new VmcExtRootPos(m.Data[0].GetAsString(), new Transform3D(new Basis(new Quaternion(m.Data[4].GetAsFloat(), m.Data[5].GetAsFloat(), m.Data[6].GetAsFloat(), m.Data[7].GetAsFloat())), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat())), new Vector3(m.Data[8].GetAsFloat(), m.Data[9].GetAsFloat(), m.Data[10].GetAsFloat()), new Vector3(m.Data[11].GetAsFloat(), m.Data[12].GetAsFloat(), m.Data[13].GetAsFloat()));
default:
GD.Print($"Invalid number of arguments for {Addr}. Expected 8 or 14, received {m.Data.Count}.");
return;
throw new MissingArgumentsException(m.Address, "{8, 14}", m.Data.Count);
}
}
@ -72,121 +57,37 @@ namespace godotVmcSharp
Offset = offset;
}
private bool Transform8(List<OscArgument> data)
{
if (data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "name", 's', data[0].Type));
return false;
}
if (data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', data[1].Type));
return false;
}
if (data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', data[2].Type));
return false;
}
if (data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', data[3].Type));
return false;
}
if (data[4].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.x", 'f', data[4].Type));
return false;
}
if (data[5].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.y", 'f', data[5].Type));
return false;
}
if (data[6].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.z", 'f', data[6].Type));
return false;
}
if (data[7].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "q.w", 'f', data[7].Type));
return false;
}
return true;
}
private bool Transform14(List<OscArgument> data)
{
if (!Transform8(data))
{
return false;
}
if (data[8].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "s.x", 'f', data[8].Type));
return false;
}
if (data[9].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "s.y", 'f', data[9].Type));
return false;
}
if (data[10].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "s.z", 'f', data[10].Type));
return false;
}
if (data[11].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "o.x", 'f', data[11].Type));
return false;
}
if (data[12].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "o.y", 'f', data[12].Type));
return false;
}
if (data[13].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "o.z", 'f', data[13].Type));
return false;
}
return true;
}
public new OscMessage ToMessage()
{
var quat = Transform.Basis.GetRotationQuaternion();
if (!Scale.HasValue)
{
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Name, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f'),
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!,
});
}
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Name, 's'),
new OscArgument(Transform.Origin.X, 'f'),
new OscArgument(Transform.Origin.Y, 'f'),
new OscArgument(Transform.Origin.Z, 'f'),
new OscArgument(quat.X, 'f'),
new OscArgument(quat.Y, 'f'),
new OscArgument(quat.Z, 'f'),
new OscArgument(quat.W, 'f'),
new OscArgument(Scale.Value.X, 'f'),
new OscArgument(Scale.Value.Y, 'f'),
new OscArgument(Scale.Value.Z, 'f'),
new OscArgument(Offset.Value.X, 'f'),
new OscArgument(Offset.Value.Y, 'f'),
new OscArgument(Offset.Value.Z, 'f'),
OscArgument.CreateFromParams(Name, 's')!,
OscArgument.CreateFromParams(Transform.Origin.X, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Y, 'f')!,
OscArgument.CreateFromParams(Transform.Origin.Z, 'f')!,
OscArgument.CreateFromParams(quat.X, 'f')!,
OscArgument.CreateFromParams(quat.Y, 'f')!,
OscArgument.CreateFromParams(quat.Z, 'f')!,
OscArgument.CreateFromParams(quat.W, 'f')!,
OscArgument.CreateFromParams(Scale!.Value.X, 'f')!,
OscArgument.CreateFromParams(Scale!.Value.Y, 'f')!,
OscArgument.CreateFromParams(Scale!.Value.Z, 'f')!,
OscArgument.CreateFromParams(Offset!.Value.X, 'f')!,
OscArgument.CreateFromParams(Offset!.Value.Y, 'f')!,
OscArgument.CreateFromParams(Offset!.Value.Z, 'f')!,
});
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,39 +24,37 @@ namespace godotVmcSharp
{
public readonly int Mode;
public VmcExtSetCalibExec(OscMessage m) : base(m.Address)
public static VmcExtSetCalibExec CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{1}", m.Data.Count);
}
if (m.Data[0].Type != 'i')
var mode = m.Data[0].GetAsInt32();
if (mode < 0 || mode > 2)
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "mode", 'i', m.Data[0].Type));
return;
throw new DataOutOfRangeException(m.Address, 0, "mode", "{0..2}", mode);
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 2)
{
GD.Print($"Invalid value for argument \"mode\" of \"/VMC/Ext/Set/Calib/Exec\". Expected in range 0-2, received {(int)m.Data[0].Value}");
return;
}
Mode = (int)m.Data[0].Value;
return new VmcExtSetCalibExec(mode);
}
public VmcExtSetCalibExec(int mode) : base(new OscAddress("/VMC/Ext/Set/Calib/Exec"))
public static VmcExtSetCalibExec CreateFromParams(int mode)
{
if (mode < 0 || mode > 2)
{
GD.Print($"Invalid value for argument \"mode\" of \"/VMC/Ext/Set/Calib/Exec\". Expected in range 0-2, received {mode}");
return;
throw new DataOutOfRangeException("/VMC/Ext/Set/Calib/Exec", 0, "mode", "{0..2}", mode);
}
return new VmcExtSetCalibExec(mode);
}
private VmcExtSetCalibExec(int mode) : base(new OscAddress("/VMC/Ext/Set/Calib/Exec"))
{
Mode = mode;
}
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{new OscArgument(Mode, 'i')});
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{OscArgument.CreateFromParams(Mode, 'i')!});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,19 +24,13 @@ namespace godotVmcSharp
{
public readonly string Path;
public VmcExtSetConfig(OscMessage m) : base(m.Address)
public static VmcExtSetConfig CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{1}", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "path", 's', m.Data[0].Type));
return;
}
Path = (string)m.Data[0].Value;
return new VmcExtSetConfig(m.Data[0].GetAsString());
}
public VmcExtSetConfig(string path) : base(new OscAddress("/VMC/Ext/Set/Config"))
@ -47,7 +40,7 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{new OscArgument(Path, 's')});
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{OscArgument.CreateFromParams(Path, 's')!});
}
}
}
}

View File

@ -26,35 +26,29 @@ namespace godotVmcSharp
public readonly int Enable;
public readonly Vector3 Position;
public VmcExtSetEye(OscMessage m) : base(m.Address)
public static VmcExtSetEye CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 4)
if (m.Data.Count < 4)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 4, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{4}", m.Data.Count);
}
if (m.Data[0].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "enable", 'i', m.Data[0].Type));
return;
throw new InvalidDataTypeException(m.Address, 0, "enable", 'i', m.Data[0].Type);
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.x", 'f', m.Data[1].Type));
return;
throw new InvalidDataTypeException(m.Address, 1, "p.x", 'f', m.Data[1].Type);
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.y", 'f', m.Data[2].Type));
return;
throw new InvalidDataTypeException(m.Address, 2, "p.y", 'f', m.Data[2].Type);
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "p.z", 'f', m.Data[3].Type));
return;
throw new InvalidDataTypeException(m.Address, 3, "p.z", 'f', m.Data[3].Type);
}
Enable = (int)m.Data[0].Value;
Position = new Vector3((float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value);
return new VmcExtSetEye(m.Data[0].GetAsInt32(), new Vector3(m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat()));
}
public VmcExtSetEye(int enable, Vector3 position) : base(new OscAddress("/VMC/Ext/Set/Eye"))
@ -66,11 +60,11 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Enable, 'i'),
new OscArgument(Position.X, 'f'),
new OscArgument(Position.Y, 'f'),
new OscArgument(Position.Z, 'f'),
OscArgument.CreateFromParams(Enable, 'i')!,
OscArgument.CreateFromParams(Position.X, 'f')!,
OscArgument.CreateFromParams(Position.Y, 'f')!,
OscArgument.CreateFromParams(Position.Z, 'f')!,
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -30,49 +29,13 @@ namespace godotVmcSharp
public readonly int Camera;
public readonly int Devices;
public VmcExtSetPeriod(OscMessage m) : base(m.Address)
public static VmcExtSetPeriod CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 6)
if (m.Data.Count < 6)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 6, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{6}", m.Data.Count);
}
if (m.Data[0].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "status", 'i', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "root", 'i', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "bone", 'i', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "blendShape", 'i', m.Data[3].Type));
return;
}
if (m.Data[4].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "camera", 'i', m.Data[4].Type));
return;
}
if (m.Data[5].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "devices", 'i', m.Data[5].Type));
return;
}
Status = (int)m.Data[0].Value;
Root = (int)m.Data[1].Value;
Bone = (int)m.Data[2].Value;
BlendShape = (int)m.Data[3].Value;
Camera = (int)m.Data[4].Value;
Devices = (int)m.Data[5].Value;
return new VmcExtSetPeriod(m.Data[0].GetAsInt32(), m.Data[1].GetAsInt32(), m.Data[2].GetAsInt32(), m.Data[3].GetAsInt32(), m.Data[4].GetAsInt32(), m.Data[5].GetAsInt32());
}
public VmcExtSetPeriod(int status, int root, int bone, int blendShape, int camera, int devices) : base(new OscAddress("/VMC/Ext/Set/Period"))
@ -88,13 +51,13 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Status, 'i'),
new OscArgument(Root, 'i'),
new OscArgument(Bone, 'i'),
new OscArgument(BlendShape, 'i'),
new OscArgument(Camera, 'i'),
new OscArgument(Devices, 'i'),
OscArgument.CreateFromParams(Status, 'i')!,
OscArgument.CreateFromParams(Root, 'i')!,
OscArgument.CreateFromParams(Bone, 'i')!,
OscArgument.CreateFromParams(BlendShape, 'i')!,
OscArgument.CreateFromParams(Camera, 'i')!,
OscArgument.CreateFromParams(Devices, 'i')!,
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
@ -26,19 +25,13 @@ namespace godotVmcSharp
{
public readonly string Response;
public VmcExtSetRes(OscMessage m) : base(m.Address)
public static VmcExtSetRes CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{1}", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "response", 's', m.Data[0].Type));
return;
}
Response = (string)m.Data[0].Value;
return new VmcExtSetRes(m.Data[0].GetAsString());
}
public VmcExtSetRes(string response) : base(new OscAddress("/VMC/Ext/Set/Res"))
@ -48,7 +41,7 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{new OscArgument(Response, 's')});
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{OscArgument.CreateFromParams(Response, 's')!});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -25,19 +24,13 @@ namespace godotVmcSharp
{
public readonly string Shortcut;
public VmcExtSetShortcut(OscMessage m) : base(m.Address)
public static VmcExtSetShortcut CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 1, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{1}", m.Data.Count);
}
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "shortcut", 's', m.Data[0].Type));
return;
}
Shortcut = (string)m.Data[0].Value;
return new VmcExtSetShortcut(m.Data[0].GetAsString());
}
public VmcExtSetShortcut(string shortcut) : base(new OscAddress("/VMC/Ext/Set/Shortcut"))
@ -47,7 +40,7 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{new OscArgument(Shortcut, 's')});
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{OscArgument.CreateFromParams(Shortcut, 's')!});
}
}
}
}

View File

@ -25,34 +25,13 @@ namespace godotVmcSharp
{
public readonly Color Color;
public VmcExtSettingColor(OscMessage m) : base(m.Address)
public static VmcExtSettingColor CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 4)
if (m.Data.Count < 4)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 4, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "{4}", m.Data.Count);
}
if (m.Data[0].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "r", 'f', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "g", 'f', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "b", 'f', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'f')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "a", 'f', m.Data[3].Type));
return;
}
Color = new Godot.Color((float)m.Data[0].Value, (float)m.Data[1].Value, (float)m.Data[2].Value, (float)m.Data[3].Value);
return new VmcExtSettingColor(new Godot.Color(m.Data[0].GetAsFloat(), m.Data[1].GetAsFloat(), m.Data[2].GetAsFloat(), m.Data[3].GetAsFloat()));
}
public VmcExtSettingColor(Color color) : base(new OscAddress("/VMC/Ext/Setting/Color"))
@ -63,11 +42,11 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Color.R, 'f'),
new OscArgument(Color.G, 'f'),
new OscArgument(Color.B, 'f'),
new OscArgument(Color.A, 'f')
OscArgument.CreateFromParams(Color.R, 'f')!,
OscArgument.CreateFromParams(Color.G, 'f')!,
OscArgument.CreateFromParams(Color.B, 'f')!,
OscArgument.CreateFromParams(Color.A, 'f')!
});
}
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
namespace godotVmcSharp
@ -28,81 +27,58 @@ namespace godotVmcSharp
public readonly int WindowClickThrough;
public readonly int HideBorder;
public VmcExtSettingWin(OscMessage m) : base(m.Address)
public static VmcExtSettingWin CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 4)
if (m.Data.Count < 4)
{
GD.Print($"Invalid number of arguments for {Addr}. Expecting 4, received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "4", m.Data.Count);
}
if (m.Data[0].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "isTopMost", 'i', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "isTransparent", 'i', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "windowClickThrough", 'i', m.Data[2].Type));
return;
}
if (m.Data[3].Type != 'i')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "hideBorder", 'i', m.Data[3].Type));
return;
}
if ((int)m.Data[0].Value < 0 || (int)m.Data[0].Value > 1)
{
GD.Print($"Invalid value for \"isTopMost\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[0].Value}");
return;
}
if ((int)m.Data[1].Value < 0 || (int)m.Data[1].Value > 1)
{
GD.Print($"Invalid value for \"isTransparent\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[1].Value}");
return;
}
if ((int)m.Data[2].Value < 0 || (int)m.Data[2].Value > 1)
{
GD.Print($"Invalid value for \"windowClickThrough\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[2].Value}");
return;
}
if ((int)m.Data[3].Value < 0 || (int)m.Data[3].Value > 1)
{
GD.Print($"Invalid value for \"hideBorder\" 'i' argument of {Addr}. Expected 0 or 1, received {(int)m.Data[3].Value}");
return;
}
IsTopMost = (int)m.Data[0].Value;
IsTransparent = (int)m.Data[1].Value;
WindowClickThrough = (int)m.Data[2].Value;
HideBorder = (int)m.Data[3].Value;
}
public VmcExtSettingWin(int isTopMost, int isTransparent, int windowClickThrough, int hideBorder) : base(new OscAddress("/VMC/Ext/Setting/Win"))
{
var isTopMost = m.Data[0].GetAsInt32();
var isTransparent = m.Data[1].GetAsInt32();
var windowClickThrough = m.Data[2].GetAsInt32();
var hideBorder = m.Data[3].GetAsInt32();
if (isTopMost < 0 || isTopMost > 1)
{
GD.Print($"Invalid value for \"isTopMost\" 'i' argument of {Addr}. Expected 0 or 1, received {isTopMost}");
return;
throw new DataOutOfRangeException(m.Address, 0, "isTopMost", "{0, 1}", isTopMost);
}
if (isTransparent < 0 || isTransparent > 1)
{
GD.Print($"Invalid value for \"isTransparent\" 'i' argument of {Addr}. Expected 0 or 1, received {isTransparent}");
return;
throw new DataOutOfRangeException(m.Address, 1, "isTransparent", "{0, 1}", isTransparent);
}
if (windowClickThrough < 0 || windowClickThrough > 1)
{
GD.Print($"Invalid value for \"windowClickThrough\" 'i' argument of {Addr}. Expected 0 or 1, received {windowClickThrough}");
return;
throw new DataOutOfRangeException(m.Address, 2, "windowClickThrough", "{0, 1}", windowClickThrough);
}
if (hideBorder < 0 || hideBorder > 1)
{
GD.Print($"Invalid value for \"hideBorder\" 'i' argument of {Addr}. Expected 0 or 1, received {hideBorder}");
return;
throw new DataOutOfRangeException(m.Address, 3, "hideBorder", "{0, 1}", hideBorder);
}
return new VmcExtSettingWin(isTopMost, isTransparent, windowClickThrough, hideBorder);
}
public static VmcExtSettingWin CreateFromParams(int isTopMost, int isTransparent, int windowClickThrough, int hideBorder)
{
if (isTopMost < 0 || isTopMost > 1)
{
throw new DataOutOfRangeException("/VMC/Ext/Setting/Win", 0, "isTopMost", "{0, 1}", isTopMost);
}
if (isTransparent < 0 || isTransparent > 1)
{
throw new DataOutOfRangeException("/VMC/Ext/Setting/Win", 1, "isTransparent", "{0, 1}", isTransparent);
}
if (windowClickThrough < 0 || windowClickThrough > 1)
{
throw new DataOutOfRangeException("/VMC/Ext/Setting/Win", 2, "windowClickThrough", "{0, 1}", windowClickThrough);
}
if (hideBorder < 0 || hideBorder > 1)
{
throw new DataOutOfRangeException("/VMC/Ext/Setting/Win", 3, "hideBorder", "{0, 1}", hideBorder);
}
return new VmcExtSettingWin(isTopMost, isTransparent, windowClickThrough, hideBorder);
}
private VmcExtSettingWin(int isTopMost, int isTransparent, int windowClickThrough, int hideBorder) : base(new OscAddress("/VMC/Ext/Setting/Win"))
{
IsTopMost = isTopMost;
IsTransparent = isTransparent;
WindowClickThrough = windowClickThrough;
@ -112,11 +88,11 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(IsTopMost, 'i'),
new OscArgument(IsTransparent, 'i'),
new OscArgument(WindowClickThrough, 'i'),
new OscArgument(HideBorder, 'i')
OscArgument.CreateFromParams(IsTopMost, 'i')!,
OscArgument.CreateFromParams(IsTransparent, 'i')!,
OscArgument.CreateFromParams(WindowClickThrough, 'i')!,
OscArgument.CreateFromParams(HideBorder, 'i')!
});
}
}
}
}

View File

@ -17,26 +17,19 @@
*/
using godotOscSharp;
using Godot;
namespace godotVmcSharp
{
public class VmcExtT : VmcMessage
{
public readonly float Time;
public VmcExtT(OscMessage m) : base(m.Address)
public static VmcExtT CreateFromMessage(OscMessage m)
{
if (m.Data.Count != 1)
if (m.Data.Count < 1)
{
GD.Print($"Invalid number of arguments for /VMC/Ext/T message. Expected 1 but received {m.Data.Count}");
return;
throw new MissingArgumentsException(m.Address, "1", m.Data.Count);
}
if (m.Data[0].Type != 'f')
{
InvalidArgumentType.GetErrorString(m.Address.ToString(), "time", 'f', m.Data[0].Type);
return;
}
Time = (float)m.Data[0].Value;
return new VmcExtT(m.Data[0].GetAsFloat());
}
public VmcExtT(float time) : base(new OscAddress("/VMC/Ext/T"))
@ -47,8 +40,8 @@ namespace godotVmcSharp
public new OscMessage ToMessage()
{
return new OscMessage(Addr, new System.Collections.Generic.List<OscArgument>{
new OscArgument(Time, 'f')
OscArgument.CreateFromParams(Time, 'f')!
});
}
}
}
}

View File

@ -16,60 +16,30 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using godotOscSharp;
using System.Collections.Generic;
#nullable enable
namespace godotVmcSharp
{
public class VmcExtVrm : VmcMessage
{
public readonly string Path;
public readonly string Title;
public readonly string Hash;
public readonly string? Hash;
public VmcExtVrm(OscMessage m) : base(m.Address)
public static VmcExtVrm? CreateFromMessage(OscMessage m)
{
switch (m.Data.Count)
{
case 2:
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "path", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "title", 's', m.Data[1].Type));
return;
}
Path = (string)m.Data[0].Value;
Title = (string)m.Data[1].Value;
Hash = "";
break;
case 3:
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "path", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "title", 's', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(Addr, "hash", 's', m.Data[1].Type));
return;
}
Path = (string)m.Data[0].Value;
Title = (string)m.Data[1].Value;
Hash = (string)m.Data[2].Value;
break;
return new VmcExtVrm(m.Data[0].GetAsString(), m.Data[1].GetAsString());
case 1:
case 0:
throw new MissingArgumentsException(m.Address, "2 <= count <= 3", m.Data.Count);
default:
GD.Print($"Invalid number of arguments for {Addr} message. Expected 2 or 3 but received {m.Data.Count}");
return;
return new VmcExtVrm(m.Data[0].GetAsString(), m.Data[1].GetAsString(), m.Data[2].GetAsString());
}
}
@ -77,7 +47,6 @@ namespace godotVmcSharp
{
Path = path;
Title = title;
Hash = "";
}
public VmcExtVrm(string path, string title, string hash) : base(new OscAddress("/VMC/Ext/VRM"))
@ -92,15 +61,15 @@ namespace godotVmcSharp
if (Hash == null)
{
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Path, 's'),
new OscArgument(Title, 's')
OscArgument.CreateFromParams(Path, 's')!,
OscArgument.CreateFromParams(Title, 's')!
});
}
return new OscMessage(Addr, new List<OscArgument>{
new OscArgument(Path, 's'),
new OscArgument(Title, 's'),
new OscArgument(Hash, 's')
OscArgument.CreateFromParams(Path, 's')!,
OscArgument.CreateFromParams(Title, 's')!,
OscArgument.CreateFromParams(Hash, 's')!
});
}
}
}
}