DragPointMeido.cs 1.9 KB

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