KinectV2Driver.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace ToneTuneToolkit.KinectV2
  5. {
  6. public class KinectV2Driver : MonoBehaviour, KinectGestures.GestureListenerInterface
  7. {
  8. public static KinectV2Driver Instance;
  9. // ==================================================
  10. private void Awake()
  11. {
  12. Instance = this;
  13. }
  14. // ==================================================
  15. public void UserDetected(long userID, int userIndex)
  16. {
  17. KinectManager kinectManager = KinectManager.Instance;
  18. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.RaiseRightHand);
  19. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.RaiseLeftHand);
  20. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Psi);
  21. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Stop);
  22. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Wave);
  23. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.RaiseRightHand);
  24. kinectManager.DetectGesture(userID, KinectGestures.Gestures.SwipeUp);
  25. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.SwipeDown);
  26. kinectManager.DetectGesture(userID, KinectGestures.Gestures.SwipeLeft);
  27. kinectManager.DetectGesture(userID, KinectGestures.Gestures.SwipeRight);
  28. // gestures 枚举里 Click默认为 注释
  29. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Click);
  30. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.ZoomOut);
  31. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.ZoomIn);
  32. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Wheel);
  33. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Jump);
  34. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Squat);
  35. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Push);
  36. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Pull);
  37. // kinectManager.DetectGesture(userID, KinectGestures.Gestures.Tpose);
  38. Debug.Log("[Kinect] User " + userID + " Detected...");
  39. return;
  40. }
  41. public void UserLost(long userID, int userIndex)
  42. {
  43. Debug.Log("[Kinect] User " + userID + " lost.");
  44. return;
  45. }
  46. public void GestureInProgress(long userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectInterop.JointType joint, Vector3 screenPos)
  47. {
  48. return;
  49. }
  50. public bool GestureCompleted(long userId, int userIndex, KinectGestures.Gestures gesture, KinectInterop.JointType joint, Vector3 screenPos)
  51. {
  52. // if (userId == 0) // 检测第一个用户
  53. switch (gesture)
  54. {
  55. default: break;
  56. case KinectGestures.Gestures.None:
  57. break;
  58. case KinectGestures.Gestures.SwipeUp:
  59. break;
  60. case KinectGestures.Gestures.SwipeLeft:
  61. break;
  62. case KinectGestures.Gestures.SwipeRight:
  63. break;
  64. }
  65. return true;
  66. }
  67. public bool GestureCancelled(long userId, int userIndex, KinectGestures.Gestures gesture, KinectInterop.JointType joint)
  68. {
  69. return true;
  70. }
  71. }
  72. }