/* Calling this method updates _currentFrame and _currentImage if and only if this * is the first time the method has been called for this Update cycle. */ protected void ensureCurrentFrameAndImageUpToDate() { if (Time.frameCount == _currentUpdateCount) { return; } _currentUpdateCount = Time.frameCount; var leapMat = UnityMatrixExtension.GetLeapMatrix(transform); _currentFrame = GetLeapController().GetTransformedFrame(leapMat, 0); }
/* Calling this method updates _currentFixedFrame if and only if this is the first time * the method has been called for this FixedUpdate burst. */ protected void ensureCurrentFixedFrameUpToDate() { if (Time.fixedTime == _currentFixedTime) { return; } _currentFixedTime = Time.fixedTime; //Aproximate the correct timestamp given the current fixed time long correctedTimestamp = (long)((Time.fixedTime + _smoothedFixedUpdateOffset.value) * S_TO_NS); //Search the leap history for a frame with a timestamp closest to the corrected timestamp Frame closestFrame = GetLeapController().Frame(); if ((correctedTimestamp < closestFrame.Timestamp)) { _smoothedFixedUpdateOffset.reset = true; } for (int searchHistoryIndex = 1; searchHistoryIndex < 60; searchHistoryIndex++) { Frame historyFrame = GetLeapController().Frame(searchHistoryIndex); //If we reach an invalid frame, terminate the search if (historyFrame.Id < 0) { Debug.LogWarning("historyFrame.Id was less than 0!"); break; } /** If the history frame is closer, replace closestFrame with the historyFrame */ if (Math.Abs(historyFrame.Timestamp - correctedTimestamp) < Math.Abs(closestFrame.Timestamp - correctedTimestamp)) { closestFrame = historyFrame; } else { //Since frames are always reported in order, we can terminate the search once we stop finding a closer frame break; } } var leapMat = UnityMatrixExtension.GetLeapMatrix(transform); _currentFixedFrame = closestFrame.TransformedCopy(leapMat); }
void Update() { if (!EditorApplication.isPlaying && SupportsEditorPersistence()) { Transform editorPoseSpace; LeapServiceProvider leapServiceProvider = FindObjectOfType <LeapServiceProvider>(); LeapTransform poseTransform = LeapTransform.Identity; if (leapServiceProvider != null) { editorPoseSpace = leapServiceProvider.transform; poseTransform = TestHandFactory.GetTestPoseLeftHandTransform(leapServiceProvider.editTimePose); } else { editorPoseSpace = transform; } Hand hand = TestHandFactory.MakeTestHand(Handedness == Chirality.Left, poseTransform).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(editorPoseSpace)); //Hand hand = TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(editorPoseSpace)); if (GetLeapHand() == null) { SetLeapHand(hand); InitHand(); BeginHand(); UpdateHand(); } else { SetLeapHand(hand); UpdateHand(); } } }
public static Leap.Hand MakeTestHand(this LeapProvider provider, bool isLeft) { return(TestHandFactory.MakeTestHand(isLeft, Hands.Provider.editTimePose) .Transform(UnityMatrixExtension.GetLeapMatrix(Hands.Provider.transform))); }
void Update() { if (!EditorApplication.isPlaying) { //Debug.Log("IHandModel.Update()"); SetLeapHand(TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(transform))); UpdateHand(); } }
// Modifique los accesors para poder overridearlo en HapticHand protected virtual void Update() { if (!EditorApplication.isPlaying && SupportsEditorPersistence()) { Transform editorPoseSpace; LeapServiceProvider leapServiceProvider = FindObjectOfType <LeapServiceProvider>(); if (leapServiceProvider) { editorPoseSpace = leapServiceProvider.transform; } else { editorPoseSpace = transform; } Hand hand = TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(editorPoseSpace)); if (GetLeapHand() == null) { SetLeapHand(hand); InitHand(); BeginHand(); UpdateHand(); } else { SetLeapHand(hand); UpdateHand(); } } }
void Update() { if (!EditorApplication.isPlaying && SupportsEditorPersistence()) { Hand hand = TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(transform)); if (GetLeapHand() == null) { SetLeapHand(hand); InitHand(); BeginHand(); UpdateHand(); } else { SetLeapHand(hand); UpdateHand(); } } }
void Awake() { if (!EditorApplication.isPlaying) { SetLeapHand(TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(transform))); InitHand(); } }