DragPointPelvis.cs 1.9 KB

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