Commit alt code of VR engine
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using LibNoise.Primitive;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -16,7 +17,7 @@ namespace RH_Engine
|
||||
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||
//new PC("T470S", "Shinichi"),
|
||||
//new PC("DESKTOP-DHS478C", "semme"),
|
||||
new PC("HP-ZBOOK-SEM", "Sem"),
|
||||
//new PC("HP-ZBOOK-SEM", "Sem"),
|
||||
//new PC("DESKTOP-TV73FKO", "Wouter"),
|
||||
new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||
//new PC("NA", "Bart")
|
||||
@@ -25,9 +26,11 @@ namespace RH_Engine
|
||||
private static ServerResponseReader serverResponseReader;
|
||||
private static string sessionId = string.Empty;
|
||||
private static string tunnelId = string.Empty;
|
||||
private static string cameraId = string.Empty;
|
||||
private static string routeId = string.Empty;
|
||||
private static string panelId = string.Empty;
|
||||
private static string bikeId = string.Empty;
|
||||
private static string headId = string.Empty;
|
||||
|
||||
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||
|
||||
@@ -55,6 +58,7 @@ namespace RH_Engine
|
||||
/// <param name="message">the response message from the server</param>
|
||||
public static void HandleResponse(string message)
|
||||
{
|
||||
//Console.WriteLine(message);
|
||||
string id = JSONParser.GetID(message);
|
||||
|
||||
// because the first messages don't have a serial, we need to check on the id
|
||||
@@ -109,7 +113,7 @@ namespace RH_Engine
|
||||
|
||||
stream.Write(res);
|
||||
|
||||
Console.WriteLine("sent message " + message);
|
||||
//Console.WriteLine("sent message " + message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,23 +148,85 @@ namespace RH_Engine
|
||||
{
|
||||
Command mainCommand = new Command(tunnelID);
|
||||
|
||||
// Reset scene
|
||||
WriteTextMessage(stream, mainCommand.ResetScene());
|
||||
//headId = GetId("Root", stream, mainCommand);
|
||||
//while (headId == string.Empty) { }
|
||||
|
||||
//Get sceneinfo
|
||||
SendMessageAndOnResponse(stream, mainCommand.GetSceneInfoCommand("sceneinfo"), "sceneinfo",
|
||||
(message) =>
|
||||
{
|
||||
//Console.WriteLine("\r\n\r\n\r\nscene info" + message);
|
||||
cameraId = JSONParser.GetIdSceneInfoChild(message, "Camera");
|
||||
string headId = JSONParser.GetIdSceneInfoChild(message, "Head");
|
||||
string handLeftId = JSONParser.GetIdSceneInfoChild(message, "LeftHand");
|
||||
string handRightId = JSONParser.GetIdSceneInfoChild(message, "RightHand");
|
||||
|
||||
//Force(stream, mainCommand.DeleteNode(handLeftId, "deleteHandL"), "deleteHandL", (message) => Console.WriteLine("Left hand deleted"));
|
||||
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
||||
});
|
||||
|
||||
//Add route, bike and put camera and bike to follow route at same speed.
|
||||
SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModel("bikeID"), "bikeID",
|
||||
(message) =>
|
||||
{
|
||||
bikeId = JSONParser.GetResponseUuid(message);
|
||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||
(message) =>
|
||||
{
|
||||
bool speedReplied = false;
|
||||
bool moveReplied = true;
|
||||
panelId = JSONParser.getPanelID(message);
|
||||
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
||||
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.MoveTo(panelId, "panelMove", new float[] { 0f, 0f, 0f }, "Z", 1, 5), "panelMove",
|
||||
(message) =>
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
SendMessageAndOnResponse(stream, mainCommand.bikeSpeed(panelId, "bikeSpeed", 5.0), "bikeSpeed",
|
||||
(message) =>
|
||||
{
|
||||
WriteTextMessage(stream, mainCommand.SwapPanel(panelId));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//while (!(speedReplied && moveReplied)) { }
|
||||
|
||||
while (cameraId == string.Empty) { }
|
||||
SetFollowSpeed(5.0f, stream, mainCommand);
|
||||
});
|
||||
});
|
||||
|
||||
//Force(stream, mainCommand.addPanel("panelID", bikeId), "panelID",
|
||||
// (message) =>
|
||||
// {
|
||||
// Console.WriteLine("panel response: " + message);
|
||||
// panelId = JSONParser.GetResponseUuid(message);
|
||||
// while(bikeId == string.Empty) { }
|
||||
// SetFollowSpeed(5.0f, stream, mainCommand);
|
||||
// });
|
||||
//SendMessageAndOnResponse(stream, maincommand.addpanel("panelid", bikeid), "panelid",
|
||||
// (message) =>
|
||||
// {
|
||||
// console.writeline("panelid: " + message);
|
||||
// //panelid = jsonparser.getpanelid(message);
|
||||
// panelid = jsonparser.getresponseuuid(message);
|
||||
// while (bikeid == string.empty) { }
|
||||
// setfollowspeed(5.0f, stream, maincommand);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null));
|
||||
//string command;
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModel("bikeID"), "bikeID", (message) => bikeId = JSONParser.GetResponseUuid(message));
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelID", bikeId), "panelID",
|
||||
(message) =>
|
||||
{
|
||||
panelId = JSONParser.GetResponseUuid(message);
|
||||
while (bikeId == string.Empty) { }
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, bikeId, 5, new float[] { 0, -(float)Math.PI / 2f, 0 }, new float[] { 0, 0, 0 }));
|
||||
});
|
||||
|
||||
Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
//Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
|
||||
//command = mainCommand.AddModel("car", "data\\customModels\\TeslaRoadster.fbx");
|
||||
//WriteTextMessage(stream, command);
|
||||
@@ -255,6 +321,30 @@ namespace RH_Engine
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void SetFollowSpeed(float speed, NetworkStream stream, Command mainCommand)
|
||||
{
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, bikeId, speed, new float[] { 0, -(float)Math.PI / 2f, 0 }, new float[] { 0, 0, 0 }));
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, cameraId, speed));
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, panelId, speed, 0, "XYZ", 1, false, new float[] { 0, 0, 0 }, new float[] { 0f, 0f, 150f }));
|
||||
}
|
||||
//string routeID, string nodeID, float speedValue, float offsetValue, string rotateValue, float smoothingValue, bool followHeightValue, float[] rotateOffsetVector, float[] positionOffsetVector)
|
||||
private static void Force(NetworkStream stream, string message, string serial, HandleSerial action)
|
||||
{
|
||||
SendMessageAndOnResponse(stream, message, serial,
|
||||
(message) =>
|
||||
{
|
||||
if (!JSONParser.GetStatus(message))
|
||||
{
|
||||
serialResponses.Remove(serial);
|
||||
Force(stream, message, serial,action);
|
||||
} else
|
||||
{
|
||||
action(message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user