ModelWriter¶
Namespace Nfty.Model in assembly Nfty.Model.
Writes a risen mesh and its texture as model files. Every format is serialized from ONE glTF object model; they differ only in where the buffer lives, and that is set in the object model, never by editing serialized text.
Methods¶
Write(Mesh, Image<Rgba32>, RiseOptions, string, StackFaces?)¶
public static IReadOnlyList<ModelFile> Write(Mesh mesh, Image<Rgba32> art, RiseOptions options, string baseName, StackFaces? faces = null);
Writes one model.
Parameters
mesh(Mesh) - The mesh, fromRiser.TryBuild().art(Image<Rgba32>) - The picture the mesh was risen from — the same size. Not modified. The texture is theFaceAtlasbuilt from it.options(RiseOptions) - Which format to write.baseName(string) - The file name without extension, and without any folder.faces(StackFaces?) - The stack's face owners (the atlas halves), ornullfor a single picture. Borrowed, not disposed.
Returns. The files: one for ModelFormat.Glb and ModelFormat.GltfEmbedded, two (.gltf then .bin) for ModelFormat.GltfWithBin.
Exceptions
ArgumentException- The art or faces are another size than the mesh was risen from, or the base name is not a plain file name.ArgumentOutOfRangeException-options'sRiseOptions.Formatis not one ofModelFormat's named values.
WriteAtlas(Mesh, Image<Rgba32>, RiseOptions, string)¶
public static IReadOnlyList<ModelFile> WriteAtlas(Mesh mesh, Image<Rgba32> atlas, RiseOptions options, string baseName);
Writes one model from a texture that is already the mesh's FaceAtlas: what a viewer holds when it was handed a mesh and its atlas but not the art they came from. The bytes are exactly those ModelWriter.Write() produces for the same atlas.
Parameters
mesh(Mesh) - The mesh.atlas(Image<Rgba32>) - The atlas the mesh's UVs address; not modified.options(RiseOptions) - Which format to write.baseName(string) - The file name without extension, and without any folder.
Returns. The files, as for ModelWriter.Write().
Exceptions
ArgumentException- The atlas is not the size the mesh addresses, or the base name is not a plain file name.ArgumentOutOfRangeException-options's format is not named.