Fixed grass texture, houses and time of day
This commit is contained in:
@@ -19,30 +19,32 @@ namespace RH_Engine
|
||||
this.tunnelID = tunnelID;
|
||||
}
|
||||
|
||||
public string TerrainCommand(int[] sizeArray, float[] heightsArray)
|
||||
public string TerrainAdd(int[] sizeArray, float[] heightsArray, string serialCode)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/terrain/add",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
size = sizeArray,
|
||||
heights = heightsArray
|
||||
heights = heightsArray,
|
||||
}
|
||||
};
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string AddLayer(string uid, string texture)
|
||||
public string AddLayer(string uuid, string serialCode)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/addlayer",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
id = uid,
|
||||
diffuse = @"C:\Users\woute\Downloads\NetworkEngine.18.10.10.1\NetworkEngine\data\NetworkEngine\textures\terrain\adesert_cracks_d.jpg",
|
||||
normal = @"C:\Users\woute\Downloads\NetworkEngine.18.10.10.1\NetworkEngine\data\NetworkEngine\textures\terrain\adesert_mntn_d.jpg",
|
||||
id = uuid,
|
||||
diffuse = @"data\NetworkEngine\textures\terrain\grass_green_d.jpg",
|
||||
normal = @"data\NetworkEngine\textures\terrain\grass_green_n.jpg",
|
||||
minHeight = 0,
|
||||
maxHeight = 10,
|
||||
fadeDist = 1
|
||||
@@ -63,19 +65,27 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string AddNodeCommand()
|
||||
public string renderTerrain(string serialCode)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/add",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
name = "newNode",
|
||||
components = new
|
||||
{
|
||||
transform = new
|
||||
{
|
||||
position = new int[] { -80, 0, -80 },
|
||||
scale = 1f,
|
||||
rotation = new int[] { 0, 0, 0 }
|
||||
},
|
||||
terrain = new
|
||||
{
|
||||
smoothnormals = true
|
||||
smoothnormals = true,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,6 +321,19 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string ShowRoute(string serialCode, bool goShow)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "route/show",
|
||||
data = new
|
||||
{
|
||||
show = goShow
|
||||
}
|
||||
};
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string RouteCommand(string serialToSend)
|
||||
{
|
||||
ImprovedPerlin improvedPerlin = new ImprovedPerlin(4325, LibNoise.NoiseQuality.Best);
|
||||
@@ -422,12 +445,13 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string RoadCommand(string uuid_route)
|
||||
|
||||
public string RoadCommand(string uuid_route, string serialCode)
|
||||
{
|
||||
Console.WriteLine("road");
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/road/add",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
route = uuid_route,
|
||||
@@ -464,6 +488,7 @@ namespace RH_Engine
|
||||
|
||||
public string SkyboxCommand(double timeToSet)
|
||||
{
|
||||
Console.WriteLine(timeToSet);
|
||||
if (timeToSet < 0 || timeToSet > 24)
|
||||
{
|
||||
throw new Exception("The time must be between 0 and 24!");
|
||||
|
||||
@@ -87,6 +87,16 @@ namespace RH_Engine
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetTerrainID(string json)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(json);
|
||||
if (jsonData.data.data.status == "ok")
|
||||
{
|
||||
return jsonData.data.data.data.uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// method to get the uuid from requests for adding a node,route or road
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,8 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
@@ -17,13 +19,15 @@ 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("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||
//new PC("NA", "Bart")
|
||||
};
|
||||
|
||||
private static ServerResponseReader serverResponseReader;
|
||||
|
||||
private static string terrainId = string.Empty;
|
||||
private static string sessionId = string.Empty;
|
||||
private static string tunnelId = string.Empty;
|
||||
private static string cameraId = string.Empty;
|
||||
@@ -171,6 +175,8 @@ namespace RH_Engine
|
||||
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
||||
});
|
||||
|
||||
CreateTerrain(stream, mainCommand);
|
||||
|
||||
//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",
|
||||
@@ -194,53 +200,45 @@ namespace RH_Engine
|
||||
|
||||
while (cameraId == string.Empty) { }
|
||||
SetFollowSpeed(5.0f, stream, mainCommand);
|
||||
WriteTextMessage(stream, mainCommand.RoadCommand(routeId, "road"));
|
||||
WriteTextMessage(stream, mainCommand.ShowRoute("showRouteFalse", false));
|
||||
});
|
||||
});
|
||||
|
||||
string groundplaneId = GetId("GroundPlane", stream, mainCommand);
|
||||
WriteTextMessage(stream, mainCommand.DeleteNode(groundplaneId, "none"));
|
||||
|
||||
PlaceHouses(stream, mainCommand);
|
||||
|
||||
WriteTextMessage(stream, mainCommand.SkyboxCommand(DateTime.Now.Hour));
|
||||
|
||||
//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);
|
||||
// });
|
||||
}
|
||||
|
||||
private static void PlaceHouses(NetworkStream stream, Command mainCommand)
|
||||
{
|
||||
// public string AddModel(string nodeName, string serial, string fileLocation, float[] positionVector, float scalar, float[] rotationVector)
|
||||
//string folderHouses = @"data\NetworkEngine\models\houses\set1\";
|
||||
//SendMessageAndOnResponse(stream, mainCommand.AddModel("House1", "uselessSerial_atm", folderHouses + "house1.obj", new float[] { -20f, 1f, 0f }, 4 , new float[] { 0f, 0f, 0f }), "uselessSerial_atm", (message) => Console.WriteLine(message));
|
||||
//WriteTextMessage(stream, mainCommand.AddModel("House1", "uselessSerial_atm", @"C:\Users\Ralf van Aert\Documents\AvansTI\NetworkEngine.18.10.10.1\NetworkEngine\data\NetworkEngine\models\houses\set1\house4.obj"));
|
||||
|
||||
PlaceHouse(stream, mainCommand, 2, new float[] { 10f, 1f, 30f }, 1);
|
||||
PlaceHouse(stream, mainCommand, 1, new float[] { 42f, 1f, 22f }, new float[] { 0f, 90f, 0f }, 2);
|
||||
PlaceHouse(stream, mainCommand, 11, new float[] { -20f, 1f, 0f }, new float[] { 0f, -35f, 0f }, 3);
|
||||
PlaceHouse(stream, mainCommand, 7, new float[] { -15f, 1f, 50f }, new float[] { 0f, -50f, 0f }, 4);
|
||||
PlaceHouse(stream, mainCommand, 24, new float[] { 40f, 1f, 40f }, new float[] { 0f, 75f, 0f }, 5);
|
||||
PlaceHouse(stream, mainCommand, 22, new float[] { 34f, 1f, -20f }, 6);
|
||||
PlaceHouse(stream, mainCommand, 14, new float[] { 0f, 1f, -20f }, new float[] { 0f, 210f, 0f }, 7);
|
||||
}
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null));
|
||||
//string command;
|
||||
private static void PlaceHouse(NetworkStream stream, Command mainCommand, int numberHousemodel, float[] position, int serialNumber)
|
||||
{
|
||||
PlaceHouse(stream, mainCommand, numberHousemodel, position, new float[] { 0f, 0f, 0f }, serialNumber);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
|
||||
//command = mainCommand.AddModel("car", "data\\customModels\\TeslaRoadster.fbx");
|
||||
//WriteTextMessage(stream, command);
|
||||
|
||||
//command = mainCommand.addPanel();
|
||||
// WriteTextMessage(stream, command);
|
||||
// string response = ReadPrefMessage(stream);
|
||||
// Console.WriteLine("add Panel response: \n\r" + response);
|
||||
// string uuidPanel = JSONParser.getPanelID(response);
|
||||
// WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel, 2.42));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.ColorPanel(uuidPanel));
|
||||
// Console.WriteLine("Color panel: " + ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.SwapPanel(uuidPanel));
|
||||
// Console.WriteLine("Swap panel: " + ReadPrefMessage(stream));
|
||||
Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
private static void PlaceHouse(NetworkStream stream, Command mainCommand, int numberHousemodel, float[] position, float[] rotation, int serialNumber)
|
||||
{
|
||||
string folderHouses = @"data\NetworkEngine\models\houses\set1\";
|
||||
SendMessageAndOnResponse(stream, mainCommand.AddModel("House1", "housePlacement" + serialNumber, folderHouses + "house" + numberHousemodel + ".obj", position, 4, rotation), "housePlacement" + serialNumber, (message) => Console.WriteLine(message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -272,12 +270,32 @@ namespace RH_Engine
|
||||
ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best);
|
||||
for (int i = 0; i < 256 * 256; i++)
|
||||
{
|
||||
height[i] = improvedPerlin.GetValue(x / 10, x / 10, x * 100) + 1;
|
||||
height[i] = improvedPerlin.GetValue(x / 10, x / 10, x * 100)/3.5f + 1;
|
||||
|
||||
if (height[i] > 1.1f)
|
||||
{
|
||||
height[i] = height[i] * 0.8f;
|
||||
}
|
||||
else if (height[i] < 0.9f)
|
||||
{
|
||||
height[i] = height[i] * 1.2f;
|
||||
}
|
||||
x += 0.001f;
|
||||
}
|
||||
WriteTextMessage(stream, createGraphics.TerrainCommand(new int[] { 256, 256 }, height));
|
||||
|
||||
WriteTextMessage(stream, createGraphics.AddNodeCommand());
|
||||
SendMessageAndOnResponse(stream, createGraphics.TerrainAdd(new int[] { 256, 256 }, height, "terrain"), "terrain",
|
||||
(message) =>
|
||||
{
|
||||
|
||||
SendMessageAndOnResponse(stream, createGraphics.renderTerrain("renderTerrain"), "renderTerrain",
|
||||
(message) =>
|
||||
{
|
||||
terrainId = JSONParser.GetTerrainID(message);
|
||||
string addLayerMsg = createGraphics.AddLayer(terrainId, "addLayer");
|
||||
SendMessageAndOnResponse(stream, addLayerMsg, "addLayer", (message) => Console.WriteLine(""));
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -352,6 +370,7 @@ namespace RH_Engine
|
||||
{
|
||||
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, 1f, "XYZ", 1, false, new float[] { 0, 0, 0 }, new float[] { 0f, 5f, 5f }));
|
||||
}
|
||||
//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)
|
||||
|
||||
Reference in New Issue
Block a user