From e54cca454bb2e0a5c2dea1d26464e978cf1b1620 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 18 Sep 2020 12:37:02 +0200 Subject: [PATCH 1/3] added null message --- RH-Engine/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index acb210b..f127687 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -95,8 +95,8 @@ namespace RH_Engine //string command = createGraphics.TerrainCommand(new int[] { 256, 256 }, heigths); - string groundId = GetId("GroundPlane", stream, createGraphics); - Console.WriteLine("ground id: " + groundId); + string groundId = GetId(CreateGraphics.STANDARD_SUN, stream, createGraphics); + Console.WriteLine("id: " + groundId); string command = createGraphics.DeleteGroundPaneCommand(groundId); //string command = createGraphics.ResetScene(); Console.WriteLine("tunnelID is: " + tunnelID); @@ -119,7 +119,7 @@ namespace RH_Engine return child.uuid; } } - + Console.WriteLine("Could not find id of " + name); return null; } From bb70d80409843e0267a89ee63f57d1283675d10a Mon Sep 17 00:00:00 2001 From: shinichi Date: Fri, 18 Sep 2020 12:50:53 +0200 Subject: [PATCH 2/3] added bike --- RH-Engine/CreateGraphics.cs | 22 ++++++++++++---------- RH-Engine/Program.cs | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/RH-Engine/CreateGraphics.cs b/RH-Engine/CreateGraphics.cs index c4df8a9..ceda29c 100644 --- a/RH-Engine/CreateGraphics.cs +++ b/RH-Engine/CreateGraphics.cs @@ -16,8 +16,8 @@ namespace RH_Engine - string tunnelID; - + string tunnelID; + public CreateGraphics(string tunnelID) { this.tunnelID = tunnelID; @@ -53,12 +53,12 @@ namespace RH_Engine data = new { id = uuid, - + } }; return JsonConvert.SerializeObject(Payload(payload)); - + } public string ModelCommand() @@ -74,10 +74,10 @@ namespace RH_Engine { model = new { - file = "\\data\\NetworkEngine\\models\\bike\\bikee.fbx", + file = "data\\NetworkEngine\\models\\bike\\bike.fbx", cullbackfaces = true, animated = false, - animation = "\\data\\NetworkEngine\\models\\bike\\bike_anim.fbx" + animation = "data\\NetworkEngine\\models\\bike\\bike_anim.fbx" }, } } @@ -86,6 +86,7 @@ namespace RH_Engine return JsonConvert.SerializeObject(Payload(payload)); } + public string RouteCommand() { return ""; @@ -132,10 +133,11 @@ namespace RH_Engine dynamic payload = new { id = "scene/skybox/settime", - data = new { + data = new + { time = timeToSet } - + }; return JsonConvert.SerializeObject(Payload(payload)); @@ -154,7 +156,7 @@ namespace RH_Engine }; } - - + + } } diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index acb210b..98d4599 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -13,12 +13,13 @@ namespace RH_Engine internal class Program { private static PC[] PCs = { - new PC("DESKTOP-M2CIH87", "Fabian"), + //new PC("DESKTOP-M2CIH87", "Fabian"), new PC("T470S", "Shinichi"), - new PC("DESKTOP-DHS478C", "semme"), - new PC("DESKTOP-TV73FKO", "Wouter"), - new PC("NA", "Ralf"), - new PC("NA", "Bart") }; + //new PC("DESKTOP-DHS478C", "semme"), + //new PC("DESKTOP-TV73FKO", "Wouter"), + //new PC("NA", "Ralf"), + //new PC("NA", "Bart") + }; private static void Main(string[] args) { TcpClient client = new TcpClient("145.48.6.10", 6666); @@ -97,13 +98,23 @@ namespace RH_Engine string groundId = GetId("GroundPlane", stream, createGraphics); Console.WriteLine("ground id: " + groundId); - string command = createGraphics.DeleteGroundPaneCommand(groundId); + string command; + //command = createGraphics.DeleteGroundPaneCommand(groundId); //string command = createGraphics.ResetScene(); + command = createGraphics.SkyboxCommand(DateTime.Now.Millisecond % 24); Console.WriteLine("tunnelID is: " + tunnelID); WriteTextMessage(stream, command); Console.WriteLine(ReadPrefMessage(stream)); + + command = createGraphics.ModelCommand(); + + WriteTextMessage(stream, command); + + Console.WriteLine(ReadPrefMessage(stream)); + + } public static string GetId(string name, NetworkStream stream, CreateGraphics createGraphics) From c82f1e9537a61209290f53d8c66164ef12ab4be7 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 18 Sep 2020 12:53:14 +0200 Subject: [PATCH 3/3] comments --- RH-Engine/Program.cs | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index f127687..d0988b9 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -106,11 +106,16 @@ namespace RH_Engine Console.WriteLine(ReadPrefMessage(stream)); } + /// + /// gets the id of the object with the given name + /// + /// the name of the object + /// the network stream to send requests to + /// the create graphics object to create all the commands + /// the uuid of the object with the given name, null otherwise. public static string GetId(string name, NetworkStream stream, CreateGraphics createGraphics) { - WriteTextMessage(stream, createGraphics.GetSceneInfoCommand()); - dynamic response = JsonConvert.DeserializeObject(ReadPrefMessage(stream)); - JArray children = response.data.data.data.children; + JArray children = GetChildren(stream, createGraphics); foreach (dynamic child in children) { @@ -124,6 +129,41 @@ namespace RH_Engine } + /// + /// gets all the children in the current scene + /// + /// the network stream to send requests to + /// the create graphics object to create all the commands + /// all the children objects in the current scene + public static JArray GetChildren(NetworkStream stream, CreateGraphics createGraphics) + { + WriteTextMessage(stream, createGraphics.GetSceneInfoCommand()); + dynamic response = JsonConvert.DeserializeObject(ReadPrefMessage(stream)); + return response.data.data.data.children; + } + + /// + /// returns all objects in the current scene, as name-uuid tuples. + /// + /// the network stream to send requests to + /// the create graphics object to create all the commands + /// an array of name-uuid tuples for each object + public static (string,string)[] GetObjectsInScene(NetworkStream stream, CreateGraphics createGraphics) + { + JArray children = GetChildren(stream, createGraphics); + (string, string)[] res = new (string, string)[children.Count]; + + int i = 0; + foreach (dynamic child in children) + { + res[i] = (child.name, child.uuid); + i++; + } + + return res; + + } + }