DragPointMeido.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. using static CustomGizmo;
  6. public abstract class DragPointMeido : DragPoint
  7. {
  8. public static readonly Vector3 boneScale = Vector3.one * 0.04f;
  9. protected const int jointUpper = 0;
  10. protected const int jointMiddle = 1;
  11. protected const int jointLower = 2;
  12. protected Meido meido;
  13. protected Maid maid;
  14. protected IKCtrlData IkCtrlData => meido.Body.IKCtrl.GetIKData("左手");
  15. protected bool isPlaying;
  16. protected bool isBone;
  17. public virtual bool IsBone
  18. {
  19. get => isBone;
  20. set
  21. {
  22. if (value != isBone)
  23. {
  24. isBone = value;
  25. ApplyDragType();
  26. }
  27. }
  28. }
  29. public virtual void Initialize(Meido meido, Func<Vector3> position, Func<Vector3> rotation)
  30. {
  31. base.Initialize(position, rotation);
  32. this.meido = meido;
  33. maid = meido.Maid;
  34. isPlaying = !meido.Stop;
  35. }
  36. public override void AddGizmo(float scale = 0.25f, GizmoMode mode = GizmoMode.Local)
  37. {
  38. base.AddGizmo(scale, mode);
  39. Gizmo.GizmoDrag += (s, a) =>
  40. {
  41. meido.Stop = true;
  42. isPlaying = false;
  43. };
  44. }
  45. protected override void OnMouseDown()
  46. {
  47. base.OnMouseDown();
  48. isPlaying = !meido.Stop;
  49. }
  50. protected void InitializeIK(TBody.IKCMO iKCmo, Transform upper, Transform middle, Transform lower)
  51. {
  52. iKCmo.Init(upper, middle, lower, maid.body0);
  53. }
  54. protected void Porc(TBody.IKCMO ikCmo, IKCtrlData ikData, Transform upper, Transform middle, Transform lower)
  55. {
  56. ikCmo.Porc(upper, middle, lower, CursorPosition(), Vector3.zero, ikData);
  57. }
  58. }
  59. }