mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-04 01:11:05 -05:00
UniVRM-0.95.0
This commit is contained in:
parent
48e4d71c43
commit
e22189c7bb
|
|
@ -4,8 +4,8 @@ namespace UniGLTF
|
|||
public static partial class UniGLTFVersion
|
||||
{
|
||||
public const int MAJOR = 2;
|
||||
public const int MINOR = 30;
|
||||
public const int MINOR = 31;
|
||||
public const int PATCH = 0;
|
||||
public const string VERSION = "2.30.0";
|
||||
public const string VERSION = "2.31.0";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.vrmc.gltf",
|
||||
"version": "0.94.0",
|
||||
"version": "0.95.0",
|
||||
"displayName": "UniGLTF",
|
||||
"description": "GLTF importer and exporter",
|
||||
"unity": "2019.4",
|
||||
|
|
@ -11,6 +11,6 @@
|
|||
"name": "VRM Consortium"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.vrmc.vrmshaders": "0.94.0"
|
||||
"com.vrmc.vrmshaders": "0.95.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ namespace VRM
|
|||
public static partial class VRMVersion
|
||||
{
|
||||
public const int MAJOR = 0;
|
||||
public const int MINOR = 94;
|
||||
public const int MINOR = 95;
|
||||
public const int PATCH = 0;
|
||||
public const string VERSION = "0.94.0";
|
||||
public const string VERSION = "0.95.0";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,27 +85,8 @@ namespace VRM.FirstPersonSample
|
|||
|
||||
// GLB形式でJSONを取得しParseします
|
||||
// VRM extension を parse します
|
||||
var data = new GlbFileParser(path).Parse();
|
||||
var vrm = new VRMData(data);
|
||||
using (var context = new VRMImporterContext(vrm))
|
||||
{
|
||||
// metaを取得(todo: thumbnailテクスチャのロード)
|
||||
var meta = await context.ReadMetaAsync();
|
||||
Debug.LogFormat("meta: title:{0}", meta.Title);
|
||||
|
||||
// ParseしたJSONをシーンオブジェクトに変換していく
|
||||
var loaded = default(RuntimeGltfInstance);
|
||||
if (m_loadAsync)
|
||||
{
|
||||
loaded = await context.LoadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
loaded = context.Load();
|
||||
}
|
||||
|
||||
OnLoaded(loaded);
|
||||
}
|
||||
var loaded = await VrmUtility.LoadAsync(path);
|
||||
OnLoaded(loaded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -49,25 +49,11 @@ namespace VRM.RuntimeExporterSample
|
|||
return;
|
||||
}
|
||||
|
||||
// GLB形式でJSONを取得しParseします
|
||||
var data = new GlbFileParser(path).Parse();
|
||||
// VRM extension を parse します
|
||||
var vrm = new VRMData(data);
|
||||
using (var context = new VRMImporterContext(vrm))
|
||||
{
|
||||
var loaded = await VrmUtility.LoadAsync(path);
|
||||
|
||||
// metaを取得(todo: thumbnailテクスチャのロード)
|
||||
var meta = await context.ReadMetaAsync();
|
||||
Debug.LogFormat("meta: title:{0}", meta.Title);
|
||||
|
||||
// ParseしたJSONをシーンオブジェクトに変換していく
|
||||
var loaded = await context.LoadAsync();
|
||||
|
||||
loaded.ShowMeshes();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
|
||||
OnLoaded(loaded.gameObject);
|
||||
}
|
||||
loaded.ShowMeshes();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
OnLoaded(loaded.gameObject);
|
||||
}
|
||||
|
||||
void OnLoaded(GameObject go)
|
||||
|
|
|
|||
|
|
@ -103,10 +103,8 @@ namespace VRM.SimpleViewer
|
|||
m_textDistributionOther.text = "";
|
||||
}
|
||||
|
||||
public async Task UpdateMetaAsync(VRMImporterContext context)
|
||||
public void UpdateMeta(VRMMetaObject meta)
|
||||
{
|
||||
var meta = await context.ReadMetaAsync(new ImmediateCaller(), true);
|
||||
|
||||
m_textModelTitle.text = meta.Title;
|
||||
m_textModelVersion.text = meta.Version;
|
||||
m_textModelAuthor.text = meta.Author;
|
||||
|
|
@ -321,7 +319,7 @@ namespace VRM.SimpleViewer
|
|||
string[] cmds = System.Environment.GetCommandLineArgs();
|
||||
if (cmds.Length > 1)
|
||||
{
|
||||
LoadModel(cmds[1]);
|
||||
LoadModelAsync(cmds[1]);
|
||||
}
|
||||
|
||||
m_texts.Start();
|
||||
|
|
@ -366,10 +364,10 @@ namespace VRM.SimpleViewer
|
|||
return;
|
||||
}
|
||||
|
||||
LoadModel(path);
|
||||
LoadModelAsync(path);
|
||||
}
|
||||
|
||||
void LoadModel(string path)
|
||||
async void LoadModelAsync(string path)
|
||||
{
|
||||
var ext = Path.GetExtension(path).ToLower();
|
||||
switch (ext)
|
||||
|
|
@ -377,12 +375,21 @@ namespace VRM.SimpleViewer
|
|||
case ".gltf":
|
||||
case ".glb":
|
||||
case ".zip":
|
||||
LoadModelAsync(path, false);
|
||||
break;
|
||||
{
|
||||
var instance = await GltfUtility.LoadAsync(path,
|
||||
GetIAwaitCaller(m_useAsync.isOn),
|
||||
GetGltfMaterialGenerator(m_useUrpMaterial.isOn));
|
||||
break;
|
||||
}
|
||||
|
||||
case ".vrm":
|
||||
LoadModelAsync(path, true);
|
||||
break;
|
||||
{
|
||||
VrmUtility.MaterialGeneratorCallback materialCallback = (VRM.glTF_VRM_extensions vrm) => GetVrmMaterialGenerator(m_useUrpMaterial.isOn, vrm);
|
||||
VrmUtility.MetaCallback metaCallback = m_texts.UpdateMeta;
|
||||
var instance = await VrmUtility.LoadAsync(path, GetIAwaitCaller(m_useAsync.isOn), materialCallback, metaCallback);
|
||||
SetModel(instance);
|
||||
break;
|
||||
}
|
||||
|
||||
case ".bvh":
|
||||
LoadMotion(path, File.ReadAllText(path));
|
||||
|
|
@ -431,59 +438,6 @@ namespace VRM.SimpleViewer
|
|||
}
|
||||
}
|
||||
|
||||
async void LoadModelAsync(string path, bool isVrm)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogFormat("{0}", path);
|
||||
|
||||
GltfData data;
|
||||
try
|
||||
{
|
||||
data = new AutoGltfFileParser(path).Parse();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarningFormat("parse error: {0}", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isVrm)
|
||||
{
|
||||
try
|
||||
{
|
||||
var vrm = new VRMData(data);
|
||||
using (var loader = new VRMImporterContext(vrm, materialGenerator: GetVrmMaterialGenerator(m_useUrpMaterial.isOn, vrm.VrmExtension)))
|
||||
{
|
||||
await m_texts.UpdateMetaAsync(loader);
|
||||
var instance = await loader.LoadAsync(GetIAwaitCaller(m_useAsync.isOn));
|
||||
SetModel(instance);
|
||||
}
|
||||
}
|
||||
catch (NotVrm0Exception)
|
||||
{
|
||||
// retry
|
||||
Debug.LogWarning("file extension is vrm. but not vrm ?");
|
||||
using (var loader = new UniGLTF.ImporterContext(data, materialGenerator: GetGltfMaterialGenerator(m_useUrpMaterial.isOn)))
|
||||
{
|
||||
var instance = await loader.LoadAsync(GetIAwaitCaller(m_useAsync.isOn));
|
||||
SetModel(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var loader = new UniGLTF.ImporterContext(data, materialGenerator: GetGltfMaterialGenerator(m_useUrpMaterial.isOn)))
|
||||
{
|
||||
var instance = await loader.LoadAsync(GetIAwaitCaller(m_useAsync.isOn));
|
||||
SetModel(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetModel(RuntimeGltfInstance instance)
|
||||
{
|
||||
// cleanup
|
||||
|
|
@ -495,7 +449,7 @@ namespace VRM.SimpleViewer
|
|||
|
||||
if (m_useFastSpringBone.isOn)
|
||||
{
|
||||
FastSpringBoneReplacer.ReplaceAsync(instance.Root);
|
||||
var _ = FastSpringBoneReplacer.ReplaceAsync(instance.Root);
|
||||
}
|
||||
|
||||
instance.EnableUpdateWhenOffscreen();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.vrmc.univrm",
|
||||
"version": "0.94.0",
|
||||
"version": "0.95.0",
|
||||
"displayName": "VRM",
|
||||
"description": "VRM importer",
|
||||
"unity": "2019.4",
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
"name": "VRM Consortium"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.vrmc.vrmshaders": "0.94.0",
|
||||
"com.vrmc.gltf": "0.94.0"
|
||||
"com.vrmc.vrmshaders": "0.95.0",
|
||||
"com.vrmc.gltf": "0.95.0"
|
||||
},
|
||||
"samples": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,27 +82,16 @@ namespace UniVRM10.FirstPersonSample
|
|||
}
|
||||
m_target = humanPoseTransfer;
|
||||
SetupTarget(m_target);
|
||||
|
||||
instance.ShowMeshes();
|
||||
}
|
||||
|
||||
async Task<RuntimeGltfInstance> LoadAsync(string path)
|
||||
async Task<Vrm10Instance> LoadAsync(string path)
|
||||
{
|
||||
var data = new GlbFileParser(path).Parse();
|
||||
if (!Vrm10Data.TryParseOrMigrate(data, true, out Vrm10Data vrm))
|
||||
{
|
||||
throw new System.Exception("vrm parse error !");
|
||||
}
|
||||
using (var loader = new Vrm10Importer(vrm))
|
||||
{
|
||||
var instance = await loader.LoadAsync();
|
||||
var instance = await Vrm10.LoadPathAsync(path);
|
||||
|
||||
// VR用 FirstPerson 設定
|
||||
var controller = instance.GetComponent<Vrm10Instance>();
|
||||
await controller.Vrm.FirstPerson.SetupAsync(controller.gameObject);
|
||||
// VR用 FirstPerson 設定
|
||||
await instance.Vrm.FirstPerson.SetupAsync(instance.gameObject);
|
||||
|
||||
return instance;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void LoadBVHClicked()
|
||||
|
|
|
|||
|
|
@ -96,55 +96,45 @@ namespace UniVRM10.VRM10Viewer
|
|||
m_textDistributionOther.text = "";
|
||||
}
|
||||
|
||||
public void UpdateMeta(Migration.Vrm0Meta meta, Texture2D thumbnail)
|
||||
public void UpdateMeta(Texture2D thumbnail, UniGLTF.Extensions.VRMC_vrm.Meta meta, Migration.Vrm0Meta meta0)
|
||||
{
|
||||
if (meta == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_textModelTitle.text = meta.title;
|
||||
m_textModelVersion.text = meta.version;
|
||||
m_textModelAuthor.text = meta.author;
|
||||
m_textModelContact.text = meta.contactInformation;
|
||||
m_textModelReference.text = meta.reference;
|
||||
m_textPermissionAllowed.text = meta.allowedUser.ToString();
|
||||
m_textPermissionViolent.text = meta.violentUsage.ToString();
|
||||
m_textPermissionSexual.text = meta.sexualUsage.ToString();
|
||||
m_textPermissionCommercial.text = meta.commercialUsage.ToString();
|
||||
m_textPermissionOther.text = meta.otherPermissionUrl;
|
||||
|
||||
// m_textDistributionLicense.text = meta.ModificationLicense.ToString();
|
||||
m_textDistributionOther.text = meta.otherLicenseUrl;
|
||||
|
||||
m_thumbnail.texture = thumbnail;
|
||||
}
|
||||
|
||||
public void UpdateMeta(UniGLTF.Extensions.VRMC_vrm.Meta meta, Texture2D thumbnail)
|
||||
{
|
||||
if (meta == null)
|
||||
if (meta != null)
|
||||
{
|
||||
return;
|
||||
m_textModelTitle.text = meta.Name;
|
||||
m_textModelVersion.text = meta.Version;
|
||||
m_textModelAuthor.text = meta.Authors[0];
|
||||
m_textModelContact.text = meta.ContactInformation;
|
||||
if (meta.References != null && meta.References.Count > 0)
|
||||
{
|
||||
m_textModelReference.text = meta.References[0];
|
||||
}
|
||||
// m_textPermissionAllowed.text = meta.AllowedUser.ToString();
|
||||
m_textPermissionViolent.text = meta.AllowExcessivelyViolentUsage.ToString();
|
||||
m_textPermissionSexual.text = meta.AllowExcessivelySexualUsage.ToString();
|
||||
m_textPermissionCommercial.text = meta.CommercialUsage.ToString();
|
||||
// m_textPermissionOther.text = meta.OtherPermissionUrl;
|
||||
|
||||
// m_textDistributionLicense.text = meta.ModificationLicense.ToString();
|
||||
m_textDistributionOther.text = meta.OtherLicenseUrl;
|
||||
}
|
||||
|
||||
m_textModelTitle.text = meta.Name;
|
||||
m_textModelVersion.text = meta.Version;
|
||||
m_textModelAuthor.text = meta.Authors[0];
|
||||
m_textModelContact.text = meta.ContactInformation;
|
||||
if (meta.References != null && meta.References.Count > 0)
|
||||
if (meta0 != null)
|
||||
{
|
||||
m_textModelReference.text = meta.References[0];
|
||||
m_textModelTitle.text = meta0.title;
|
||||
m_textModelVersion.text = meta0.version;
|
||||
m_textModelAuthor.text = meta0.author;
|
||||
m_textModelContact.text = meta0.contactInformation;
|
||||
m_textModelReference.text = meta0.reference;
|
||||
m_textPermissionAllowed.text = meta0.allowedUser.ToString();
|
||||
m_textPermissionViolent.text = meta0.violentUsage.ToString();
|
||||
m_textPermissionSexual.text = meta0.sexualUsage.ToString();
|
||||
m_textPermissionCommercial.text = meta0.commercialUsage.ToString();
|
||||
m_textPermissionOther.text = meta0.otherPermissionUrl;
|
||||
// m_textDistributionLicense.text = meta0.ModificationLicense.ToString();
|
||||
m_textDistributionOther.text = meta0.otherLicenseUrl;
|
||||
}
|
||||
// m_textPermissionAllowed.text = meta.AllowedUser.ToString();
|
||||
m_textPermissionViolent.text = meta.AllowExcessivelyViolentUsage.ToString();
|
||||
m_textPermissionSexual.text = meta.AllowExcessivelySexualUsage.ToString();
|
||||
m_textPermissionCommercial.text = meta.CommercialUsage.ToString();
|
||||
// m_textPermissionOther.text = meta.OtherPermissionUrl;
|
||||
|
||||
// m_textDistributionLicense.text = meta.ModificationLicense.ToString();
|
||||
m_textDistributionOther.text = meta.OtherLicenseUrl;
|
||||
|
||||
m_thumbnail.texture = thumbnail;
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
|
|
@ -425,62 +415,22 @@ namespace UniVRM10.VRM10Viewer
|
|||
}
|
||||
|
||||
Debug.LogFormat("{0}", path);
|
||||
GltfData data;
|
||||
try
|
||||
var vrm10Instance = await Vrm10.LoadPathAsync(path,
|
||||
canLoadVrm0X: true,
|
||||
normalizeTransform: m_useNormalization.isOn,
|
||||
showMeshes: false,
|
||||
awaitCaller: new RuntimeOnlyAwaitCaller(),
|
||||
materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn),
|
||||
vrmMetaInformationCallback: m_texts.UpdateMeta);
|
||||
if (vrm10Instance != null)
|
||||
{
|
||||
data = new AutoGltfFileParser(path).Parse();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning(ex);
|
||||
return;
|
||||
}
|
||||
|
||||
var vrm = await System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
if (Vrm10Data.TryParseOrMigrate(data, doMigrate: true, out Vrm10Data _vrm))
|
||||
{
|
||||
return _vrm;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if (vrm != null)
|
||||
{
|
||||
// vrm
|
||||
using (var loader = new Vrm10Importer(vrm,
|
||||
materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn),
|
||||
doNormalize: m_useNormalization.isOn))
|
||||
{
|
||||
// migrate しても thumbnail は同じ
|
||||
var thumbnail = await loader.LoadVrmThumbnailAsync();
|
||||
|
||||
if (vrm.OriginalMetaBeforeMigration != null)
|
||||
{
|
||||
// migrated from vrm-0.x. use OldMeta
|
||||
m_texts.UpdateMeta(vrm.OriginalMetaBeforeMigration, thumbnail);
|
||||
}
|
||||
else
|
||||
{
|
||||
// load vrm-1.0. use newMeta
|
||||
m_texts.UpdateMeta(vrm.VrmExtension.Meta, thumbnail);
|
||||
}
|
||||
|
||||
var instance = await loader.LoadAsync(new RuntimeOnlyAwaitCaller());
|
||||
SetModel(instance);
|
||||
}
|
||||
SetModel(vrm10Instance.GetComponent<RuntimeGltfInstance>());
|
||||
}
|
||||
else
|
||||
{
|
||||
// gltf
|
||||
using (var loader = new UniGLTF.ImporterContext(data, materialGenerator: GetMaterialDescriptorGenerator(m_useUrpMaterial.isOn)))
|
||||
{
|
||||
var instance = await loader.LoadAsync(new RuntimeOnlyAwaitCaller());
|
||||
SetModel(instance);
|
||||
}
|
||||
// fallback to gltf
|
||||
var instance = await GltfUtility.LoadAsync(path, awaitCaller: new RuntimeOnlyAwaitCaller());
|
||||
SetModel(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.vrmc.vrm",
|
||||
"version": "0.94.0",
|
||||
"version": "0.95.0",
|
||||
"displayName": "VRM-1.0β",
|
||||
"description": "VRM-1.0β importer",
|
||||
"unity": "2019.4",
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
"name": "VRM Consortium"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.vrmc.vrmshaders": "0.94.0",
|
||||
"com.vrmc.gltf": "0.94.0"
|
||||
"com.vrmc.vrmshaders": "0.95.0",
|
||||
"com.vrmc.gltf": "0.95.0"
|
||||
},
|
||||
"samples": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.vrmc.vrmshaders",
|
||||
"version": "0.94.0",
|
||||
"version": "0.95.0",
|
||||
"displayName": "VRM Shaders",
|
||||
"description": "VRM Shaders",
|
||||
"unity": "2019.4",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user