/// <summary> /// Writes this <see cref="MODEL"/> to a file in GLTF format. /// </summary> /// <param name="filePath">A valid file path to write to.</param> /// <param name="settings">Optional settings.</param> /// <remarks> /// Satellite files like buffers and images are also saved with the file name formatted as "FILE_{Index}.EXT". /// </remarks> public void SaveGLTF(string filePath, WriteSettings settings = null) { Guard.FilePathMustBeValid(filePath, nameof(filePath)); var context = IO.WriteContext .CreateFromFile(filePath); settings?.CopyTo(context); var name = Path.GetFileNameWithoutExtension(filePath); context.WriteTextSchema2(name, this); }
/// <summary> /// Writes this <see cref="MODEL"/> to a <see cref="Stream"/> in GLB format. /// </summary> /// <param name="stream">A <see cref="Stream"/> open for writing.</param> /// <param name="settings">Optional settings.</param> public void WriteGLB(Stream stream, WriteSettings settings = null) { Guard.NotNull(stream, nameof(stream)); Guard.IsTrue(stream.CanWrite, nameof(stream)); var context = IO.WriteContext.CreateFromStream(stream); if (settings != null) { settings.CopyTo(context); context.MergeBuffers = true; context.ImageWriting = ResourceWriteMode.Default; } context.WriteBinarySchema2("model", this); }
/// <summary> /// Writes this <see cref="MODEL"/> to a file in GLB format. /// </summary> /// <param name="filePath">A valid file path to write to.</param> /// <param name="settings">Optional settings.</param> public void SaveGLB(string filePath, WriteSettings settings = null) { Guard.FilePathMustBeValid(filePath, nameof(filePath)); var context = IO.WriteContext .CreateFromFile(filePath) .WithBinarySettings(); if (settings != null) { settings.CopyTo(context); } var name = Path.GetFileNameWithoutExtension(filePath); context.WriteBinarySchema2(name, this); }
public WriteSettings(WriteSettings other) { Guard.NotNull(other, nameof(other)); other.CopyTo(this); }
public WriteContext WithSettingsFrom(WriteSettings settings) { settings?.CopyTo(this); return(this); }