private static unsafe void OnRender(double obj) { renderer.BeginScene(MainCamera); renderer.RenderChunk(testChunk); renderer.EndScene(); }
public void RenderInnitialChunks() { System.DateTime renStart = System.DateTime.Now; foreach (var key in chunkCollection.Keys) { renderer.RenderChunk((Chunk2)chunkCollection[key]); } StatsEngine.ChunkRenderTime += (float)System.DateTime.Now.Subtract(renStart).TotalSeconds; }
private void RenderChunk(VisualChunkData chunkToRender, int chunkPositionX, int chunkPositionY) { ChunkRenderer chunkRenderer = TechnicalsFactory.GetInstance().GetChunkRendererInstance(); chunkToRender.SetUpWithNumberOfBlocksInChunk(intBuffersOfOpaqueBlocksInChunk.Count); chunkToRender.SetWorldPosition(chunkPositionX, chunkPositionY); for (int k = 0; k < floatBuffersOfOpaqueBlocksInChunk.Count; k += 3) { chunkToRender.AddVerticesToTemporaryBuffer(floatBuffersOfOpaqueBlocksInChunk[k]); chunkToRender.AddNormalsToTemporaryBuffer(floatBuffersOfOpaqueBlocksInChunk[k + 1]); chunkToRender.AddUvCoordinatesToTemporaryBuffer(floatBuffersOfOpaqueBlocksInChunk[k + 2]); } for (int k = 0; k < intBuffersOfOpaqueBlocksInChunk.Count; k++) { chunkToRender.AddIndicesToTemporaryBuffer(intBuffersOfOpaqueBlocksInChunk[k]); } chunkToRender.BuildChunkData(); chunkRenderer.RenderChunk(chunkToRender); }
private static void RenderMap(int chunkRadius, Maploader.World.World dut, int centerOffsetX, int centerOffsetZ, string filename) { var json = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"textures", "terrain_texture.json")); var ts = new TerrainTextureJsonParser(json, ""); var textures = ts.Textures; var g = new SystemDrawing(); var finder = new TextureFinder <Bitmap>(textures, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "textures"), g); finder.Debug = false; var b = g.CreateEmptyImage(16 * 16 * (2 * chunkRadius + 1), 16 * 16 * (2 * chunkRadius + 1)); var render = new ChunkRenderer <Bitmap>(finder, g, new RenderSettings() { YMax = 40 }); //Parallel.For(-chunkRadius, chunkRadius + 1,new ParallelOptions(){MaxDegreeOfParallelism = 8} , dx => for (int dz = -chunkRadius; dz <= chunkRadius; dz++) { for (int dx = -chunkRadius; dx <= chunkRadius; dx++) { var c = dut.GetChunk(dx + centerOffsetX, dz + centerOffsetZ); if (c != null) { render.RenderChunk(b, c, (chunkRadius + dx) * 256, (chunkRadius + dz) * 256); } } } var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); b.Save(path); Console.WriteLine(path); dut.Close(); }
public void ThreadCallback(object threadContext) { ChunkRenderer chunkRenderer = new ChunkRenderer(); chunkRenderer.RenderChunk(chunkToBeRendered); }