Пример #1
0
        public static Body CreateRoundedRectangle(World world, float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices verts = PolygonTools.createRoundedRectangle(width, height, xRadius, yRadius, segments);

            //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));
        }
Пример #2
0
        public static List <Fixture> attachRoundedRectangle(float width, float height, float xRadius, float yRadius, int segments, float density, Body body, object userData = null)
        {
            var verts = PolygonTools.createRoundedRectangle(width, height, xRadius, yRadius, segments);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.maxPolygonVertices)
            {
                var vertList = Triangulate.convexPartition(verts, TriangulationAlgorithm.Earclip);
                return(attachCompoundPolygon(vertList, density, body, userData));
            }

            var fixtures = new List <Fixture>(1);

            fixtures.Add(attachPolygon(verts, density, body, userData));
            return(fixtures);
        }