public void SetupSequence() { if (user == null) { user = GameObject.FindObjectOfType <SG_User>(); } SGCore.HandPose lh_openPose = SGCore.HandPose.FlatHand(false); SGCore.HandPose lh_closedPose = SGCore.HandPose.Fist(false); lh_interp = SGCore.Kinematics.HandInterpolator.BetweenPoses(lh_openPose, lh_closedPose); SGCore.HandPose rh_openPose = SGCore.HandPose.FlatHand(true); SGCore.HandPose rh_closedPose = SGCore.HandPose.Fist(true); rh_interp = SGCore.Kinematics.HandInterpolator.BetweenPoses(rh_openPose, rh_closedPose); //disable calibration on start. We're going to be the one's to control it. SetCalibrationChecks(user.leftHand, false); SetCalibrationChecks(user.rightHand, false); //They're not allowed to grab objects yet EnableGrasps(user.rightHand, false); EnableGrasps(user.leftHand, false); openClose_freq = 1 / openCloseTime; if (exampleHandLeft != null && user.leftHand != null) { Transform exHand = exampleHandLeft.transform.parent != null ? exampleHandLeft.transform.parent : exampleHandLeft.transform; exHand.parent = user.leftHand.transform; exHand.localRotation = Quaternion.identity; exHand.localPosition = Vector3.zero; } if (exampleHandRight != null && user.rightHand != null) { Transform exHand = exampleHandRight.transform.parent != null ? exampleHandRight.transform.parent : exampleHandRight.transform; exHand.parent = user.rightHand.transform; exHand.localRotation = Quaternion.identity; exHand.localPosition = Vector3.zero; } if (beginImmedeately) { GoToStage(VoidStage.WaitingForFirst); } else { GoToStage(VoidStage.WaitForStart); } //MainInstr = " Before we can begin, we need to calibrate your hand(s)."; //currStage = VoidStage.WaitingForFirst; if (GetCalibrationLayer(user.leftHand, out leftCalibration)) //if true, a calibration algorithm has been assigned, { leftCalibration.calibrationType = SG_CalibrationSequence.CalibrationType.Quick; leftCalibration.startCondition = SG_CalibrationSequence.StartCondition.Manual; } else { Debug.LogError("Missing Calibration Layer for left hand!"); } if (GetCalibrationLayer(user.rightHand, out rightCalibration)) { rightCalibration.calibrationType = SG_CalibrationSequence.CalibrationType.Quick; rightCalibration.startCondition = SG_CalibrationSequence.StartCondition.Manual; } else { Debug.LogError("Missing Calibration Layer for right hand!"); GoToStage(VoidStage.NoCalibrationError); } if (introAudio != null) { introTime = introAudio.clip.length + 0.5f; introAudio.playOnAwake = false; } DisableAwake(moveFingersAudio); DisableAwake(confirmAudio); DisableAwake(completionAudio); }
public static void UpdateOpenClose(bool isRight, SG_HandAnimator animater, bool calibrating, SGCore.Kinematics.HandInterpolator poseInterp, float normalizedTime01) { if (animater != null && calibrating && poseInterp != null) { SGCore.Kinematics.Vect3D[][] handAngles = SGCore.Kinematics.Values.FillZero(5, 3); for (int f = 0; f < 5; f++) { if (f == 0) { handAngles[f][0].x = poseInterp.CalculateAngle(SGCore.Kinematics.ThumbMovement.T_CMC_Twist, normalizedTime01); handAngles[f][0].z = poseInterp.CalculateAngle(SGCore.Kinematics.ThumbMovement.T_CMC_Abd, normalizedTime01); handAngles[f][0].y = poseInterp.CalculateAngle(SGCore.Kinematics.ThumbMovement.T_CMC_Flex, normalizedTime01); handAngles[f][1].y = poseInterp.CalculateAngle(SGCore.Kinematics.ThumbMovement.T_MCP_Flex, normalizedTime01); handAngles[f][2].y = poseInterp.CalculateAngle(SGCore.Kinematics.ThumbMovement.T_IP_Flex, normalizedTime01); } else { SGCore.Finger finger = (SGCore.Finger)f; handAngles[f][0].z = poseInterp.CalculateAngle(finger, SGCore.Kinematics.FingerMovement.F_MCP_Abd, normalizedTime01); handAngles[f][0].y = poseInterp.CalculateAngle(finger, SGCore.Kinematics.FingerMovement.F_MCP_Flex, normalizedTime01); handAngles[f][1].y = poseInterp.CalculateAngle(finger, SGCore.Kinematics.FingerMovement.F_PIP_Flex, normalizedTime01); handAngles[f][2].y = poseInterp.CalculateAngle(finger, SGCore.Kinematics.FingerMovement.F_DIP_Flex, normalizedTime01); } } animater.UpdateHand(new SG_HandPose(SGCore.HandPose.FromHandAngles(handAngles, isRight))); } }