Example #1
0
        public static BreakableBody CreateBreakableBody(World world, IEnumerable <Shape> shapes, TSVector2 position)
        {
            BreakableBody breakableBody = new BreakableBody(shapes, world);

            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return(breakableBody);
        }
Example #2
0
        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static BreakableBody CreateBreakableBody(World world, Vertices vertices, FP density, TSVector2 position)
        {
            List <Vertices> triangles = Triangulate.ConvexPartition(vertices, TriangulationAlgorithm.Earclip, true, FP.EN3);

            BreakableBody breakableBody = new BreakableBody(triangles, world, density);

            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return(breakableBody);
        }