UniVRM/Assets/VRM10/Runtime/ControlRig/NormalizedRotationRigGetter.cs
ousttrue 6dd2bb38cc IControlRigGetter と IControlRigSetter を追加
add ControlRigRetarget
impl InitialRotationRigGetter.cs
impl NormalizedRotationRigGetter.cs
mv Assets/Vrm10/Runtime/ControlRig/Vrm10ControlBone.cs => Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10ControlBone.cs
mv Assets/VRM10/Runtime/ControlRig/InitialRotations/ControlRigGenerationOption.cs => Assets/VRM10/Runtime/Components/Vrm10Runtime/ControlRigGenerationOption.cs
rename Vrm10BoneInitialRotation => BoneInitialRotation
remove Vrm0XCompatibleRig.cs
2023-02-20 15:49:50 +09:00

42 lines
1.2 KiB
C#

using UnityEngine;
namespace UniVRM10
{
/// <summary>
/// 正規化済みのヒエラルキーの getter。
/// localRotation をコピーするだけなのだが、
/// GetNormalizedLocalRotation にて、ボーンの有無(upperChestなど)の違いの対応をする予定(未実装)。
/// </summary>
public class NormalizedRigGetter : IControlRigGetter
{
Transform m_root;
Animator m_animator;
public NormalizedRigGetter(Transform root, Animator animator)
{
m_root = root;
m_animator = animator;
}
public Quaternion GetNormalizedLocalRotation(HumanBodyBones bone, HumanBodyBones parentBone)
{
if (m_animator.GetBoneTransform(bone) is Transform t)
{
// TODO: parentBone relative
return t.localRotation;
}
else
{
// Debug.LogWarning($"{bone} not found");
return Quaternion.identity;
}
}
public Vector3 GetRootPosition()
{
// TODO: from model root ?
return m_animator.GetBoneTransform(HumanBodyBones.Hips).localPosition;
}
}
}