mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 15:08:02 -05:00
implement build meta
This commit is contained in:
parent
6244f6a1fe
commit
5df1576a70
|
|
@ -95,7 +95,7 @@ namespace UniVRM10.Samples
|
|||
m_textModelVersion.text = meta.Version;
|
||||
m_textModelAuthor.text = meta.Authors[0];
|
||||
m_textModelContact.text = meta.ContactInformation;
|
||||
m_textModelReference.text = meta.Reference;
|
||||
m_textModelReference.text = meta.References[0];
|
||||
|
||||
m_textPermissionAllowed.text = meta.AllowedUser.ToString();
|
||||
m_textPermissionViolent.text = meta.ViolentUsage.ToString();
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace UniVRM10
|
|||
{
|
||||
return ("", MessageType.None);
|
||||
});
|
||||
m_reference = new ValidateProperty(serializedObject.FindProperty(nameof(m_target.Reference)), prop =>
|
||||
m_reference = new ValidateProperty(serializedObject.FindProperty(nameof(m_target.References)), prop =>
|
||||
{
|
||||
return ("", MessageType.None);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace UniVRM10
|
|||
Selection.selectionChanged += Repaint;
|
||||
|
||||
m_tmpMeta = ScriptableObject.CreateInstance<VRM10MetaObject>();
|
||||
m_tmpMeta.Authors = new string[] { "" };
|
||||
m_tmpMeta.Authors = new List<string> { "" };
|
||||
|
||||
m_state = new MeshUtility.ExporterDialogState();
|
||||
m_state.ExportRootChanged += (root) =>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ namespace UniVRM10
|
|||
[CreateAssetMenu(menuName = "VRM10/ExpressionAvatar")]
|
||||
public sealed class VRM10ExpressionAvatar : ScriptableObject
|
||||
{
|
||||
public const string ExtractKey = ".ExpressionAvatar";
|
||||
|
||||
[SerializeField]
|
||||
public List<VRM10Expression> Clips = new List<VRM10Expression>();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ namespace UniVRM10
|
|||
[CreateAssetMenu(menuName = "VRM10/MetaObject")]
|
||||
public class VRM10MetaObject : ScriptableObject
|
||||
{
|
||||
public const string ExtractKey = ".Meta";
|
||||
|
||||
[SerializeField]
|
||||
public string ExporterVersion;
|
||||
|
||||
|
|
@ -24,13 +26,13 @@ namespace UniVRM10
|
|||
public string CopyrightInformation;
|
||||
|
||||
[SerializeField]
|
||||
public string[] Authors;
|
||||
public List<string> Authors = new List<string>();
|
||||
|
||||
[SerializeField]
|
||||
public string ContactInformation;
|
||||
|
||||
[SerializeField]
|
||||
public string Reference;
|
||||
public List<string> References = new List<string>();
|
||||
|
||||
[SerializeField]
|
||||
public Texture2D Thumbnail;
|
||||
|
|
@ -80,7 +82,7 @@ namespace UniVRM10
|
|||
yield return Validation.Error("Require Name. ");
|
||||
}
|
||||
|
||||
if (Authors == null || Authors.Length == 0)
|
||||
if (Authors == null || Authors.Count == 0)
|
||||
{
|
||||
yield return Validation.Error("Require at leaset one Author.");
|
||||
}
|
||||
|
|
@ -99,14 +101,14 @@ namespace UniVRM10
|
|||
dst.CopyrightInformation = CopyrightInformation;
|
||||
if (Authors != null)
|
||||
{
|
||||
dst.Authors = Authors.Select(x => x).ToArray();
|
||||
dst.Authors = Authors.Select(x => x).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dst.Authors = new string[] { };
|
||||
dst.Authors = new List<string>();
|
||||
}
|
||||
dst.ContactInformation = ContactInformation;
|
||||
dst.Reference = Reference;
|
||||
dst.References = References;
|
||||
dst.Thumbnail = Thumbnail;
|
||||
dst.AllowedUser = AllowedUser;
|
||||
dst.ViolentUsage = ViolentUsage;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,8 @@ namespace UniVRM10
|
|||
}
|
||||
|
||||
UnityEngine.Avatar m_humanoid;
|
||||
UniVRM10.VRM10ExpressionAvatar m_exressionAvatar;
|
||||
VRM10MetaObject m_meta;
|
||||
VRM10ExpressionAvatar m_exressionAvatar;
|
||||
|
||||
protected override async Task OnLoadHierarchy(IAwaitCaller awaitCaller, Func<string, IDisposable> MeasureTime)
|
||||
{
|
||||
|
|
@ -213,7 +214,41 @@ namespace UniVRM10
|
|||
// meta
|
||||
if (m_vrm.Meta != null)
|
||||
{
|
||||
|
||||
var src = m_vrm.Meta;
|
||||
m_meta = ScriptableObject.CreateInstance<VRM10MetaObject>();
|
||||
m_meta.name = VRM10MetaObject.ExtractKey;
|
||||
controller.Meta = m_meta;
|
||||
m_meta.Name = src.Name;
|
||||
m_meta.Version = src.Version;
|
||||
m_meta.ContactInformation = src.ContactInformation;
|
||||
// avatar
|
||||
m_meta.AllowedUser = src.AvatarPermission;
|
||||
m_meta.ViolentUsage = src.AllowExcessivelyViolentUsage.Value;
|
||||
m_meta.SexualUsage = src.AllowExcessivelySexualUsage.Value;
|
||||
m_meta.CommercialUsage = src.CommercialUsage;
|
||||
m_meta.PoliticalOrReligiousUsage = src.AllowPoliticalOrReligiousUsage.Value;
|
||||
// redistribution
|
||||
m_meta.CreditNotation = src.CreditNotation;
|
||||
m_meta.Redistribution = src.AllowRedistribution.Value;
|
||||
m_meta.ModificationLicense = src.Modification;
|
||||
m_meta.OtherLicenseUrl = src.OtherLicenseUrl;
|
||||
//
|
||||
if (src.References != null)
|
||||
{
|
||||
m_meta.References.AddRange(src.References);
|
||||
}
|
||||
if (src.Authors != null)
|
||||
{
|
||||
m_meta.Authors.AddRange(src.Authors);
|
||||
}
|
||||
if (Vrm10MToonMaterialImporter.TryGetMetaThumbnailTextureImportParam(Parser, m_vrm, out VRMShaders.TextureImportParam param))
|
||||
{
|
||||
var texture = await TextureFactory.GetTextureAsync(param);
|
||||
if (texture != null)
|
||||
{
|
||||
m_meta.Thumbnail = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// firstPerson
|
||||
|
|
@ -221,10 +256,10 @@ namespace UniVRM10
|
|||
// expression
|
||||
if (m_vrm.Expressions != null)
|
||||
{
|
||||
controller.Expression.ExpressionAvatar = ScriptableObject.CreateInstance<UniVRM10.VRM10ExpressionAvatar>();
|
||||
controller.Expression.ExpressionAvatar = ScriptableObject.CreateInstance<VRM10ExpressionAvatar>();
|
||||
|
||||
m_exressionAvatar = controller.Expression.ExpressionAvatar;
|
||||
m_exressionAvatar.name = "ExpressionAvatar";
|
||||
m_exressionAvatar.name = VRM10ExpressionAvatar.ExtractKey;
|
||||
|
||||
foreach (var expression in m_vrm.Expressions)
|
||||
{
|
||||
|
|
@ -336,10 +371,10 @@ namespace UniVRM10
|
|||
m_humanoid = null;
|
||||
}
|
||||
|
||||
// if (take(Meta))
|
||||
// {
|
||||
// Meta = null;
|
||||
// }
|
||||
if (take(m_meta))
|
||||
{
|
||||
m_meta = null;
|
||||
}
|
||||
|
||||
foreach (var x in m_exressionAvatar.Clips)
|
||||
{
|
||||
|
|
@ -367,10 +402,10 @@ namespace UniVRM10
|
|||
{
|
||||
destroy(m_humanoid);
|
||||
}
|
||||
// if (Meta != null)
|
||||
// {
|
||||
// destroy(Meta);
|
||||
// }
|
||||
if (m_meta != null)
|
||||
{
|
||||
destroy(m_meta);
|
||||
}
|
||||
if (m_exressionAvatar != null)
|
||||
{
|
||||
foreach (var clip in m_exressionAvatar.Clips)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,40 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VRM-1 の thumbnail テクスチャー。gltf.textures ではなく gltf.images の参照であることに注意(sampler等の設定が無い)
|
||||
///
|
||||
/// MToonとは無関係だがとりあえずここに
|
||||
/// </summary>
|
||||
/// <param name="parser"></param>
|
||||
/// <param name="vrm"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetMetaThumbnailTextureImportParam(GltfParser parser, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm, out TextureImportParam value)
|
||||
{
|
||||
if (!vrm.Meta.ThumbnailImage.HasValue)
|
||||
{
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
// thumbnail
|
||||
var imageIndex = vrm.Meta.ThumbnailImage.Value;
|
||||
var gltfImage = parser.GLTF.images[imageIndex];
|
||||
var name = new TextureImportName(TextureImportTypes.sRGB, gltfImage.name, gltfImage.GetExt(), "");
|
||||
|
||||
GetTextureBytesAsync getBytesAsync = () =>
|
||||
{
|
||||
var bytes = parser.GLTF.GetImageBytes(parser.Storage, imageIndex);
|
||||
return Task.FromResult(GltfTextureImporter.ToArray(bytes));
|
||||
};
|
||||
value = new TextureImportParam(name, Vector2.zero, Vector2.one, default, TextureImportTypes.sRGB, default, default,
|
||||
getBytesAsync, default, default,
|
||||
default, default, default
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// glTF 全体で使うテクスチャーをユニークになるように列挙する
|
||||
/// </summary>
|
||||
|
|
@ -97,25 +131,12 @@ namespace UniVRM10
|
|||
{
|
||||
throw new System.Exception("not vrm");
|
||||
}
|
||||
if (vrm.Meta.ThumbnailImage.HasValue)
|
||||
|
||||
if (TryGetMetaThumbnailTextureImportParam(parser, vrm, out TextureImportParam thumbnail))
|
||||
{
|
||||
// thumbnail
|
||||
var imageIndex = vrm.Meta.ThumbnailImage.Value;
|
||||
var gltfImage = parser.GLTF.images[imageIndex];
|
||||
var name = new TextureImportName(TextureImportTypes.sRGB, gltfImage.name, gltfImage.GetExt(), "");
|
||||
|
||||
GetTextureBytesAsync getBytesAsync = () =>
|
||||
{
|
||||
var bytes = parser.GLTF.GetImageBytes(parser.Storage, imageIndex);
|
||||
return Task.FromResult(GltfTextureImporter.ToArray(bytes));
|
||||
};
|
||||
yield return new TextureImportParam(name, Vector2.zero, Vector2.one, default, TextureImportTypes.sRGB, default, default,
|
||||
getBytesAsync, default, default,
|
||||
default, default, default
|
||||
);
|
||||
yield return thumbnail;
|
||||
}
|
||||
|
||||
|
||||
var used = new HashSet<string>();
|
||||
for (int i = 0; i < parser.GLTF.materials.Count; ++i)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user