Exemplo n.º 1
0
        public static Body CreateCapsule(World world, float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices verts = PolygonTools.createCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.maxPolygonVertices)
            {
                List <Vertices> vertList = Triangulate.convexPartition(verts, TriangulationAlgorithm.Earclip);
                return(CreateCompoundPolygon(world, vertList, density, position, rotation, bodyType, userData));
            }

            return(CreatePolygon(world, verts, density, position, rotation, bodyType, userData));
        }