void Update() { if (Status == GestureStatus.NotStarted || Status == GestureStatus.Error) { return; } UpdatedInThisFrame = false; IntPtr ptr; int index; var size = GestureInterface.GetGestureResult(out ptr, out index); if (index < 0) { #if VIVEHANDTRACKING_WITH_WAVEVR WaveVR_Log.Log.e("Aristo", "Gesture detection stopped"); #else Debug.LogError("Gesture detection stopped"); #endif Status = GestureStatus.Error; Error = GestureFailure.Internal; return; } else if (Status == GestureStatus.Starting && index > 0) { Status = GestureStatus.Running; } if (index <= lastIndex) { return; } lastIndex = index; UpdatedInThisFrame = true; LeftHand = RightHand = null; if (size <= 0) { return; } var structSize = Marshal.SizeOf(typeof(GestureResultRaw)); for (var i = 0; i < size; i++) { var gesture = (GestureResultRaw)Marshal.PtrToStructure(ptr, typeof(GestureResultRaw)); ptr = new IntPtr(ptr.ToInt64() + structSize); for (int j = 0; j < 21; j++) { gesture.points[j] = transform.TransformPoint(gesture.points[j]); } if (gesture.isLeft) { LeftHand = new GestureResult(gesture); } else { RightHand = new GestureResult(gesture); } } }
public override void UpdateResult() { var transform = GestureProvider.Current.transform; GestureInterface.SetCameraTransform(transform.position, transform.rotation); IntPtr ptr; int index; var size = GestureInterface.GetGestureResult(out ptr, out index); if (index < 0) { Debug.LogError("Gesture detection stopped"); State.Status = GestureStatus.Error; State.Error = GestureFailure.Internal; return; } if (index <= lastIndex) { return; } lastIndex = index; State.UpdatedInThisFrame = true; State.LeftHand = State.RightHand = null; if (size <= 0) { return; } var structSize = Marshal.SizeOf(typeof(GestureResultRaw)); for (var i = 0; i < size; i++) { var gesture = (GestureResultRaw)Marshal.PtrToStructure(ptr, typeof(GestureResultRaw)); ptr = new IntPtr(ptr.ToInt64() + structSize); if (gesture.isLeft) { State.LeftHand = new GestureResult(gesture); } else { State.RightHand = new GestureResult(gesture); } } }