DragPointChain.cs 1.0 KB

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