Final version of this Renderer, will improve upon it in the next prototype

This commit is contained in:
Halbear
2026-02-19 18:06:18 +00:00
parent 70acbd2526
commit eb4b979843
3 changed files with 41 additions and 29 deletions

View File

@@ -59,8 +59,9 @@ namespace VoxelIsometricRenderer
PlayerObject.CreatePlayer(new int[] { 0, 0, 0, 0, 0, 0 }, 0, new BlockState(false, BlockType.Ground, false));
Chunk TestChunk = ChunkRegistry.IndexChunk(0, 0, 0);
Chunk TestChunk2 = ChunkRegistry.IndexChunk(0, 1, 0);
//Chunk TestChunk3 = ChunkRegistry.IndexChunk(0, 0, -1);
//Chunk TestChunk4 = ChunkRegistry.IndexChunk(0, 1, -1);
Chunk TestChunk3 = ChunkRegistry.IndexChunk(0, 0, -1);
Chunk TestChunk4 = ChunkRegistry.IndexChunk(-1, 0, -1);
Chunk TestChunk5 = ChunkRegistry.IndexChunk(-1, 0, 0);
Random rnd = new Random();
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
@@ -72,30 +73,33 @@ namespace VoxelIsometricRenderer
TestChunk2.CreateBlock(new int[] { 5,5,5,5,6,6 }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
}
else TestChunk2.CreateAir(i, j, k);
if (i < 8 && k < 8 && rnd.Next(0,1)==0) TestChunk.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
if (LightSource.IsWithinSphere(8, 4, 8, 4, i, j, k)) TestChunk.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
else TestChunk.CreateAir(i, j, k);
//if (LightSource.IsWithinSphere(7,8,8,8,i,j,k)) TestChunk4.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
//else TestChunk4.CreateAir(i, j, k);
//if (j == 15) TestChunk3.CreateBlock(new int[] {1,1,1,1,2,2 }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
//else TestChunk3.CreateAir(i, j, k);
if (LightSource.IsWithinSphere(8, 4, 8, 20, i, j, k)) TestChunk3.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
else TestChunk3.CreateAir(i, j, k);
if (LightSource.IsWithinSphere(8, 20, 8, 20, i, j, k)) TestChunk4.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
else TestChunk4.CreateAir(i, j, k);
if (LightSource.IsWithinSphere(8, 20, 8, 4, i, j, k)) TestChunk5.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
else TestChunk5.CreateAir(i, j, k);
}
}
}
//LightingManager.Lights.Add(new LightSource(LightShape.Sphere,7,7,7, 6, 14, 7, new float[] {0.8f,0.8f,0.0f}, 255));
//LightingManager.Lights.Add(new LightSource(LightShape.Sphere, 15, 15, 15, 7,18,7, new float[] {1.8f,0.0f,0.0f},255));
//LightingManager.Lights.Add(new LightSource(LightShape.Sphere,15,15,15, 3, 8, 15, new float[] {0.0f,1.8f,0.0f},255));
LightingManager.Lights.Add(new LightSource(LightShape.Sphere,12,12,12, 10, 18, 10, new float[] {0.0f,0.0f,1.8f}, 255));
LightingManager.Lights.Add(new LightSource(LightShape.Sphere, 7, 7, 7, 4,18,4, new float[] {1.8f,0.0f,0.0f},255));
LightingManager.Lights.Add(new LightSource(LightShape.Sphere,9,9,9, 12, 18, 12, new float[] {0.0f,0.0f,1.8f}, 255));
LightingManager.Lights.Add(new LightSource(LightShape.Sphere, 8, 8, 8, 4,18,4, new float[] {1.8f,0.0f,0.0f},255));
TestChunk2.GenerateLightMap();
//TestChunk4.GenerateLightMap();
// TestChunk3.GenerateLightMap();
TestChunk4.GenerateLightMap();
TestChunk5.GenerateLightMap();
TestChunk3.GenerateLightMap();
TestChunk.GenerateLightMap();
TestChunk.CalculateCull();
//ChunksToRender.Add(2);
//ChunksToRender.Add(3);
TestChunk3.CalculateCull();
TestChunk4.CalculateCull();
TestChunk5.CalculateCull();
ChunksToRender.Add(2);
ChunksToRender.Add(3);
ChunksToRender.Add(4);
ChunksToRender.Add(0);
ChunksToRender.Add(1);
//TestChunk2.CalculateCull();
MainThread = new Thread(Runtime);
MainThread.SetApartmentState(ApartmentState.STA);
MainThread.Start();