protected override void DrawTilesBelow(GameContext context) { // Ensure we have a chunk manager to source chunks from. if (!(context.World is RPGWorld)) { return; } this.Octree = (context.World as RPGWorld).ChunkOctree; if (this.Octree == null) { return; } if (this.Chunk == null) { this.Chunk = this.Octree.Get(0, 0, 0); } // Determine our Z offset. int zoffset = -(Chunk.Depth - this.ZLevel) * TileIsometricifier.TILE_CUBE_HEIGHT; // Get rendering information. ChunkRenderer.ResetNeeded(); IEnumerable <RelativeRenderInformation> renders = this.GetRelativeRenderInformation(context, this.Chunk); ChunkRenderer.LastRenderedCountOnScreen = renders.Count(); // Render chunks. if (FilteredFeatures.IsEnabled(Feature.DepthBuffer)) { context.EndSpriteBatch(); context.Graphics.GraphicsDevice.SetRenderTarget(RenderingBuffers.ScreenBuffer); context.StartSpriteBatch(); } foreach (RelativeRenderInformation ri in renders) { if (ri.Target == this.Chunk) { this.m_ChunkCenterX = ri.X + TileIsometricifier.CHUNK_TOP_WIDTH / 2; this.m_ChunkCenterY = ri.Y; } Texture2D tex = ri.Target.Texture; ChunkRenderer.MarkNeeded(ri.Target); if (tex != null) { ChunkRenderer.MarkUsed(ri.Target); if (FilteredFeatures.IsEnabled(Feature.DepthBuffer)) { context.SpriteBatch.Draw(tex, new Vector2(ri.X, ri.Y + zoffset), Color.White); } else { if (FilteredFeatures.IsEnabled(Feature.RenderingBuffers)) { context.Graphics.GraphicsDevice.SetRenderTarget(RenderingBuffers.ScreenBuffer); } context.SpriteBatch.Draw(tex, new Vector2(ri.X, ri.Y + zoffset), Color.White); } FilteredConsole.WriteLine(FilterCategory.RenderingActive, "Rendering chunk at " + ri.X + ", " + ri.Y + "."); } else { FilteredConsole.WriteLine(FilterCategory.Rendering, "No texture yet for chunk to render at " + ri.X + ", " + ri.Y + "."); } } // Render depth maps. if (FilteredFeatures.IsEnabled(Feature.DepthBuffer)) { context.EndSpriteBatch(); context.Graphics.GraphicsDevice.SetRenderTarget(RenderingBuffers.DepthBuffer); context.StartSpriteBatch(); foreach (RelativeRenderInformation ri in renders) { Texture2D depth = ri.Target.DepthMap; if (depth != null) { ChunkRenderer.MarkUsed(ri.Target); if (FilteredFeatures.IsEnabled(Feature.DepthBuffer)) { context.SpriteBatch.Draw(depth, new Vector2(ri.X, ri.Y + zoffset), Color.White); } } } } // Finish drawing. context.EndSpriteBatch(); context.Graphics.GraphicsDevice.SetRenderTarget(null); context.StartSpriteBatch(); }