mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-25 03:31:29 -05:00
Merge pull request #961 from Santarh/refactorTextureSerializer
Refactoring Serializing Textures
This commit is contained in:
@@ -130,7 +130,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="settings"></param>
|
||||
@@ -225,7 +225,7 @@ namespace VRM
|
||||
using (var exporter = new VRMExporter(gltf))
|
||||
{
|
||||
exporter.Prepare(target);
|
||||
exporter.Export(settings.MeshExportSettings, AssetTextureUtil.IsTextureEditorAsset, AssetTextureUtil.GetTextureBytesWithMime);
|
||||
exporter.Export(settings.MeshExportSettings, new EditorTextureSerializer());
|
||||
}
|
||||
var bytes = gltf.ToGlbBytes();
|
||||
Debug.LogFormat("Export elapsed {0}", sw.Elapsed);
|
||||
|
||||
@@ -15,13 +15,13 @@ namespace VRM
|
||||
return new VRMMaterialExporter();
|
||||
}
|
||||
|
||||
public static glTF Export(MeshExportSettings configuration, GameObject go, Func<Texture, bool> useAsset, GetBytesWithMimeFromTexture2D getTextureBytes)
|
||||
public static glTF Export(MeshExportSettings configuration, GameObject go, ITextureSerializer textureSerializer)
|
||||
{
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new VRMExporter(gltf))
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export(configuration, useAsset, getTextureBytes);
|
||||
exporter.Export(configuration, textureSerializer);
|
||||
}
|
||||
return gltf;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace VRM
|
||||
gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
|
||||
}
|
||||
|
||||
public override void ExportExtensions(GetBytesWithMimeFromTexture2D getTextureBytes)
|
||||
public override void ExportExtensions(ITextureSerializer textureSerializer)
|
||||
{
|
||||
// avatar
|
||||
var animator = Copy.GetComponent<Animator>();
|
||||
@@ -111,7 +111,7 @@ namespace VRM
|
||||
VRM.meta.title = meta.Title;
|
||||
if (meta.Thumbnail != null)
|
||||
{
|
||||
VRM.meta.texture = glTF.PushGltfTexture(glTF.buffers.Count - 1, meta.Thumbnail, ColorSpace.sRGB, getTextureBytes);
|
||||
VRM.meta.texture = glTF.PushGltfTexture(glTF.buffers.Count - 1, meta.Thumbnail, ColorSpace.sRGB, textureSerializer);
|
||||
}
|
||||
|
||||
VRM.meta.licenseType = meta.LicenseType;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace VRM
|
||||
filterMode = FilterMode.Bilinear,
|
||||
};
|
||||
|
||||
var textureManager = new TextureExporter(AssetTextureUtil.IsTextureEditorAsset);
|
||||
var textureManager = new TextureExporter(new EditorTextureSerializer());
|
||||
var srcMaterial = new Material(Shader.Find("VRM/MToon"));
|
||||
|
||||
var offset = new Vector2(0.3f, 0.2f);
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace VRM
|
||||
try
|
||||
{
|
||||
// export
|
||||
var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, go, AssetTextureUtil.IsTextureEditorAsset, AssetTextureUtil.GetTextureBytesWithMime);
|
||||
var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, go, new EditorTextureSerializer());
|
||||
|
||||
// re import
|
||||
if (vrm != null)
|
||||
|
||||
@@ -49,12 +49,12 @@ namespace VRM
|
||||
|
||||
/// <summary>
|
||||
/// positions: [
|
||||
/// {1, 1, 0}
|
||||
/// {1, 1, 1}
|
||||
/// {1, 1, 2}
|
||||
/// {1, 1, 3}
|
||||
/// {1, 1, 4}
|
||||
/// {1, 1, 5}
|
||||
/// {1, 1, 0}
|
||||
/// {1, 1, 1}
|
||||
/// {1, 1, 2}
|
||||
/// {1, 1, 3}
|
||||
/// {1, 1, 4}
|
||||
/// {1, 1, 5}
|
||||
/// ]
|
||||
/// submesh
|
||||
/// 0 1 2
|
||||
@@ -73,7 +73,7 @@ namespace VRM
|
||||
ExportOnlyBlendShapePosition = true,
|
||||
ExportTangents = false,
|
||||
UseSparseAccessorForMorphTarget = true,
|
||||
}, loaded, AssetTextureUtil.IsTextureEditorAsset, AssetTextureUtil.GetTextureBytesWithMime);
|
||||
}, loaded, new EditorTextureSerializer());
|
||||
var bytes = exported.ToGlbBytes();
|
||||
var divided = Load(bytes, path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user