mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-25 07:28:51 -05:00
Vrm10BoneTransfromExpression
This commit is contained in:
parent
d4f6d3dddb
commit
ad9b88eb4e
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
|
@ -7,19 +7,32 @@ namespace UniVRM10
|
|||
{
|
||||
internal sealed class BoneTransformBindingMerger
|
||||
{
|
||||
Dictionary<ExpressionKey, float> _acum = new();
|
||||
// Vrm10BoneTransformExpression[] _expressions;
|
||||
Transform _root;
|
||||
|
||||
public BoneTransformBindingMerger(Transform root)
|
||||
{
|
||||
// _expressions = root.GetComponentsInChildren<Vrm10BoneTransformExpression>();
|
||||
_root = root;
|
||||
}
|
||||
|
||||
public void AccumulateValue(ExpressionKey key, float value)
|
||||
{
|
||||
_acum[key] = value;
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AccumulateValue(VRM10Expression clip, float value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
foreach (var expression in _root.GetComponentsInChildren<Vrm10BoneTransformExpression>())
|
||||
{
|
||||
var transform = expression.transform;
|
||||
var tr = expression.Expression.Transformation;
|
||||
var m = Matrix4x4.TRS(tr.Translation, tr.Rotation, Vector3.one);
|
||||
var w = m * transform.localToWorldMatrix;
|
||||
var (t, r, s) = w.Decompose();
|
||||
transform.SetPositionAndRotation(t, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ namespace UniVRM10
|
|||
|
||||
m_morphTargetBindingMerger.AccumulateValue(key, value);
|
||||
m_materialValueBindingMerger.AccumulateValue(clip, value);
|
||||
m_boneTransformBindingMerger.AccumulateValue(clip, value);
|
||||
m_boneTransformBindingMerger.AccumulateValue(key, value);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using UniGLTF.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Vrm10BoneTransformExpression : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class BoneTransformExpression
|
||||
{
|
||||
public ExpressionPreset Preset;
|
||||
public EuclideanTransform Transformation = new EuclideanTransform(Quaternion.identity, Vector3.zero);
|
||||
}
|
||||
|
||||
public BoneTransformExpression Expression;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1520687d88c34af4eb8c16bb37ee0391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user