/// <summary> /// 三角面数组 每个子List为一个三角面 /// </summary> /// <param name="triangleLst"></param> /// <param name="vert"></param> /// <returns></returns> public static List<List<int>> Decompose(List<List<Vector2>> triangleLst, ref List<Vector2> vert) { List<Vector2> tries = new List<Vector2>(); GeoUtils.FlatList(triangleLst, ref tries); List<int> indices = new List<int>(); GeoUtils.MeshVertexPrimitiveType(tries, ref vert, ref indices); return HMDecompose(vert, indices); }
public static List<List<int>> Decompose(EarPolygon poly, ref List<Vector2> vert) { EarClipping.Clip(poly); List<Vector2> triangles = new List<Vector2>(); GeoUtils.FlatList(poly.mResults, ref triangles); List<int> indices = new List<int>(); GeoUtils.MeshVertexPrimitiveType(triangles, ref vert, ref indices); return HMDecompose(vert, indices); }
/// <summary> /// 简单多边形或者三角面点数组 /// </summary> /// <param name="tries"></param> /// <param name="isPolygon">是否为简单多边形</param> /// <param name="vert"></param> /// <returns></returns> public static List<List<int>> Decompose(List<Vector2> tries, bool isPolygon, ref List<Vector2> vert) { if (isPolygon) { EarPolygon poly = new EarPolygon(); foreach (Vector2 v in tries) { poly.AddPoint(v.x, v.y); } EarClipping.Clip(poly); List<Vector2> triangles = new List<Vector2>(); GeoUtils.FlatList(poly.mResults, ref triangles); List<int> indices = new List<int>(); GeoUtils.MeshVertexPrimitiveType(triangles, ref vert, ref indices); return HMDecompose(vert, indices); } else { List<int> indices = new List<int>(); GeoUtils.MeshVertexPrimitiveType(tries, ref vert, ref indices); return HMDecompose(vert, indices); } }