restore expression

This commit is contained in:
ousttrue 2024-11-01 19:27:09 +09:00
parent 1584ca90d5
commit d059cbea79
2 changed files with 27 additions and 27 deletions

View File

@ -8,24 +8,24 @@ namespace UniVRM10
{
public static class ExpressionExtensions
{
// public static MorphTargetBinding? Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer.ModelMap loader, VrmLib.Model model)
// {
// if (bind.Node.TryGetValidIndex(model.Nodes.Count, out var nodeIndex))
// {
// var libNode = model.Nodes[nodeIndex];
// if (libNode.MeshGroup == null)
// {
// return default;
// }
// var node = loader.Nodes[libNode].transform;
// var relativePath = node.RelativePathFrom(root.transform);
// return new MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
// }
// else
// {
// return default;
// }
// }
public static MorphTargetBinding? Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer importer)
{
if (bind.Node.TryGetValidIndex(importer.Nodes.Count, out var nodeIndex))
{
var node = importer.Nodes[nodeIndex];
var smr = node.GetComponent<SkinnedMeshRenderer>();
if (smr == null)
{
return default;
}
var relativePath = node.RelativePathFrom(root.transform);
return new MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
}
else
{
return default;
}
}
public static UniVRM10.MaterialColorBinding? Build10(this MaterialColorBind bind, IReadOnlyList<MaterialFactory.MaterialLoadInfo> materials)
{

View File

@ -420,15 +420,15 @@ namespace UniVRM10
clip.OverrideLookAt = expression.OverrideLookAt;
clip.OverrideMouth = expression.OverrideMouth;
// if (expression.MorphTargetBinds != null)
// {
// clip.MorphTargetBindings = expression.MorphTargetBinds?
// .Select(x => x.Build10(Root, m_map, m_model))
// .Where(x => x.HasValue)
// .Select(x => x.Value)
// .ToArray();
// }
// else
if (expression.MorphTargetBinds != null)
{
clip.MorphTargetBindings = expression.MorphTargetBinds?
.Select(x => x.Build10(Root, this))
.Where(x => x.HasValue)
.Select(x => x.Value)
.ToArray();
}
else
{
clip.MorphTargetBindings = new MorphTargetBinding[] { };
}