public getVertices ( int divisions ) : Vertices | ||
divisions | int | Number of divisions between each control point. |
Résultat | Vertices |
/// <summary> /// Convert a closed path into a polygon. /// Convex decomposition is automatically performed. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="density">The density.</param> /// <param name="subdivisions">The subdivisions.</param> public static void convertPathToPolygon( Path path, Body body, float density, int subdivisions ) { if( !path.isClosed ) throw new Exception( "The path must be closed to convert to a polygon." ); var verts = path.getVertices( subdivisions ); var decomposedVerts = Triangulate.convexPartition( new Vertices( verts ), TriangulationAlgorithm.Bayazit ); foreach( Vertices item in decomposedVerts ) { body.createFixture( new PolygonShape( item, density ) ); } }
/// <summary> /// Convert a closed path into a polygon. /// Convex decomposition is automatically performed. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="density">The density.</param> /// <param name="subdivisions">The subdivisions.</param> public static void convertPathToPolygon(Path path, Body body, float density, int subdivisions) { if (!path.isClosed) { throw new Exception("The path must be closed to convert to a polygon."); } var verts = path.getVertices(subdivisions); var decomposedVerts = Triangulate.convexPartition(new Vertices(verts), TriangulationAlgorithm.Bayazit); foreach (Vertices item in decomposedVerts) { body.createFixture(new PolygonShape(item, density)); } }
//Contributed by Matthew Bettcher /// <summary> /// Convert a path into a set of edges and attaches them to the specified body. /// Note: use only for static edges. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="subdivisions">The subdivisions.</param> public static void convertPathToEdges( Path path, Body body, int subdivisions ) { var verts = path.getVertices( subdivisions ); if( path.isClosed ) { var chain = new ChainShape( verts, true ); body.createFixture( chain ); } else { for( int i = 1; i < verts.Count; i++ ) { body.createFixture( new EdgeShape( verts[i], verts[i - 1] ) ); } } }
//Contributed by Matthew Bettcher /// <summary> /// Convert a path into a set of edges and attaches them to the specified body. /// Note: use only for static edges. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="subdivisions">The subdivisions.</param> public static void convertPathToEdges(Path path, Body body, int subdivisions) { var verts = path.getVertices(subdivisions); if (path.isClosed) { var chain = new ChainShape(verts, true); body.createFixture(chain); } else { for (int i = 1; i < verts.Count; i++) { body.createFixture(new EdgeShape(verts[i], verts[i - 1])); } } }