示例#1
0
        //----------------------------------------------------------------------------------------------
        // Construction

        /// <summary> Create a new SG_HandPose from an internal SenseGlove Pose. </summary>
        /// <param name="handPose"></param>
        public SG_HandPose(SGCore.HandPose handPose)
        {
            jointAngles       = Util.SG_Conversions.ToUnityEulers(handPose.handAngles);
            jointRotations    = Util.SG_Conversions.ToUnityQuaternions(handPose.jointRotations);
            jointPositions    = Util.SG_Conversions.ToUnityPositions(handPose.jointPositions, true);
            normalizedFlexion = handPose.GetNormalizedFlexion();
        }
示例#2
0
        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);
        }