Renamed Parameters

This commit is contained in:
glax 2023-11-29 18:18:23 +01:00
parent cf3552a3ae
commit 891d8f3b73

View File

@ -26,7 +26,7 @@ public class OSCCollar
private OscServer Server { get; init; }
private OscClient Client { get; init; }
private float _collarAngle, _collarStretch;
private float _leashAngle, _leashStretch;
private double _leftOrRight = 1;
private double _verticalMovement = 0;
private double _horizontalMovement = 0;
@ -42,12 +42,12 @@ public class OSCCollar
{
this.Server = new OscServer(portReceive);
this.Client = new OscClient(ip, portSend);
this._collarAngle = 0;
this._collarStretch = 0;
Server.TryAddMethod("/avatar/parameters/Collar_Angle", CollarAngleHandle);
Server.TryAddMethod("/avatar/parameters/CollarRight", CollarLeftRightHandle);
Server.TryAddMethod("/avatar/parameters/Collar_Allow_Moving", AllowMovingHandle);
Server.TryAddMethodPair("/avatar/parameters/Collar_Stretch", CollarStretchHandle, CalculateMovement);
this._leashAngle = 0;
this._leashStretch = 0;
Server.TryAddMethod("/avatar/parameters/LeashDirection_Angle", CollarAngleHandle);
Server.TryAddMethod("/avatar/parameters/LeashRight", CollarLeftRightHandle);
Server.TryAddMethod("/avatar/parameters/Leash_Toggle", AllowMovingHandle);
Server.TryAddMethodPair("/avatar/parameters/Leash_Stretch", CollarStretchHandle, CalculateMovement);
this.Server.Start();
Thread runningThread = new Thread(RunningThread);
@ -59,9 +59,9 @@ public class OSCCollar
Console.Clear();
Console.WriteLine($"OSC Collar - Status: {(_allowMoving ? "enabled" : "disabled")}");
Console.WriteLine("===============================================================");
Console.WriteLine($"Angle:...............{_collarAngle:0.0000}");
Console.WriteLine($"Angle:...............{_leashAngle:0.0000}");
Console.WriteLine($"Left/Right:..........{(_leftOrRight < 0 ? "left" : "right")}");
Console.WriteLine($"Stretch:.............{_collarStretch:0.0000}");
Console.WriteLine($"Stretch:.............{_leashStretch:0.0000}");
Console.WriteLine($"Vertical Movement:...{verticalMovement:0.0000}");
Console.WriteLine($"Horizontal Movement:.{horizontalMovement:0.0000}");
Console.SetCursorPosition(0, Console.WindowHeight - 2);
@ -96,7 +96,7 @@ public class OSCCollar
private void CollarAngleHandle(OscMessageValues messageValues)
{
this._collarAngle = messageValues.ReadFloatElement(0);
this._leashAngle = messageValues.ReadFloatElement(0);
}
private void CollarLeftRightHandle(OscMessageValues messageValues)
@ -106,16 +106,16 @@ public class OSCCollar
private void CollarStretchHandle(OscMessageValues messageValues)
{
this._collarStretch = messageValues.ReadFloatElement(0);
this._leashStretch = messageValues.ReadFloatElement(0);
}
private const float PowerAdjust = 0.25f;
private void CalculateMovement()
{
float degrees = _collarAngle * 180;
float degrees = _leashAngle * 180;
double radians = degrees * Math.PI / 180;
_verticalMovement = Math.Cos(radians) * this._collarStretch * PowerAdjust;
_horizontalMovement = Math.Sin(radians) * this._collarStretch * PowerAdjust * _leftOrRight;
_verticalMovement = Math.Cos(radians) * this._leashStretch * PowerAdjust;
_horizontalMovement = Math.Sin(radians) * this._leashStretch * PowerAdjust * _leftOrRight;
}
private void RunningThread()