2023-08-16 19:47:14 +02:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
using System.Net;
|
2023-09-24 18:26:52 +02:00
|
|
|
using godotOscSharp;
|
2023-08-16 19:47:14 +02:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace godotVmcSharp
|
|
|
|
{
|
|
|
|
public class Marionette
|
|
|
|
{
|
2023-09-24 18:26:52 +02:00
|
|
|
private OscReceiver receiver;
|
|
|
|
private OscSender sender;
|
|
|
|
private CameraReceiver cam;
|
|
|
|
private DeviceReceiver devices;
|
|
|
|
private DirectionalLightReceiver lights;
|
2023-08-16 19:47:14 +02:00
|
|
|
public Marionette(int port)
|
|
|
|
{
|
2023-09-24 18:26:52 +02:00
|
|
|
receiver = new OscReceiver(port);
|
2023-08-16 19:47:14 +02:00
|
|
|
receiver.MessageReceived += (sender, e) =>
|
|
|
|
{
|
|
|
|
if (sender == null) {
|
2023-09-24 18:26:52 +02:00
|
|
|
sender = new OscSender(IPAddress.Parse(e.IPAddress), port);
|
2023-08-16 19:47:14 +02:00
|
|
|
}
|
|
|
|
GD.Print($"Received a message from {e.IPAddress}:{e.Port}");
|
|
|
|
ProcessMessage(e.Message);
|
|
|
|
};
|
|
|
|
receiver.ErrorReceived += (sender, e) =>
|
|
|
|
{
|
|
|
|
GD.Print($"Error: {e.ErrorMessage}");
|
|
|
|
};
|
2023-09-24 18:26:52 +02:00
|
|
|
devices = new DeviceReceiver();
|
|
|
|
lights = new DirectionalLightReceiver();
|
2023-08-16 19:47:14 +02:00
|
|
|
}
|
2023-09-24 18:26:52 +02:00
|
|
|
private void ProcessMessage(OscMessage m)
|
2023-08-16 19:47:14 +02:00
|
|
|
{
|
|
|
|
switch (m.Address.ToString())
|
|
|
|
{
|
|
|
|
case "/VMC/Ext/OK":
|
|
|
|
new VmcExtOk(m);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/T":
|
|
|
|
new VmcExtT(m);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Root/Pos":
|
|
|
|
new VmcExtRootPos(m);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Bone/Pos":
|
|
|
|
new VmcExtBonePos(m);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Blend/Val":
|
|
|
|
new VmcExtBlendVal(m);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Blend/Apply":
|
|
|
|
new VmcMessage(m.Address);
|
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Cam":
|
2023-09-24 18:26:52 +02:00
|
|
|
this.cam.ProcessMessage(new VmcExtCam(m));
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Con":
|
2023-08-16 20:07:50 +02:00
|
|
|
new VmcExtCon(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Key":
|
2023-08-16 20:11:20 +02:00
|
|
|
new VmcExtKey(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Midi/Note":
|
2023-08-16 20:16:10 +02:00
|
|
|
new VmcExtMidiNote(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Midi/CC/Val":
|
2023-08-16 20:19:45 +02:00
|
|
|
new VmcExtMidiCcVal(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
|
|
|
case "/VMC/Ext/Midi/CC/Bit":
|
2023-08-16 20:22:23 +02:00
|
|
|
new VmcExtMidiCcBit(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
2023-08-16 19:52:35 +02:00
|
|
|
case "/VMC/Ext/Hmd/Pos":
|
2023-08-16 19:55:42 +02:00
|
|
|
case "/VMC/Ext/Con/Pos":
|
|
|
|
case "/VMC/Ext/Tra/Pos":
|
|
|
|
case "/VMC/Ext/Hmd/Pos/Local":
|
|
|
|
case "/VMC/Ext/Con/Pos/Local":
|
|
|
|
case "/VMC/Ext/Tra/Pos/Local":
|
2023-09-24 18:26:52 +02:00
|
|
|
this.devices.ProcessMessage(new VmcExtDevicePos(m));
|
2023-08-16 19:55:42 +02:00
|
|
|
break;
|
2023-08-16 19:47:14 +02:00
|
|
|
case "/VMC/Ext/Rcv":
|
2023-08-16 20:29:28 +02:00
|
|
|
new VmcExtRcv(m);
|
2023-08-16 19:47:14 +02:00
|
|
|
break;
|
2023-08-16 20:35:37 +02:00
|
|
|
case "/VMC/Ext/Light":
|
2023-09-24 18:31:07 +02:00
|
|
|
this.lights.ProcessMessage(new VmcExtLight(m));
|
2023-08-16 20:35:37 +02:00
|
|
|
break;
|
2023-08-16 20:42:04 +02:00
|
|
|
case "/VMC/Ext/VRM":
|
2023-08-16 20:41:23 +02:00
|
|
|
new VmcExtVrm(m);
|
|
|
|
break;
|
2023-08-16 20:44:45 +02:00
|
|
|
case "/VMC/Ext/Remote":
|
|
|
|
new VmcExtRemote(m);
|
|
|
|
break;
|
2023-08-16 20:59:29 +02:00
|
|
|
case "/VMC/Ext/Opt":
|
2023-08-16 20:58:58 +02:00
|
|
|
new VmcExtOpt(m);
|
|
|
|
break;
|
2023-08-16 21:03:41 +02:00
|
|
|
case "/VMC/Ext/Setting/Color":
|
|
|
|
new VmcExtSettingColor(m);
|
|
|
|
break;
|
2023-08-16 21:08:12 +02:00
|
|
|
case "/VMC/Ext/Setting/Win":
|
|
|
|
new VmcExtSettingWin(m);
|
|
|
|
break;
|
2023-08-16 21:26:36 +02:00
|
|
|
case "/VMC/Ext/Config":
|
|
|
|
new VmcExtConfig(m);
|
|
|
|
break;
|
2023-08-16 19:47:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|