private void RenderBodies() { var bodies = _engine.World.AllBodies.Where(x => x.Visible).ToList(); var parts = bodies.SelectMany(x => x.EnumParts().Where(y => y.Visible)).ToList(); if (_engine.Debug) { foreach (var body in bodies) { var bounds = body.Bounds.ToPointF(); _graphics.DrawPolygon(PenFactory.Get(Color.DarkGray), bounds); } } foreach (var part in parts) { var vertices = part.Vertices.ToPointF(); _graphics.FillPolygon(BrushFactory.Get(part.Render.Fill), vertices); _graphics.DrawPolygon(PenFactory.Get(part.Render.Stroke), vertices); } /*foreach (var part in parts) * { * foreach (var axis in part.Axes.Points) * { * _graphics.DrawLine(PenFactory.Get(Color.LightCyan), * (float) part.Position.X, (float) part.Position.Y, * (float) part.Position.X + 5f*(float) axis.X, * (float) part.Position.Y + 5f*(float) axis.Y); * } * }*/ if (!_engine.Debug) { return; } foreach (var part in parts) { foreach (var axis in part.Axes.Points) { var first = part.Vertices.Vertexes.First(); var last = part.Vertices.Vertexes.Last(); _graphics.DrawLine(PenFactory.Get(Color.Salmon), (float)part.Position.X, (float)part.Position.Y, ((float)first.X + (float)last.X) / 2f, ((float)first.Y + (float)last.Y) / 2f); } } foreach (var part in parts) { _graphics.DrawArc(PenFactory.Get(Color.Indigo), (float)part.Position.X - 1.5f, (float)part.Position.Y - 1.5f, 3f, 3f, 0f, 360f); } foreach (var body in bodies) { _graphics.DrawLine(PenFactory.Get(Color.CornflowerBlue), (float)body.Position.X, (float)body.Position.Y, (float)body.Position.X + 2f * (float)(body.Position.X - body.PositionPrev.X), (float)body.Position.Y + 2f * (float)(body.Position.Y - body.PositionPrev.Y)); } }
private void RenderInfo() { _graphics.DrawString($"FPS: {_runner.Fps:F} COLL: {_engine.Pairs.PairList.Count(x => x.Active)}", _font, BrushFactory.Get(Color.Black), new PointF(40f, 20f)); }