public static void UpdateHand(SG_HandAnimator animater, bool calibrating, SG_HandPose pose) { if (animater != null && calibrating) { animater.UpdateHand(pose); } }
protected virtual void Start() { //sets the animation in a starting pose. SG_HandPose startPose = SG_HandPose.Idle(this.handModelInfo != null ? this.handModelInfo.handSide != HandSide.LeftHand : true); this.UpdateHand(startPose); }
//----------------------------------------------------------------------------------------------------------------------------------------- // Update Methods #region Update /// <summary> /// Update the (absolute) finger orientations, which move realtive to the (absolute) wrist transform. /// Note: This method is called after UpdateWrist() is called. /// </summary> /// <param name="data"></param> public virtual void UpdateHand(SG_HandPose pose) { if (pose != null) { Quaternion[][] angles = pose.jointRotations; Quaternion[][] corrections = handModelInfo.FingerCorrections; Transform[][] fingerJoints = handModelInfo.FingerJoints; if (corrections != null && fingerJoints != null) { for (int f = 0; f < fingerJoints.Length; f++) { if (pose.jointRotations.Length > f) { for (int j = 0; j < fingerJoints[f].Length; j++) { if (pose.jointRotations[f].Length > j) { fingerJoints[f][j].rotation = handModelInfo.wristTransform.rotation * (angles[f][j] * corrections[f][j]); } } } } } } }
public static void SetAnimation(SG_TrackedHand hand, bool enabled) { if (hand != null && hand.handAnimation != null) { hand.handAnimation.gameObject.SetActive(enabled); if (!enabled) { hand.handAnimation.UpdateHand(SG_HandPose.Idle(hand.TracksRightHand)); } } }
//---------------------------------------------------------------------------------------------- // Hand Tracking Methods /// <summary> Returns the HandPose from the Glove Hardware linked to this TrackedHand. </summary> /// <param name="hand"></param> /// <param name="pose"></param> /// <returns></returns> public virtual bool GetHandPose(out SG_HandPose pose) { if (this.gloveHardware != null && this.handModel != null) { SGCore.Kinematics.BasicHandModel HM = handModel.HandKinematics; //Debug.Log("TrackedHand: " + HM.ToString()); return(this.gloveHardware.GetHandPose(this.handModel.HandKinematics, out pose, true)); } pose = SG_HandPose.Idle(this.TracksRightHand); return(false); }
/// <summary> Returns a Hand Pose containing everything you'd want to animate a hand model in Unity. Using a custom HandProfile. </summary> /// <returns></returns> public bool GetHandPose(SGCore.Kinematics.BasicHandModel handDimensions, SGCore.HandProfile userProfile, out SG_HandPose pose, bool forceUpdate = false) { #if UNFINISHED_FEATURES if (this.CVDataAvailable(forceUpdate)) //we are able to get CV data. Yay { pose = new SG_HandPose(SGCore.HandPose.FromHandAngles(lastCVData.handAngles, lastCVData.rightHand, handDimensions)); newPoseNeeded = false; //we don't need a new pose this frame, thank you. lastHandModel = handDimensions; lastHandPose = pose; return(true); } #endif if (this.lastGlove != null) { if (forceUpdate || newPoseNeeded) //we need a new pose { lastHandModel = handDimensions; if (this.CalibrationStage == CalibrationStage.MoveFingers) { lastHandPose = SG_HandPose.Idle(this.IsRight); newPoseNeeded = false; //we don't need a new pose this frame, thank you. } else if (this.CalibrationLocked && this.currentSequence != null) { //we should gram it from the calibrationSequence instead. if (this.currentSequence.GetCalibrationPose(out lastHandPose)) { newPoseNeeded = false; } } else { SGCore.HandPose iPose; if (lastGlove.GetHandPose(handDimensions, userProfile, out iPose)) { lastHandPose = new SG_HandPose(iPose); newPoseNeeded = false; //we don't need a new pose this frame, thank you. } } } // else we already have one, and don't want to force-update. pose = lastHandPose; return(lastHandPose != null); } else if (lastHandPose == null) { lastHandPose = SG_HandPose.Idle(this.IsRight); } //only if we dont yet have a LastHandPose. //otherwise we shouldn't bother pose = lastHandPose; return(false); }
/// <summary> Retrieve the basic calibration pose. </summary> /// <param name="calibrationPose"></param> /// <returns></returns> public bool GetCalibrationPose(out SG_HandPose calibrationPose) { if (this.internalSequence != null) { SGCore.HandPose pose; if (this.internalSequence.GetHandPose(out pose)) { calibrationPose = new SG.SG_HandPose(pose); return(true); } } calibrationPose = null; return(false); }
/// <summary> Returns a Hand Pose containing everything you'd want to animate a hand model in Unity. Using the global HandProfile. </summary> /// <param name="handModel"></param> /// <param name="pose"></param> /// <param name="forceUpdate"></param> /// <returns></returns> public virtual bool GetHandPose(SGCore.Kinematics.BasicHandModel handModel, out SG_HandPose pose, bool forceUpdate = false) { return(GetHandPose(handModel, SG_HandProfiles.GetProfile(this.IsRight), out pose, forceUpdate)); }