conflicts

This commit is contained in:
Sem van der Hoeven
2020-10-09 16:59:31 +02:00
8 changed files with 120 additions and 69 deletions

View File

@@ -14,8 +14,11 @@ namespace ClientApp.ViewModels
{
public string Username { get; set; }
public ICommand LoginCommand { get; set; }
public bool LoginStatus { get; set; }
public bool InvertedLoginStatus { get; set; }
private MainWindowViewModel mainWindowViewModel;
public LoginViewModel(MainWindowViewModel mainWindowViewModel)
{
@@ -32,7 +35,7 @@ namespace ClientApp.ViewModels
internal void setLoginStatus(bool status)
{
this.mainWindowViewModel.InfoModel.ConnectedToServer = status;
this.LoginStatus = status;
this.InvertedLoginStatus = !status;
if (status)
{
this.mainWindowViewModel.SelectedViewModel = new MainViewModel(mainWindowViewModel);

View File

@@ -14,9 +14,8 @@
<Label Content="Password" HorizontalContentAlignment="Center"/>
<PasswordBox x:Name="Password" Width="120"/>
<Button x:Name="Login" Content="Login" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=Password}" Margin="0,20,0,0" Width="120"/>
<CheckBox Name = "PCheckBox" Margin = "198,94,208,194" Content = "Checked Me"/>
<Popup IsOpen="{Binding LoginStatus}" PopupAnimation = "Slide">
<Label Content="Login failed" Foreground="Red"/>
<Popup IsOpen="{Binding InvertedLoginStatus}" PopupAnimation = "Fade" HorizontalAlignment="Left">
<Label Content="Login failed" Foreground="Red" Background="#FFFF" />
</Popup>
</StackPanel>
</DockPanel>

View File

@@ -11,6 +11,6 @@
<DockPanel>
<Label Content="gemaakt door: mensen" DockPanel.Dock="Bottom" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontStyle="Italic" Foreground="Gray"/>
<ContentControl HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding SelectedViewModel}" />
<ContentControl HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding SelectedViewModel}" Focusable="False" />
</DockPanel>
</Window>

View File

@@ -21,7 +21,7 @@
<Label Content="Username" HorizontalContentAlignment="Center"/>
<TextBox x:Name="Username" TextWrapping="Wrap" Width="120"/>
<Label Content="Password" HorizontalContentAlignment="Center"/>
<TextBox x:Name="Password" TextWrapping="Wrap" Width="120"/>
<PasswordBox x:Name="Password" Width="120"/>
<Button x:Name="Login" Content="Login" Margin="0,20,0,0" Click="Login_Click_1" />
</StackPanel>

View File

@@ -25,10 +25,8 @@ namespace DokterApp
public MainWindow()
{
InitializeComponent();
}
}
private void Login_Click_1(object sender, RoutedEventArgs e)
{
@@ -36,16 +34,13 @@ namespace DokterApp
handler = windowTabs.NewTab;
this.Label.Content = "Waiting";
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Text, handler);
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Password, handler);
while (!client.IsConnected())
{
}
windowTabs.Show();
this.Close();
}
}

View File

@@ -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!");

View File

@@ -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>

View File

@@ -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)