protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam) { if (BasicEffect == null) { BasicEffect = new BasicEffect(render.device); BasicEffect.VertexColorEnabled = true; BasicEffect.TextureEnabled = false; } //if (_fetchedResults == false) { DebugRenderable RenderBuffer = Scene.GetDebugRenderable(); if (RenderBuffer == null || (RenderBuffer.TriangleCount == 0 && RenderBuffer.LineCount == 0)) return; Color c = Color.Red; if (RenderBuffer.TriangleCount > 0) { VertexPositionColor1 = new VertexPositionColor[RenderBuffer.TriangleCount * 3]; for (int i = 0, j = 0; i < RenderBuffer.TriangleCount; i += 3, j++) { VertexPositionColor1[i].Color = c; VertexPositionColor1[i].Position = RenderBuffer.GetDebugTriangles()[j].Point0.AsXNA(); VertexPositionColor1[i + 1].Color = c; VertexPositionColor1[i + 1].Position = RenderBuffer.GetDebugTriangles()[j].Point1.AsXNA(); VertexPositionColor1[i + 2].Color = c; VertexPositionColor1[i + 2].Position = RenderBuffer.GetDebugTriangles()[j].Point2.AsXNA(); } } if (RenderBuffer.LineCount > 0) { VertexPositionColor2 = new VertexPositionColor[RenderBuffer.LineCount * 2]; for (int i = 0, j = 0; i < RenderBuffer.LineCount; i += 2, j++) { VertexPositionColor2[i].Color = c; VertexPositionColor2[i].Position = RenderBuffer.GetDebugLines()[j].Point0.AsXNA(); VertexPositionColor2[i + 1].Color = c; VertexPositionColor2[i + 1].Position = RenderBuffer.GetDebugLines()[j].Point1.AsXNA(); } } } BasicEffect.View = cam.View; BasicEffect.Projection = cam.Projection; BasicEffect.World = Matrix.Identity; if(VertexPositionColor2 != null) render.RenderUserPrimitive<VertexPositionColor>(BasicEffect, PrimitiveType.LineList, VertexPositionColor2, 0, VertexPositionColor2.Length / 2); if (VertexPositionColor1 != null) render.RenderUserPrimitive<VertexPositionColor>(BasicEffect, PrimitiveType.TriangleList, VertexPositionColor1, 0, VertexPositionColor1.Length / 3); }