DragPointPelvis.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class DragPointPelvis : DragPointMeido
  5. {
  6. private Quaternion pelvisRotation;
  7. protected override void ApplyDragType()
  8. {
  9. if (CurrentDragType == DragType.Ignore) ApplyProperties();
  10. else if (IsBone) ApplyProperties(false, false, false);
  11. else ApplyProperties(CurrentDragType != DragType.None, false, false);
  12. }
  13. protected override void UpdateDragType()
  14. {
  15. if (Input.GetKey(KeyCode.Space) || OtherDragType())
  16. {
  17. CurrentDragType = DragType.Ignore;
  18. }
  19. else if (Utility.GetModKey(Utility.ModKey.Alt) && !Utility.GetModKey(Utility.ModKey.Control))
  20. {
  21. bool shift = Utility.GetModKey(Utility.ModKey.Shift);
  22. CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
  23. }
  24. else
  25. {
  26. CurrentDragType = DragType.None;
  27. }
  28. }
  29. protected override void OnMouseDown()
  30. {
  31. base.OnMouseDown();
  32. pelvisRotation = MyObject.rotation;
  33. }
  34. protected override void Drag()
  35. {
  36. if (CurrentDragType == DragType.None) return;
  37. if (isPlaying) meido.Stop = true;
  38. Vector3 mouseDelta = MouseDelta();
  39. if (CurrentDragType == DragType.RotLocalXZ)
  40. {
  41. MyObject.rotation = pelvisRotation;
  42. MyObject.Rotate(camera.transform.forward, mouseDelta.x / 6f, Space.World);
  43. MyObject.Rotate(camera.transform.right, mouseDelta.y / 4f, Space.World);
  44. }
  45. if (CurrentDragType == DragType.RotLocalY)
  46. {
  47. MyObject.rotation = pelvisRotation;
  48. MyObject.Rotate(Vector3.right * (mouseDelta.x / 2.2f));
  49. }
  50. }
  51. }
  52. }