Exemplo n.º 1
0
        public static Body CreateGear(World world, FP radius, int numberOfTeeth, FP tipPercentage, FP toothHeight, FP density, object userData = null)
        {
            Vertices gearPolygon = PolygonTools.CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight);

            //Gears can in some cases be convex
            if (!gearPolygon.IsConvex())
            {
                //Decompose the gear:
                List <Vertices> list = Triangulate.ConvexPartition(gearPolygon, TriangulationAlgorithm.Earclip, true, FP.EN3);

                return(CreateCompoundPolygon(world, list, density, userData));
            }

            return(CreatePolygon(world, gearPolygon, density, userData));
        }
Exemplo n.º 2
0
        public static Body CreateGear(World world, FP radius, int numberOfTeeth, FP tipPercentage, FP toothHeight, FP density, object userData = null)
        {
            Vertices vertices = PolygonTools.CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight);
            bool     flag     = !vertices.IsConvex();
            Body     result;

            if (flag)
            {
                List <Vertices> list = Triangulate.ConvexPartition(vertices, TriangulationAlgorithm.Earclip, true, FP.EN3);
                result = BodyFactory.CreateCompoundPolygon(world, list, density, userData);
            }
            else
            {
                result = BodyFactory.CreatePolygon(world, vertices, density, userData);
            }
            return(result);
        }