private void Draw(Graphic g) { var v = VectorKit.AngleToVector(Body.Rotation); g.DrawSolidPolygon(ShapeFactory.Triangle(Body.Position - v * .5f, 2f, Body.Rotation + MathKit.Pi), Color.DarkRed); g.DrawSolidPolygon(ShapeFactory.Triangle(Body.Position + v * 1f, 1.5f, Body.Rotation), Color.DarkRed); g.FlushPrimitives(); // var color = _isActive ? Color.Orange : Color.White; var color = Color.Orange; g.DrawSolidPolygon(ShapeFactory.Triangle(Body.Position, 1, Body.Rotation + MathKit.Pi), color); g.DrawSolidPolygon(ShapeFactory.Triangle(Body.Position + v, 1, Body.Rotation), color); }
private void DrawBody(Graphic g) { var v = _body.LinearVelocity; var l = v.Length(); Vector2 pos; if (l == 0) { pos = _body.Position; } else { var d = Interpolation.From(l, 0, 10, 0, .2f); v.Normalize(); v *= d; pos = _body.Position + v; } g.DrawSolidCircle(pos, .2f, _actorColor); g.DrawCircleStrip(_body.Position, .5f, .1f, _actorColor); foreach (var poly in _staticBodiesContours) { g.DrawSolidPolygon(poly, _actorColor); } }
private void DrawFixture(Graphic g, Body body, Fixture fixture, Color color) { switch (fixture.Shape.ShapeType) { case ShapeType.Circle: { var circle = (CircleShape)fixture.Shape; Vector2 center = body.GetWorldPoint(circle.Position); if (DrawSolidShape) { g.DrawSolidCircle(center, circle.Radius, color); } else { g.DrawCircle(center, circle.Radius, color); } break; } case ShapeType.Polygon: { TempVertices.Clear(); var poly = fixture.Shape as PolygonShape; int vertexCount = poly.Vertices.Count; for (int i = 0; i < vertexCount; ++i) { var p = body.GetWorldPoint(poly.Vertices[i]); TempVertices.Add(p); } if (DrawSolidShape) { g.DrawSolidPolygon(TempVertices.ToArray(), color); } else { g.DrawPolygon(TempVertices.ToArray(), color); } break; } } }