|
@@ -21,7 +21,7 @@ namespace SharpGLTF.Schema2
|
|
|
return root.CreateMeshes(mesh)[0];
|
|
return root.CreateMeshes(mesh)[0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static Mesh CreateMesh<TMaterial>(this ModelRoot root, Func<TMaterial, Material> materialEvaluator, IMeshBuilder<TMaterial> mesh)
|
|
|
|
|
|
|
+ public static Mesh CreateMesh<TMaterial>(this ModelRoot root, Converter<TMaterial, Material> materialEvaluator, IMeshBuilder<TMaterial> mesh)
|
|
|
{
|
|
{
|
|
|
return root.CreateMeshes<TMaterial>(materialEvaluator, mesh)[0];
|
|
return root.CreateMeshes<TMaterial>(materialEvaluator, mesh)[0];
|
|
|
}
|
|
}
|
|
@@ -51,19 +51,19 @@ namespace SharpGLTF.Schema2
|
|
|
return root.CreateMeshes(matFactory, meshBuilders);
|
|
return root.CreateMeshes(matFactory, meshBuilders);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static IReadOnlyList<Mesh> CreateMeshes<TMaterial>(this ModelRoot root, Func<TMaterial, Material> materialEvaluator, params IMeshBuilder<TMaterial>[] meshBuilders)
|
|
|
|
|
|
|
+ public static IReadOnlyList<Mesh> CreateMeshes<TMaterial>(this ModelRoot root, Converter<TMaterial, Material> materialConverter, params IMeshBuilder<TMaterial>[] meshBuilders)
|
|
|
{
|
|
{
|
|
|
Guard.NotNull(root, nameof(root));
|
|
Guard.NotNull(root, nameof(root));
|
|
|
- Guard.NotNull(materialEvaluator, nameof(materialEvaluator));
|
|
|
|
|
|
|
+ Guard.NotNull(materialConverter, nameof(materialConverter));
|
|
|
Guard.NotNull(meshBuilders, nameof(meshBuilders));
|
|
Guard.NotNull(meshBuilders, nameof(meshBuilders));
|
|
|
|
|
|
|
|
- return root.CreateMeshes(materialEvaluator, true, meshBuilders);
|
|
|
|
|
|
|
+ return root.CreateMeshes(materialConverter, true, meshBuilders);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static IReadOnlyList<Mesh> CreateMeshes<TMaterial>(this ModelRoot root, Func<TMaterial, Material> materialEvaluator, bool strided, params IMeshBuilder<TMaterial>[] meshBuilders)
|
|
|
|
|
|
|
+ public static IReadOnlyList<Mesh> CreateMeshes<TMaterial>(this ModelRoot root, Converter<TMaterial, Material> materialConverter, bool strided, params IMeshBuilder<TMaterial>[] meshBuilders)
|
|
|
{
|
|
{
|
|
|
Guard.NotNull(root, nameof(root));
|
|
Guard.NotNull(root, nameof(root));
|
|
|
- Guard.NotNull(materialEvaluator, nameof(materialEvaluator));
|
|
|
|
|
|
|
+ Guard.NotNull(materialConverter, nameof(materialConverter));
|
|
|
Guard.NotNull(meshBuilders, nameof(meshBuilders));
|
|
Guard.NotNull(meshBuilders, nameof(meshBuilders));
|
|
|
Guard.IsTrue(meshBuilders.Length == meshBuilders.Distinct().Count(), nameof(meshBuilders), "The collection has repeated meshes.");
|
|
Guard.IsTrue(meshBuilders.Length == meshBuilders.Distinct().Count(), nameof(meshBuilders), "The collection has repeated meshes.");
|
|
|
|
|
|
|
@@ -75,7 +75,7 @@ namespace SharpGLTF.Schema2
|
|
|
.Where(item => !item.IsEmpty())
|
|
.Where(item => !item.IsEmpty())
|
|
|
.Select(item => item.Material)
|
|
.Select(item => item.Material)
|
|
|
.Distinct()
|
|
.Distinct()
|
|
|
- .ToDictionary(m => m, m => materialEvaluator(m));
|
|
|
|
|
|
|
+ .ToDictionary(m => m, m => materialConverter(m));
|
|
|
|
|
|
|
|
// create Schema2.Mesh collections for every gathered group.
|
|
// create Schema2.Mesh collections for every gathered group.
|
|
|
|
|
|
|
@@ -520,7 +520,7 @@ namespace SharpGLTF.Schema2
|
|
|
if (vertexAccessors.ContainsKey("WEIGHTS_1")) dstColumns.Weights1 = vertexAccessors["WEIGHTS_1"].AsVector4Array();
|
|
if (vertexAccessors.ContainsKey("WEIGHTS_1")) dstColumns.Weights1 = vertexAccessors["WEIGHTS_1"].AsVector4Array();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void AddMesh<TMaterial, TvG, TvM, TvS>(this MeshBuilder<TMaterial, TvG, TvM, TvS> meshBuilder, Mesh srcMesh, Func<Material, TMaterial> materialFunc)
|
|
|
|
|
|
|
+ public static void AddMesh<TMaterial, TvG, TvM, TvS>(this MeshBuilder<TMaterial, TvG, TvM, TvS> meshBuilder, Mesh srcMesh, Converter<Material, TMaterial> materialFunc)
|
|
|
where TvG : struct, IVertexGeometry
|
|
where TvG : struct, IVertexGeometry
|
|
|
where TvM : struct, IVertexMaterial
|
|
where TvM : struct, IVertexMaterial
|
|
|
where TvS : struct, IVertexSkinning
|
|
where TvS : struct, IVertexSkinning
|
|
@@ -562,7 +562,7 @@ namespace SharpGLTF.Schema2
|
|
|
/// <param name="animation">The source <see cref="Animation"/> to evaluate.</param>
|
|
/// <param name="animation">The source <see cref="Animation"/> to evaluate.</param>
|
|
|
/// <param name="time">A time point, in seconds, within <paramref name="animation"/>.</param>
|
|
/// <param name="time">A time point, in seconds, within <paramref name="animation"/>.</param>
|
|
|
/// <returns>A new <see cref="MeshBuilder{TMaterial, TvG, TvM, TvS}"/> containing the evaluated geometry.</returns>
|
|
/// <returns>A new <see cref="MeshBuilder{TMaterial, TvG, TvM, TvS}"/> containing the evaluated geometry.</returns>
|
|
|
- public static MeshBuilder<TMaterial, TvG, TvM, VertexEmpty> ToStaticMeshBuilder<TMaterial, TvG, TvM>(this Scene srcScene, Func<Material, TMaterial> materialFunc, Animation animation, float time)
|
|
|
|
|
|
|
+ public static MeshBuilder<TMaterial, TvG, TvM, VertexEmpty> ToStaticMeshBuilder<TMaterial, TvG, TvM>(this Scene srcScene, Converter<Material, TMaterial> materialFunc, Animation animation, float time)
|
|
|
where TvG : struct, IVertexGeometry
|
|
where TvG : struct, IVertexGeometry
|
|
|
where TvM : struct, IVertexMaterial
|
|
where TvM : struct, IVertexMaterial
|
|
|
{
|
|
{
|
|
@@ -662,7 +662,7 @@ namespace SharpGLTF.Schema2
|
|
|
return dstMesh;
|
|
return dstMesh;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static MeshBuilder<Materials.MaterialBuilder, TvG, TvM, TvS> ToMeshBuilder<TMaterial, TvG, TvM, TvS>(this IEnumerable<(VertexBuilder<TvG, TvM, TvS> A, VertexBuilder<TvG, TvM, TvS> B, VertexBuilder<TvG, TvM, TvS> C, TMaterial Material)> triangles, Func<TMaterial, Materials.MaterialBuilder> materialFunc)
|
|
|
|
|
|
|
+ public static MeshBuilder<Materials.MaterialBuilder, TvG, TvM, TvS> ToMeshBuilder<TMaterial, TvG, TvM, TvS>(this IEnumerable<(VertexBuilder<TvG, TvM, TvS> A, VertexBuilder<TvG, TvM, TvS> B, VertexBuilder<TvG, TvM, TvS> C, TMaterial Material)> triangles, Converter<TMaterial, Materials.MaterialBuilder> materialFunc)
|
|
|
where TvG : struct, IVertexGeometry
|
|
where TvG : struct, IVertexGeometry
|
|
|
where TvM : struct, IVertexMaterial
|
|
where TvM : struct, IVertexMaterial
|
|
|
where TvS : struct, IVertexSkinning
|
|
where TvS : struct, IVertexSkinning
|