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); }
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); }