DragPointChain.cs 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. namespace MeidoPhotoStudio.Plugin;
  3. public abstract class DragPointChain : DragPointMeido
  4. {
  5. protected readonly TBody.IKCMO IK = new();
  6. protected readonly Quaternion[] jointRotation = new Quaternion[3];
  7. protected IKCtrlData ikCtrlData;
  8. protected Transform[] ikChain;
  9. public override void Set(Transform myObject)
  10. {
  11. base.Set(myObject);
  12. ikChain = new Transform[]
  13. {
  14. myObject.parent,
  15. myObject.parent,
  16. myObject,
  17. };
  18. ikCtrlData = IkCtrlData;
  19. }
  20. protected override void OnMouseDown()
  21. {
  22. base.OnMouseDown();
  23. InitializeRotation();
  24. InitializeIK(IK, ikChain[JointUpper], ikChain[JointMiddle], ikChain[JointLower]);
  25. }
  26. protected void InitializeRotation()
  27. {
  28. for (var i = 0; i < jointRotation.Length; i++)
  29. jointRotation[i] = ikChain[i].localRotation;
  30. }
  31. }