68 lines
1.4 KiB
C#
68 lines
1.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace FIMSpace.FTools
|
|
{
|
|
[Serializable]
|
|
public abstract class FIK_ProcessorBase
|
|
{
|
|
[Range(0f, 1f)]
|
|
public float IKWeight = 1f;
|
|
|
|
public Vector3 IKTargetPosition;
|
|
|
|
public Quaternion IKTargetRotation;
|
|
|
|
public Vector3 LastLocalDirection;
|
|
|
|
public Vector3 LocalDirection;
|
|
|
|
[NonSerialized]
|
|
public bool CallPreCalibrate = true;
|
|
|
|
public float fullLength { get; protected set; }
|
|
|
|
public bool Initialized { get; protected set; }
|
|
|
|
public FIK_IKBoneBase[] Bones { get; protected set; }
|
|
|
|
public FIK_IKBoneBase StartBone => Bones[0];
|
|
|
|
public FIK_IKBoneBase EndBone => Bones[Bones.Length - 1];
|
|
|
|
public Quaternion StartBoneRotationOffset { get; set; } = Quaternion.identity;
|
|
|
|
public virtual void Init(Transform root)
|
|
{
|
|
StartBoneRotationOffset = Quaternion.identity;
|
|
}
|
|
|
|
public virtual void PreCalibrate()
|
|
{
|
|
if (CallPreCalibrate)
|
|
{
|
|
for (FIK_IKBoneBase fIK_IKBoneBase = Bones[0]; fIK_IKBoneBase != null; fIK_IKBoneBase = fIK_IKBoneBase.Child)
|
|
{
|
|
fIK_IKBoneBase.transform.localRotation = fIK_IKBoneBase.InitialLocalRotation;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void Update()
|
|
{
|
|
}
|
|
|
|
public static float EaseInOutQuint(float start, float end, float value)
|
|
{
|
|
value /= 0.5f;
|
|
end -= start;
|
|
if (value < 1f)
|
|
{
|
|
return end * 0.5f * value * value * value * value * value + start;
|
|
}
|
|
value -= 2f;
|
|
return end * 0.5f * (value * value * value * value * value + 2f) + start;
|
|
}
|
|
}
|
|
}
|