From 5ac0de5c6812f2d63ecdb85ef6d2d43e0c34600c Mon Sep 17 00:00:00 2001 From: xLinka Date: Thu, 20 Apr 2023 00:16:49 +0100 Subject: [PATCH 01/17] Get Stock Price Node - Yahoo Finance API Shrug --- NEOSPlus/Logix/Network/Get Stock Price.cs | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 NEOSPlus/Logix/Network/Get Stock Price.cs diff --git a/NEOSPlus/Logix/Network/Get Stock Price.cs b/NEOSPlus/Logix/Network/Get Stock Price.cs new file mode 100644 index 0000000..cb80d33 --- /dev/null +++ b/NEOSPlus/Logix/Network/Get Stock Price.cs @@ -0,0 +1,72 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; +using Newtonsoft.Json.Linq; + +namespace FrooxEngine.LogiX.Network +{ + [Category("LogiX/Network")] + [NodeName("Get Stock Price")] + public class GetStockPriceNode : LogixNode + { + public readonly Impulse onSent; + public readonly Impulse onResponse; + public readonly Impulse onError; + public readonly Input stockSymbol; + public readonly Output stockPrice; + public readonly Output statusCode; + + [ImpulseTarget] + public void SendRequest() => StartTask(new Func(this.RunRequest)); + + private async Task RunRequest() + { + string symbol = stockSymbol.Evaluate(); + if (string.IsNullOrEmpty(symbol)) + { + UniLog.Warning("Stock symbol is empty."); + onError.Trigger(); + return; + } + + string requestUrl = $"https://query1.finance.yahoo.com/v8/finance/chart/{symbol}?interval=1d"; + + if (await Engine.Security.RequestAccessPermission("query1.finance.yahoo.com", 443, null) != HostAccessPermission.Allowed) + { + UniLog.Warning("Access to the Yahoo Finance API was not granted."); + onError.Trigger(); + return; + } + + // Send the request to Yahoo Finance API and wait for the response + using (HttpClient client = new HttpClient()) + using (HttpResponseMessage response = await client.GetAsync(requestUrl)) + using (HttpContent content = response.Content) + { + string responseString = await content.ReadAsStringAsync(); + JObject jsonResponse = JObject.Parse(responseString); + + // Extract the stock price from the response JSON + JArray resultArray = (JArray)jsonResponse["chart"]["result"]; + if (resultArray.Count == 0) + { + UniLog.Warning($"Failed to get stock price for symbol '{symbol}'."); + onError.Trigger(); + return; + } + + JObject result = (JObject)resultArray[0]; + JObject meta = (JObject)result["meta"]; + decimal price = (decimal)meta["regularMarketPrice"]; + + // Return the stock price as output + stockPrice.Value = price; + statusCode.Value = (int)response.StatusCode; + onResponse.Trigger(); + } + } + } +} From 5a72392d8c59436256e14f1c46e5b020e6b8bc87 Mon Sep 17 00:00:00 2001 From: xLinka Date: Thu, 20 Apr 2023 22:04:59 +0100 Subject: [PATCH 02/17] Create RandomEuler.cs @Readun asked for this --- NEOSPlus/Logix/Math/Random/RandomEuler.cs | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 NEOSPlus/Logix/Math/Random/RandomEuler.cs diff --git a/NEOSPlus/Logix/Math/Random/RandomEuler.cs b/NEOSPlus/Logix/Math/Random/RandomEuler.cs new file mode 100644 index 0000000..4cfbe89 --- /dev/null +++ b/NEOSPlus/Logix/Math/Random/RandomEuler.cs @@ -0,0 +1,25 @@ +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; + +[Category("LogiX/Math/Random")] +[NodeName("Random Euler Angles")] +public class RandomEulerAngles : LogixNode +{ + public readonly Input minPitch; + public readonly Input maxPitch; + public readonly Input minYaw; + public readonly Input maxYaw; + public readonly Input minRoll; + public readonly Input maxRoll; + public readonly Output euler; + + protected override void OnEvaluate() + { + float pitch = RandomX.Range(minPitch.Evaluate(), maxPitch.Evaluate()); + float yaw = RandomX.Range(minYaw.Evaluate(), maxYaw.Evaluate()); + float roll = RandomX.Range(minRoll.Evaluate(), maxRoll.Evaluate()); + + euler.Value = new float3(pitch, yaw, roll); + } +} From 04dd236c718f0c98e7b96399fb21b5f2196333a5 Mon Sep 17 00:00:00 2001 From: xLinka Date: Mon, 8 May 2023 15:12:41 +0100 Subject: [PATCH 03/17] New Nodes Is User Eye Tracking Color To CYMK HMAC --- NEOSPlus/Hardware/Is User Eye Tracking.cs | 34 ++++++++++++ NEOSPlus/Logix/Color/Color to CMYK.cs | 36 +++++++++++++ NEOSPlus/Logix/String/HMAC.cs | 66 +++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 NEOSPlus/Hardware/Is User Eye Tracking.cs create mode 100644 NEOSPlus/Logix/Color/Color to CMYK.cs create mode 100644 NEOSPlus/Logix/String/HMAC.cs diff --git a/NEOSPlus/Hardware/Is User Eye Tracking.cs b/NEOSPlus/Hardware/Is User Eye Tracking.cs new file mode 100644 index 0000000..f478c3d --- /dev/null +++ b/NEOSPlus/Hardware/Is User Eye Tracking.cs @@ -0,0 +1,34 @@ +using FrooxEngine; +using FrooxEngine.LogiX; +using FrooxEngine.UIX; + +[Category("LogiX/Hardware")] +[NodeName("IsUserEyeTracking")] +public class IsUserEyeTracking : LogixNode +{ + public readonly Input User; + public readonly Input Side; + public readonly Output EyeTracking; + + private EyeTrackingStreamManager eyeTrackingStreamManager; + + protected override void OnAttach() + { + eyeTrackingStreamManager = base.LocalUserRoot.GetRegisteredComponent(); + } + + protected override void OnEvaluate() + { + User user = User.Evaluate(); + if (user != null) + { + EyeSide side = EyeSide.Left; // or EyeSide.Right, depending on which eye you want to track + bool eyeTracking = eyeTrackingStreamManager.GetIsTracking(side); + EyeTracking.Value = eyeTracking; + } + else + { + EyeTracking.Value = false; + } + } +} diff --git a/NEOSPlus/Logix/Color/Color to CMYK.cs b/NEOSPlus/Logix/Color/Color to CMYK.cs new file mode 100644 index 0000000..6142595 --- /dev/null +++ b/NEOSPlus/Logix/Color/Color to CMYK.cs @@ -0,0 +1,36 @@ +using System; +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; +using FrooxEngine.LogiX.Color; + +[Category(new string[] { "LogiX/Color" })] +[NodeName("Color To CMYK")] +public class ColorToCMYK : LogixNode +{ + public readonly Input Color; + public readonly Output C; + public readonly Output M; + public readonly Output Y; + public readonly Output K; + + protected override void OnEvaluate() + { + color c = Color.Evaluate(); + + float rPrime = c.r / 255f; + float gPrime = c.g / 255f; + float bPrime = c.b / 255f; + + float k = 1 - Math.Max(rPrime, Math.Max(gPrime, bPrime)); + + float cPrime = (1 - rPrime - k) / (1 - k); + float mPrime = (1 - gPrime - k) / (1 - k); + float yPrime = (1 - bPrime - k) / (1 - k); + + C.Value = (float)Math.Round(cPrime * 100f); + M.Value = (float)Math.Round(mPrime * 100f); + Y.Value = (float)Math.Round(yPrime * 100f); + K.Value = (float)Math.Round(k * 100f); + } +} diff --git a/NEOSPlus/Logix/String/HMAC.cs b/NEOSPlus/Logix/String/HMAC.cs new file mode 100644 index 0000000..168a716 --- /dev/null +++ b/NEOSPlus/Logix/String/HMAC.cs @@ -0,0 +1,66 @@ +using System; +using System.Security.Cryptography; +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; + +public enum HashFunction +{ + MD5, + SHA1, + SHA256, + SHA384, + SHA512 +} + +[Category("Security")] +[NodeName("HMAC")] +public class HMACNode : LogixNode +{ + public readonly Input Message; + public readonly Input Key; + public readonly Input HashAlgorithm; + + public readonly Output Result; + + protected override void OnEvaluate() + { + string message = Message.Evaluate(); + string key = Key.Evaluate(); + HashFunction hashFunction = HashAlgorithm.Evaluate(); + + if (string.IsNullOrEmpty(message) || string.IsNullOrEmpty(key)) + { + Result.Value = ""; + return; + } + + byte[] keyBytes = System.Text.Encoding.UTF8.GetBytes(key); + byte[] messageBytes = System.Text.Encoding.UTF8.GetBytes(message); + + using (HMAC hmac = GetHMAC(hashFunction, keyBytes)) + { + byte[] hash = hmac.ComputeHash(messageBytes); + Result.Value = BitConverter.ToString(hash).Replace("-", ""); + } + } + + private HMAC GetHMAC(HashFunction hashFunction, byte[] key) + { + switch (hashFunction) + { + case HashFunction.MD5: + return new HMACMD5(key); + case HashFunction.SHA1: + return new HMACSHA1(key); + case HashFunction.SHA256: + return new HMACSHA256(key); + case HashFunction.SHA384: + return new HMACSHA384(key); + case HashFunction.SHA512: + return new HMACSHA512(key); + default: + throw new ArgumentException($"Unsupported hash function {hashFunction}"); + } + } +} From 4e50e1acee4e9c6af0b41a315a6e245ba06f8634 Mon Sep 17 00:00:00 2001 From: xLinka Date: Mon, 8 May 2023 16:16:05 +0100 Subject: [PATCH 04/17] Update HMAC.cs --- NEOSPlus/Logix/String/HMAC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEOSPlus/Logix/String/HMAC.cs b/NEOSPlus/Logix/String/HMAC.cs index 168a716..0d16e7d 100644 --- a/NEOSPlus/Logix/String/HMAC.cs +++ b/NEOSPlus/Logix/String/HMAC.cs @@ -13,7 +13,7 @@ public enum HashFunction SHA512 } -[Category("Security")] +[Category("LogiX/String")] [NodeName("HMAC")] public class HMACNode : LogixNode { From 93e8284065900b4ff9ed2ada1380de71577c5fe3 Mon Sep 17 00:00:00 2001 From: xLinka Date: Thu, 11 May 2023 20:03:41 +0100 Subject: [PATCH 05/17] Added Get Tracker Battery Level Node --- NEOSPlus/Hardware/FileName.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 NEOSPlus/Hardware/FileName.cs diff --git a/NEOSPlus/Hardware/FileName.cs b/NEOSPlus/Hardware/FileName.cs new file mode 100644 index 0000000..2f75351 --- /dev/null +++ b/NEOSPlus/Hardware/FileName.cs @@ -0,0 +1,34 @@ +using System; +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; +using System.Linq; +using System.Collections.Generic; + +[Category("LogiX/Users")] +[NodeName("GetTrackerBatteryLevel")] +public class GetTrackerBatteryLevel : LogixNode +{ + public readonly Input User; + public readonly Input TrackerIndex; + public readonly Output BatteryLevel; + + protected override void OnEvaluate() + { + User user = User.Evaluate(); + int trackerIndex = TrackerIndex.Evaluate(); + + if (user != null) + { + List trackers = user.InputInterface.GetDevices().ToList(); + if (trackerIndex >= 0 && trackerIndex < trackers.Count) + { + ViveTracker tracker = trackers[trackerIndex]; + BatteryLevel.Value = tracker.BatteryLevel.Value; + return; + } + } + + BatteryLevel.Value = 0f; + } +} From 8c8267147a39bde6a2ee83971ac1bbb4c8e6948a Mon Sep 17 00:00:00 2001 From: xLinka Date: Thu, 11 May 2023 20:03:46 +0100 Subject: [PATCH 06/17] Update Is User Eye Tracking.cs --- NEOSPlus/Hardware/Is User Eye Tracking.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEOSPlus/Hardware/Is User Eye Tracking.cs b/NEOSPlus/Hardware/Is User Eye Tracking.cs index f478c3d..cf039ea 100644 --- a/NEOSPlus/Hardware/Is User Eye Tracking.cs +++ b/NEOSPlus/Hardware/Is User Eye Tracking.cs @@ -1,8 +1,8 @@ using FrooxEngine; using FrooxEngine.LogiX; using FrooxEngine.UIX; - -[Category("LogiX/Hardware")] +//this is experimental not tested using a normal user. +[Category("LogiX/Users")] [NodeName("IsUserEyeTracking")] public class IsUserEyeTracking : LogixNode { From 2751397e3fb6d27c952b06e95d98ddd4d8a4b6ce Mon Sep 17 00:00:00 2001 From: xLinka Date: Thu, 11 May 2023 20:04:51 +0100 Subject: [PATCH 07/17] Cleanup --- .../FileName.cs => Logix/Users/GetTrackerBatteryLevel.cs} | 0 NEOSPlus/{Hardware => Logix/Users}/Is User Eye Tracking.cs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename NEOSPlus/{Hardware/FileName.cs => Logix/Users/GetTrackerBatteryLevel.cs} (100%) rename NEOSPlus/{Hardware => Logix/Users}/Is User Eye Tracking.cs (100%) diff --git a/NEOSPlus/Hardware/FileName.cs b/NEOSPlus/Logix/Users/GetTrackerBatteryLevel.cs similarity index 100% rename from NEOSPlus/Hardware/FileName.cs rename to NEOSPlus/Logix/Users/GetTrackerBatteryLevel.cs diff --git a/NEOSPlus/Hardware/Is User Eye Tracking.cs b/NEOSPlus/Logix/Users/Is User Eye Tracking.cs similarity index 100% rename from NEOSPlus/Hardware/Is User Eye Tracking.cs rename to NEOSPlus/Logix/Users/Is User Eye Tracking.cs From 3f220f5c6343b077ba28d7af1b4ebfda94bcea4f Mon Sep 17 00:00:00 2001 From: art0007i Date: Fri, 12 May 2023 18:52:21 +0200 Subject: [PATCH 08/17] tracker batteries better --- .../GetTrackerBatteryLevel.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) rename NEOSPlus/Logix/{Users => Input Devices}/GetTrackerBatteryLevel.cs (62%) diff --git a/NEOSPlus/Logix/Users/GetTrackerBatteryLevel.cs b/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs similarity index 62% rename from NEOSPlus/Logix/Users/GetTrackerBatteryLevel.cs rename to NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs index 2f75351..f4a9fa6 100644 --- a/NEOSPlus/Logix/Users/GetTrackerBatteryLevel.cs +++ b/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs @@ -5,25 +5,23 @@ using System.Linq; using System.Collections.Generic; -[Category("LogiX/Users")] +[Category("LogiX/Imput Devices")] [NodeName("GetTrackerBatteryLevel")] public class GetTrackerBatteryLevel : LogixNode { public readonly Input User; - public readonly Input TrackerIndex; + public readonly Input TrackerIndex; public readonly Output BatteryLevel; protected override void OnEvaluate() { User user = User.Evaluate(); - int trackerIndex = TrackerIndex.Evaluate(); - if (user != null) { - List trackers = user.InputInterface.GetDevices().ToList(); - if (trackerIndex >= 0 && trackerIndex < trackers.Count) + var trackerIndex = TrackerIndex.Evaluate(); + ViveTracker tracker = user.InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == trackerIndex); + if (tracker != null) { - ViveTracker tracker = trackers[trackerIndex]; BatteryLevel.Value = tracker.BatteryLevel.Value; return; } From 130dfbab5d5ea2740ecaa197798d043a64513334 Mon Sep 17 00:00:00 2001 From: art0007i Date: Fri, 12 May 2023 18:59:56 +0200 Subject: [PATCH 09/17] it wasn't working correctly before --- .../Input Devices/GetTrackerBatteryLevel.cs | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs b/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs index f4a9fa6..6d17795 100644 --- a/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs +++ b/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs @@ -10,23 +10,43 @@ public class GetTrackerBatteryLevel : LogixNode { public readonly Input User; - public readonly Input TrackerIndex; + public readonly Input BodyNode; public readonly Output BatteryLevel; + public readonly Output IsBatteryCharging; - protected override void OnEvaluate() + private ViveTracker _lastTracker; + protected readonly SyncRef> _batteryLevelStream; + protected readonly SyncRef> _batteryChargingStream; + + protected override void OnCommonUpdate() { + base.OnCommonUpdate(); User user = User.Evaluate(); - if (user != null) + var bodyNode = BodyNode.Evaluate(); + if (user == base.LocalUser) { - var trackerIndex = TrackerIndex.Evaluate(); - ViveTracker tracker = user.InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == trackerIndex); - if (tracker != null) + ViveTracker device = InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == bodyNode); + if (device != _lastTracker) { - BatteryLevel.Value = tracker.BatteryLevel.Value; - return; + _batteryLevelStream.Target = device?.BatteryLevel.GetStream(base.World); + _batteryChargingStream.Target = device?.BatteryCharging.GetStream(base.World); + _lastTracker = device; } } + else + { + _lastTracker = null; + if (base.World.IsAuthority && user == null) + { + _batteryLevelStream.Target = null; + _batteryChargingStream.Target = null; + } + } + } - BatteryLevel.Value = 0f; + protected override void OnEvaluate() + { + BatteryLevel.Value = _batteryLevelStream.Target?.Value ?? (-1f); + IsBatteryCharging.Value = _batteryChargingStream.Target?.Value ?? false; } } From e23e152150b7f21745b9525d145896adee2d7695 Mon Sep 17 00:00:00 2001 From: art0007i Date: Fri, 12 May 2023 19:27:10 +0200 Subject: [PATCH 10/17] untested shit. it might be fucked --- .../Input Devices/GetTrackerBatteryLevel.cs | 52 ------------------ .../Input Devices/LocalViveTrackerCount.cs | 40 ++++++++++++++ .../Logix/Input Devices/TrackerBatteryBase.cs | 53 +++++++++++++++++++ .../Input Devices/ViveTrackerByBodyNode.cs | 20 +++++++ .../Logix/Input Devices/ViveTrackerByIndex.cs | 24 +++++++++ 5 files changed, 137 insertions(+), 52 deletions(-) delete mode 100644 NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs create mode 100644 NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs create mode 100644 NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs create mode 100644 NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs create mode 100644 NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs diff --git a/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs b/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs deleted file mode 100644 index 6d17795..0000000 --- a/NEOSPlus/Logix/Input Devices/GetTrackerBatteryLevel.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using BaseX; -using FrooxEngine; -using FrooxEngine.LogiX; -using System.Linq; -using System.Collections.Generic; - -[Category("LogiX/Imput Devices")] -[NodeName("GetTrackerBatteryLevel")] -public class GetTrackerBatteryLevel : LogixNode -{ - public readonly Input User; - public readonly Input BodyNode; - public readonly Output BatteryLevel; - public readonly Output IsBatteryCharging; - - private ViveTracker _lastTracker; - protected readonly SyncRef> _batteryLevelStream; - protected readonly SyncRef> _batteryChargingStream; - - protected override void OnCommonUpdate() - { - base.OnCommonUpdate(); - User user = User.Evaluate(); - var bodyNode = BodyNode.Evaluate(); - if (user == base.LocalUser) - { - ViveTracker device = InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == bodyNode); - if (device != _lastTracker) - { - _batteryLevelStream.Target = device?.BatteryLevel.GetStream(base.World); - _batteryChargingStream.Target = device?.BatteryCharging.GetStream(base.World); - _lastTracker = device; - } - } - else - { - _lastTracker = null; - if (base.World.IsAuthority && user == null) - { - _batteryLevelStream.Target = null; - _batteryChargingStream.Target = null; - } - } - } - - protected override void OnEvaluate() - { - BatteryLevel.Value = _batteryLevelStream.Target?.Value ?? (-1f); - IsBatteryCharging.Value = _batteryChargingStream.Target?.Value ?? false; - } -} diff --git a/NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs b/NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs new file mode 100644 index 0000000..3dc52c3 --- /dev/null +++ b/NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FrooxEngine; +using FrooxEngine.LogiX; + +namespace NEOSPlus.Logix.Input_Devices +{ + public class ViveTrackerCount : LogixNode + { + public readonly Input User; + public readonly Output Count; + + public readonly Sync _count; + + protected override void OnCommonUpdate() + { + base.OnCommonUpdate(); + User user = User.Evaluate(); + if (user == base.LocalUser) + { + _count.Value = InputInterface.GetDevices().Count; + } + else + { + if (World.IsAuthority && user == null) + { + _count.Value = -1; + } + } + } + + protected override void OnEvaluate() + { + Count.Value = _count.Value; + } + } +} diff --git a/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs new file mode 100644 index 0000000..365d84f --- /dev/null +++ b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FrooxEngine; +using FrooxEngine.LogiX; + +namespace NEOSPlus.Logix.Input_Devices +{ + public abstract class TrackerBatteryBase : LogixNode + { + public readonly Input User; + public readonly Output BatteryLevel; + public readonly Output IsBatteryCharging; + + internal ViveTracker _lastTracker; + protected readonly SyncRef> _batteryLevelStream; + protected readonly SyncRef> _batteryChargingStream; + + internal abstract ViveTracker GetViveTracker(); + + protected override void OnCommonUpdate() + { + base.OnCommonUpdate(); + User user = User.Evaluate(); + if (user == base.LocalUser) + { + ViveTracker device = GetViveTracker(); + if (device != _lastTracker) + { + _batteryLevelStream.Target = device?.BatteryLevel.GetStream(base.World); + _batteryChargingStream.Target = device?.BatteryCharging.GetStream(base.World); + _lastTracker = device; + } + } + else + { + _lastTracker = null; + if (base.World.IsAuthority && user == null) + { + _batteryLevelStream.Target = null; + _batteryChargingStream.Target = null; + } + } + } + protected override void OnEvaluate() + { + BatteryLevel.Value = _batteryLevelStream.Target?.Value ?? (-1f); + IsBatteryCharging.Value = _batteryChargingStream.Target?.Value ?? false; + } + } +} diff --git a/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs new file mode 100644 index 0000000..4625712 --- /dev/null +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs @@ -0,0 +1,20 @@ +using System; +using BaseX; +using FrooxEngine; +using FrooxEngine.LogiX; +using System.Linq; +using System.Collections.Generic; +using NEOSPlus.Logix.Input_Devices; + +[Category("LogiX/Imput Devices")] +[NodeName("GetTrackerBatteryLevel")] +public class ViveTrackerByBodyNode : TrackerBatteryBase +{ + public readonly Input BodyNode; + + internal override ViveTracker GetViveTracker() + { + var bodyNode = BodyNode.Evaluate(); + return InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == bodyNode); + } +} diff --git a/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs new file mode 100644 index 0000000..cfcba3f --- /dev/null +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FrooxEngine; +using FrooxEngine.LogiX; + +namespace NEOSPlus.Logix.Input_Devices +{ + public class ViveTrackerByIndex : TrackerBatteryBase + { + public readonly Input TrackerIndex; + + internal override ViveTracker GetViveTracker() + { + var idx = TrackerIndex.Evaluate(); + if (idx < 0) return null; + var trackers = InputInterface.GetDevices(); + if (idx > trackers.Count) return null; + return trackers[idx]; + } + } +} From 36213139465d7d5e5f01be96a3dd96f840a12dbc Mon Sep 17 00:00:00 2001 From: art0007i Date: Sun, 14 May 2023 23:18:34 +0200 Subject: [PATCH 11/17] improve battery nodes --- NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs | 2 ++ NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs | 3 +-- NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs | 3 ++- .../{LocalViveTrackerCount.cs => ViveTrackerCount.cs} | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) rename NEOSPlus/Logix/Input Devices/{LocalViveTrackerCount.cs => ViveTrackerCount.cs} (96%) diff --git a/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs index 365d84f..8c90a3f 100644 --- a/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs +++ b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs @@ -8,6 +8,8 @@ namespace NEOSPlus.Logix.Input_Devices { + // TODO: check in multiplayer to make sure this all syncs correctly. + public abstract class TrackerBatteryBase : LogixNode { public readonly Input User; diff --git a/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs index 4625712..4994880 100644 --- a/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs @@ -6,8 +6,7 @@ using System.Collections.Generic; using NEOSPlus.Logix.Input_Devices; -[Category("LogiX/Imput Devices")] -[NodeName("GetTrackerBatteryLevel")] +[Category("LogiX/Input Devices")] public class ViveTrackerByBodyNode : TrackerBatteryBase { public readonly Input BodyNode; diff --git a/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs index cfcba3f..d49cc7a 100644 --- a/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerByIndex.cs @@ -8,6 +8,7 @@ namespace NEOSPlus.Logix.Input_Devices { + [Category("LogiX/Input Devices")] public class ViveTrackerByIndex : TrackerBatteryBase { public readonly Input TrackerIndex; @@ -17,7 +18,7 @@ internal override ViveTracker GetViveTracker() var idx = TrackerIndex.Evaluate(); if (idx < 0) return null; var trackers = InputInterface.GetDevices(); - if (idx > trackers.Count) return null; + if (idx >= trackers.Count) return null; return trackers[idx]; } } diff --git a/NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerCount.cs similarity index 96% rename from NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs rename to NEOSPlus/Logix/Input Devices/ViveTrackerCount.cs index 3dc52c3..0bcd2cb 100644 --- a/NEOSPlus/Logix/Input Devices/LocalViveTrackerCount.cs +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerCount.cs @@ -8,6 +8,7 @@ namespace NEOSPlus.Logix.Input_Devices { + [Category("LogiX/Input Devices")] public class ViveTrackerCount : LogixNode { public readonly Input User; From 3dbbb0d7663e1956ab4b765ebfc2f9e35161640d Mon Sep 17 00:00:00 2001 From: xLinka Date: Fri, 16 Jun 2023 18:43:38 +0100 Subject: [PATCH 12/17] Changes Made Changes Made --- NEOSPlus/Logix/Color/Color to CMYK.cs | 6 +++--- NEOSPlus/Logix/Users/Is User Eye Tracking.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NEOSPlus/Logix/Color/Color to CMYK.cs b/NEOSPlus/Logix/Color/Color to CMYK.cs index 6142595..7b5e0ae 100644 --- a/NEOSPlus/Logix/Color/Color to CMYK.cs +++ b/NEOSPlus/Logix/Color/Color to CMYK.cs @@ -18,9 +18,9 @@ protected override void OnEvaluate() { color c = Color.Evaluate(); - float rPrime = c.r / 255f; - float gPrime = c.g / 255f; - float bPrime = c.b / 255f; + float rPrime = c.r; + float gPrime = c.g; + float bPrime = c.b; float k = 1 - Math.Max(rPrime, Math.Max(gPrime, bPrime)); diff --git a/NEOSPlus/Logix/Users/Is User Eye Tracking.cs b/NEOSPlus/Logix/Users/Is User Eye Tracking.cs index cf039ea..d062252 100644 --- a/NEOSPlus/Logix/Users/Is User Eye Tracking.cs +++ b/NEOSPlus/Logix/Users/Is User Eye Tracking.cs @@ -1,7 +1,7 @@ using FrooxEngine; using FrooxEngine.LogiX; using FrooxEngine.UIX; -//this is experimental not tested using a normal user. + [Category("LogiX/Users")] [NodeName("IsUserEyeTracking")] public class IsUserEyeTracking : LogixNode @@ -22,7 +22,7 @@ protected override void OnEvaluate() User user = User.Evaluate(); if (user != null) { - EyeSide side = EyeSide.Left; // or EyeSide.Right, depending on which eye you want to track + EyeSide side = Side.Evaluate(); // Get the EyeSide value from the input bool eyeTracking = eyeTrackingStreamManager.GetIsTracking(side); EyeTracking.Value = eyeTracking; } From 2b42f2d24978069ca975ee032ec167cb079b8e24 Mon Sep 17 00:00:00 2001 From: xLinka Date: Sat, 17 Jun 2023 15:39:08 +0100 Subject: [PATCH 13/17] Update Is User Eye Tracking.cs Fixing the issue of breaking on users without --- NEOSPlus/Logix/Users/Is User Eye Tracking.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NEOSPlus/Logix/Users/Is User Eye Tracking.cs b/NEOSPlus/Logix/Users/Is User Eye Tracking.cs index d062252..e670898 100644 --- a/NEOSPlus/Logix/Users/Is User Eye Tracking.cs +++ b/NEOSPlus/Logix/Users/Is User Eye Tracking.cs @@ -1,6 +1,5 @@ using FrooxEngine; using FrooxEngine.LogiX; -using FrooxEngine.UIX; [Category("LogiX/Users")] [NodeName("IsUserEyeTracking")] @@ -20,7 +19,7 @@ protected override void OnAttach() protected override void OnEvaluate() { User user = User.Evaluate(); - if (user != null) + if (user != null && eyeTrackingStreamManager != null) { EyeSide side = Side.Evaluate(); // Get the EyeSide value from the input bool eyeTracking = eyeTrackingStreamManager.GetIsTracking(side); From 2311ef3d8f016d85ff721c0df0bfba3f9ce002b5 Mon Sep 17 00:00:00 2001 From: xLinka Date: Sat, 17 Jun 2023 17:23:13 +0100 Subject: [PATCH 14/17] Update Color to CMYK.cs beep boop --- NEOSPlus/Logix/Color/Color to CMYK.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/NEOSPlus/Logix/Color/Color to CMYK.cs b/NEOSPlus/Logix/Color/Color to CMYK.cs index 7b5e0ae..e1a7eef 100644 --- a/NEOSPlus/Logix/Color/Color to CMYK.cs +++ b/NEOSPlus/Logix/Color/Color to CMYK.cs @@ -1,10 +1,9 @@ using System; -using BaseX; using FrooxEngine; using FrooxEngine.LogiX; -using FrooxEngine.LogiX.Color; +using BaseX; -[Category(new string[] { "LogiX/Color" })] +[Category("LogiX/Color")] [NodeName("Color To CMYK")] public class ColorToCMYK : LogixNode { @@ -18,15 +17,15 @@ protected override void OnEvaluate() { color c = Color.Evaluate(); - float rPrime = c.r; - float gPrime = c.g; - float bPrime = c.b; + float rPrime = c.r * 255f; + float gPrime = c.g * 255f; + float bPrime = c.b * 255f; - float k = 1 - Math.Max(rPrime, Math.Max(gPrime, bPrime)); + float k = 1 - Math.Max(rPrime, Math.Max(gPrime, bPrime)) / 255f; - float cPrime = (1 - rPrime - k) / (1 - k); - float mPrime = (1 - gPrime - k) / (1 - k); - float yPrime = (1 - bPrime - k) / (1 - k); + float cPrime = (1 - rPrime / 255f - k) / (1 - k); + float mPrime = (1 - gPrime / 255f - k) / (1 - k); + float yPrime = (1 - bPrime / 255f - k) / (1 - k); C.Value = (float)Math.Round(cPrime * 100f); M.Value = (float)Math.Round(mPrime * 100f); From 46b8b0657cdd3f0e054178dfd82910757d4c954c Mon Sep 17 00:00:00 2001 From: xLinka Date: Sat, 17 Jun 2023 22:15:04 +0100 Subject: [PATCH 15/17] fixed also added a rssfeed node for funny --- .../{Color to CMYK.cs => ColorToCMYK.cs} | 0 .../Logix/Input Devices/TrackerBatteryBase.cs | 2 +- .../Input Devices/ViveTrackerByBodyNode.cs | 6 +-- .../{Get Stock Price.cs => GetStockPrice.cs} | 0 NEOSPlus/Logix/Network/RSSFeed.cs | 54 +++++++++++++++++++ ...r Eye Tracking.cs => IsUserEyeTracking.cs} | 0 6 files changed, 56 insertions(+), 6 deletions(-) rename NEOSPlus/Logix/Color/{Color to CMYK.cs => ColorToCMYK.cs} (100%) rename NEOSPlus/Logix/Network/{Get Stock Price.cs => GetStockPrice.cs} (100%) create mode 100644 NEOSPlus/Logix/Network/RSSFeed.cs rename NEOSPlus/Logix/Users/{Is User Eye Tracking.cs => IsUserEyeTracking.cs} (100%) diff --git a/NEOSPlus/Logix/Color/Color to CMYK.cs b/NEOSPlus/Logix/Color/ColorToCMYK.cs similarity index 100% rename from NEOSPlus/Logix/Color/Color to CMYK.cs rename to NEOSPlus/Logix/Color/ColorToCMYK.cs diff --git a/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs index 8c90a3f..fbfefbd 100644 --- a/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs +++ b/NEOSPlus/Logix/Input Devices/TrackerBatteryBase.cs @@ -9,7 +9,7 @@ namespace NEOSPlus.Logix.Input_Devices { // TODO: check in multiplayer to make sure this all syncs correctly. - + // Update 6/17/2023 It Works public abstract class TrackerBatteryBase : LogixNode { public readonly Input User; diff --git a/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs index 4994880..6dbabfe 100644 --- a/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs +++ b/NEOSPlus/Logix/Input Devices/ViveTrackerByBodyNode.cs @@ -11,9 +11,5 @@ public class ViveTrackerByBodyNode : TrackerBatteryBase { public readonly Input BodyNode; - internal override ViveTracker GetViveTracker() - { - var bodyNode = BodyNode.Evaluate(); - return InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == bodyNode); - } + internal override ViveTracker GetViveTracker() => InputInterface.GetDevices().Find((t) => t.CorrespondingBodyNode == BodyNode.Evaluate()); } diff --git a/NEOSPlus/Logix/Network/Get Stock Price.cs b/NEOSPlus/Logix/Network/GetStockPrice.cs similarity index 100% rename from NEOSPlus/Logix/Network/Get Stock Price.cs rename to NEOSPlus/Logix/Network/GetStockPrice.cs diff --git a/NEOSPlus/Logix/Network/RSSFeed.cs b/NEOSPlus/Logix/Network/RSSFeed.cs new file mode 100644 index 0000000..ba37e7e --- /dev/null +++ b/NEOSPlus/Logix/Network/RSSFeed.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Net; +using Newtonsoft.Json.Linq; +using FrooxEngine; +using FrooxEngine.LogiX; +using BaseX; +using System.Xml; + +namespace LogiX.Network +{ + [Category("LogiX/Network")] + [NodeName("RSSFeed")] + public class RSSFeedNode : LogixNode + { + public readonly Input FeedURL; + public readonly Output FeedItems; + + protected override void OnEvaluate() + { + Uri feedURL = FeedURL.Evaluate(); + JArray items = new JArray(); + + try + { + // Retrieve RSS feed content + WebClient client = new WebClient(); + string feedContent = client.DownloadString(feedURL); + + // Parse the XML content + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(feedContent); + + // Extract feed items + XmlNodeList itemNodes = xmlDoc.SelectNodes("//item"); + foreach (XmlNode itemNode in itemNodes) + { + JObject item = new JObject(); + item["title"] = itemNode.SelectSingleNode("title")?.InnerText; + item["description"] = itemNode.SelectSingleNode("description")?.InnerText; + item["pubDate"] = itemNode.SelectSingleNode("pubDate")?.InnerText; + item["link"] = itemNode.SelectSingleNode("link")?.InnerText; + items.Add(item); + } + } + catch (Exception ex) + { + UniLog.Log("Error retrieving or parsing RSS feed: " + ex.Message); + } + + FeedItems.Value = items; + } + } +} diff --git a/NEOSPlus/Logix/Users/Is User Eye Tracking.cs b/NEOSPlus/Logix/Users/IsUserEyeTracking.cs similarity index 100% rename from NEOSPlus/Logix/Users/Is User Eye Tracking.cs rename to NEOSPlus/Logix/Users/IsUserEyeTracking.cs From 52f14b9cf6b5d2ee8377b717230a042c9c0b8525 Mon Sep 17 00:00:00 2001 From: xLinka Date: Sun, 18 Jun 2023 16:22:25 +0100 Subject: [PATCH 16/17] Delete ColorToCMYK.cs Removed this headache for now --- NEOSPlus/Logix/Color/ColorToCMYK.cs | 35 ----------------------------- 1 file changed, 35 deletions(-) delete mode 100644 NEOSPlus/Logix/Color/ColorToCMYK.cs diff --git a/NEOSPlus/Logix/Color/ColorToCMYK.cs b/NEOSPlus/Logix/Color/ColorToCMYK.cs deleted file mode 100644 index e1a7eef..0000000 --- a/NEOSPlus/Logix/Color/ColorToCMYK.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using FrooxEngine; -using FrooxEngine.LogiX; -using BaseX; - -[Category("LogiX/Color")] -[NodeName("Color To CMYK")] -public class ColorToCMYK : LogixNode -{ - public readonly Input Color; - public readonly Output C; - public readonly Output M; - public readonly Output Y; - public readonly Output K; - - protected override void OnEvaluate() - { - color c = Color.Evaluate(); - - float rPrime = c.r * 255f; - float gPrime = c.g * 255f; - float bPrime = c.b * 255f; - - float k = 1 - Math.Max(rPrime, Math.Max(gPrime, bPrime)) / 255f; - - float cPrime = (1 - rPrime / 255f - k) / (1 - k); - float mPrime = (1 - gPrime / 255f - k) / (1 - k); - float yPrime = (1 - bPrime / 255f - k) / (1 - k); - - C.Value = (float)Math.Round(cPrime * 100f); - M.Value = (float)Math.Round(mPrime * 100f); - Y.Value = (float)Math.Round(yPrime * 100f); - K.Value = (float)Math.Round(k * 100f); - } -} From be2a44daa03f07390af16bf949eb3249d0593dbe Mon Sep 17 00:00:00 2001 From: xLinka Date: Sun, 18 Jun 2023 16:28:12 +0100 Subject: [PATCH 17/17] Update RSSFeed.cs --- NEOSPlus/Logix/Network/RSSFeed.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEOSPlus/Logix/Network/RSSFeed.cs b/NEOSPlus/Logix/Network/RSSFeed.cs index ba37e7e..dbc0f20 100644 --- a/NEOSPlus/Logix/Network/RSSFeed.cs +++ b/NEOSPlus/Logix/Network/RSSFeed.cs @@ -10,7 +10,7 @@ namespace LogiX.Network { [Category("LogiX/Network")] - [NodeName("RSSFeed")] + [NodeName("RSS Feed")] public class RSSFeedNode : LogixNode { public readonly Input FeedURL;