Example #1
0
        public override void Draw(SpriteBatch spriteBatch, SpriteFont font, float dt)
        {
            spriteBatch.Begin();

            spriteBatch.DrawString(font, "No of bodies: " + physicsWorld.bodies.Count,
                                   new Vector2(10, 85), Color.White);

            spriteBatch.End();

            foreach (Body body in physicsWorld.bodies)
            {
                DrawBody(body, Color.White);
            }

            if (isIntersect)
            {
                Primitives2D.DrawLine(((ray.origin).ToVector2()), ((result.point).ToVector2()), Color.Green);
                Primitives2D.DrawLine(((result.point).ToVector2()),
                                      ((result.point + result.normal).ToVector2()), Color.Yellow);
            }
            else
            {
                Primitives2D.DrawLine(((ray.origin).ToVector2()),
                                      ((ray.origin + ray.direction * distance).ToVector2()), Color.Blue);
            }
        }
Example #2
0
        protected static void DrawBody(Body body, Color color)
        {
            DrawShape(body.shape, body.position, color);

            if (body.shape is Circle)
            {
                Vec2 r = body.transform.LocalToWorldDirection(-Vec2.UnitY * (body.shape as Circle).radius);
                Primitives2D.DrawLine(body.position.ToVector2(), (body.position + r).ToVector2(), color);
            }
        }