Wpf System test

This commit is contained in:
Troispoils 2024-03-06 17:19:53 +01:00
parent af9c782c1e
commit 9ad4bc1c69
17 changed files with 746 additions and 12 deletions

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace LandblockExtraction.WorldMap.Types;
public class Cell {
public Vector3[,] position;
public Vector4[,] color;
public Cell() {
position = new Vector3[17, 17];
color = new Vector4[17, 17];
}
}

View file

@ -0,0 +1,50 @@
using LandblockExtraction.WorldMap.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LandblockExtraction.WorldMap;
public class Land {
public Cell cell;
public Land() {
cell = new Cell();
}
public float[] getVertices() {
List<float> vertices = new List<float>();
for(int y = 0; y < 10; y++) {
for(int x = 0; x < 10; x++) {
vertices.Add(cell.position[x, y].X);
vertices.Add(cell.position[x, y].Y);
vertices.Add(cell.position[x, y].Z);
vertices.Add(cell.color[x, y].X);
vertices.Add(cell.color[x, y].Y);
vertices.Add(cell.color[x, y].Z);
vertices.Add(cell.color[x, y].W);
}
}
return vertices.ToArray();
}
public int[] getIndices() {
List<int> indices = new List<int>();
for (int y = 0; y < 10 - 1; y++) {
for (int x = 0; x < 10 - 1; x++) {
var value = y * 10 + x;
indices.Add(value);
indices.Add(value + 1);
indices.Add(value + 10);
indices.Add(value + 10);
indices.Add(value + 11);
indices.Add(value + 1);
}
}
return indices.ToArray();
}
}

View file

@ -0,0 +1,40 @@
using LandblockExtraction.WorldMap.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
namespace LandblockExtraction.WorldMap;
public class WorldMap {
public Land[,] lands;
public WorldMap() {
lands = new Land[10, 10];
CreatePlane();
}
public void CreatePlane() {
for(int i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
lands[j,i] = CreateCell(i, j);
}
}
}
private Land CreateCell(int i, int j) {
Land land = new Land();
for(int y = 0; y < 17; y++) {
for (int x = 0; x < 17; x++) {
float rand = new Random().Next(0, 254) / 255f;
Console.WriteLine(rand);
land.cell.position[x, y] = new Vector3(x + (j * 9), 0, y + (i * 9));
land.cell.color[x, y] = new Vector4(rand, rand, rand, 1f);
}
}
return land;
}
}