BT3DofDevicePartManipulation.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using SC.XR.Unity.Module_InputSystem;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. public class BT3DofDevicePartManipulation : AbstractDevicePartManipulation
  8. {
  9. private SCPointEventData eventData;
  10. private SCPose pointerPose;
  11. public override void OneDevicePartInit(Dictionary<InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
  12. {
  13. base.OneDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
  14. this.eventData = this.eventDataDic.Values.ToArray()[0];
  15. pointerPose = new SCPose(Vector3.zero, Quaternion.identity);
  16. Vector3 grabPosition = Vector3.zero;
  17. pointerPose.position = this.eventData.Position3D;
  18. pointerPose.rotation = Quaternion.identity;
  19. grabPosition = this.eventData.Position3D;
  20. //Head only need to setup movelogic
  21. moveLogic.Setup(pointerPose, grabPosition, targetTransform, targetTransform.localScale);
  22. }
  23. public override Tuple<Vector3, Quaternion, Vector3> OneDevicePartUpdate()
  24. {
  25. pointerPose.position = this.eventData.Position3D;
  26. pointerPose.rotation = Quaternion.identity;
  27. Vector3 position = moveLogic.Update(pointerPose, targetTransform.rotation, targetTransform.localScale, true);
  28. //TODO
  29. return new Tuple<Vector3, Quaternion, Vector3>(position, targetTransform.rotation, targetTransform.localScale);
  30. }
  31. public override void TwoDevicePartInit(Dictionary<InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
  32. {
  33. base.TwoDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
  34. //TODO
  35. }
  36. public override Tuple<Vector3, Quaternion, Vector3> TwoDevicePartUpdate(Func<Vector3, Vector3> scaleConstraint)
  37. {
  38. //TODO
  39. return new Tuple<Vector3, Quaternion, Vector3>(Vector3.zero, Quaternion.identity, Vector3.one);
  40. }
  41. }