Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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;
                    }
            }
        }