DragPointChain.cs 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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
  8. #if COM25
  9. AIKCtrl
  10. #else
  11. IKCtrlData
  12. #endif
  13. ikCtrlData;
  14. protected Transform[] ikChain;
  15. public override void Set(Transform myObject)
  16. {
  17. base.Set(myObject);
  18. ikChain = new Transform[]
  19. {
  20. myObject.parent,
  21. myObject.parent,
  22. myObject,
  23. };
  24. ikCtrlData = IkCtrlData;
  25. }
  26. protected override void OnMouseDown()
  27. {
  28. base.OnMouseDown();
  29. InitializeRotation();
  30. InitializeIK(IK, ikChain[JointUpper], ikChain[JointMiddle], ikChain[JointLower]);
  31. }
  32. protected void InitializeRotation()
  33. {
  34. for (var i = 0; i < jointRotation.Length; i++)
  35. jointRotation[i] = ikChain[i].localRotation;
  36. }
  37. }