mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-11 21:14:19 -05:00
implement importer normalize
This commit is contained in:
parent
ed047383f7
commit
99d1b5df63
|
|
@ -36,8 +36,8 @@ namespace UniVRM10
|
|||
/// <param name="context"></param>
|
||||
/// <param name="migrateToVrm1">vrm0 だった場合に vrm1 化する</param>
|
||||
/// <param name="renderPipeline"></param>
|
||||
/// <param name="normalize">normalize する</param>
|
||||
public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool migrateToVrm1, RenderPipelineTypes renderPipeline, bool normalize)
|
||||
/// <param name="doNormalize">normalize する</param>
|
||||
public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool migrateToVrm1, RenderPipelineTypes renderPipeline, bool doNormalize)
|
||||
{
|
||||
#if VRM_DEVELOP
|
||||
Debug.Log("OnImportAsset to " + scriptedImporter.assetPath);
|
||||
|
|
@ -58,7 +58,9 @@ namespace UniVRM10
|
|||
|
||||
var materialGenerator = GetMaterialDescriptorGenerator(renderPipeline);
|
||||
|
||||
using (var loader = new Vrm10Importer(result, extractedObjects, materialGenerator: materialGenerator))
|
||||
using (var loader = new Vrm10Importer(result, extractedObjects,
|
||||
materialGenerator: materialGenerator,
|
||||
doNormalize: doNormalize))
|
||||
{
|
||||
// settings TextureImporters
|
||||
foreach (var textureInfo in loader.TextureDescriptorGenerator.Get().GetEnumerable())
|
||||
|
|
|
|||
|
|
@ -20,11 +20,14 @@ namespace UniVRM10
|
|||
|
||||
IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> m_externalMap;
|
||||
|
||||
readonly bool m_doNormalize;
|
||||
|
||||
public Vrm10Importer(
|
||||
Vrm10Data vrm,
|
||||
IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> externalObjectMap = null,
|
||||
ITextureDeserializer textureDeserializer = null,
|
||||
IMaterialDescriptorGenerator materialGenerator = null)
|
||||
IMaterialDescriptorGenerator materialGenerator = null,
|
||||
bool doNormalize = false)
|
||||
: base(vrm.Data, externalObjectMap, textureDeserializer)
|
||||
{
|
||||
if (vrm == null)
|
||||
|
|
@ -32,6 +35,7 @@ namespace UniVRM10
|
|||
throw new ArgumentNullException("vrm");
|
||||
}
|
||||
m_vrm = vrm;
|
||||
m_doNormalize = doNormalize;
|
||||
|
||||
TextureDescriptorGenerator = new Vrm10TextureDescriptorGenerator(Data);
|
||||
MaterialDescriptorGenerator = materialGenerator ?? new Vrm10MaterialDescriptorGenerator();
|
||||
|
|
@ -74,6 +78,12 @@ namespace UniVRM10
|
|||
// bin に対して右手左手変換を破壊的に実行することに注意 !(bin が変換済みになる)
|
||||
m_model = ModelReader.Read(Data);
|
||||
|
||||
if (m_doNormalize)
|
||||
{
|
||||
var result = VrmLib.ModelModifierExtensions.SkinningBake(new VrmLib.ModelModifier(m_model));
|
||||
Debug.Log($"SkinningBake: {result}");
|
||||
}
|
||||
|
||||
// assign humanoid bones
|
||||
if (m_vrm.VrmExtension.Humanoid is UniGLTF.Extensions.VRMC_vrm.Humanoid humanoid)
|
||||
{
|
||||
|
|
@ -251,7 +261,7 @@ namespace UniVRM10
|
|||
}
|
||||
// constraint
|
||||
await LoadConstraintAsync(awaitCaller, controller);
|
||||
|
||||
|
||||
// Hierarchyの構築が終わるまで遅延させる
|
||||
controller.enabled = true;
|
||||
}
|
||||
|
|
@ -361,7 +371,7 @@ namespace UniVRM10
|
|||
meta.Name = src.Name;
|
||||
meta.Version = src.Version;
|
||||
meta.ContactInformation = src.ContactInformation;
|
||||
meta.ThirdPartyLicenses = src.ThirdPartyLicenses;
|
||||
meta.ThirdPartyLicenses = src.ThirdPartyLicenses;
|
||||
// avatar
|
||||
meta.AvatarPermission = src.AvatarPermission;
|
||||
meta.ViolentUsage = src.AllowExcessivelyViolentUsage.GetValueOrDefault();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user