Пример #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------
        // Monobeviour

        // Use this for initialization
        void Start()
        {
            GenerateFingers();
            ResizeFingers();
            SG_HandPose startPose = SG_HandPose.Idle(this.IsRight);

            this.UpdateHand(startPose);
        }
Пример #2
0
        // Update is called once per frame
        void Update()
        {
            //Keybinds
            if (Input.GetKeyDown(this.toggleGloveKey))
            {
                this.GloveVisible = !GloveVisible;
            }
            if (Input.GetKeyDown(this.toggleHandKey))
            {
                this.HandVisible = !HandVisible;
            }

            //Automated Updates
            if (this.glove != null && glove.IsConnected)
            {
                if (!setupComplete)
                {
                    setupComplete     = true;
                    this.HandGeometry = SGCore.Kinematics.BasicHandModel.Default(this.glove.IsRight);
                    //Debug.Log("WireFrame; " + this.HandGeometry.ToString());

                    this.CalibrateWrist();

                    SG_HandPose idleHand = SG_HandPose.Idle(glove.IsRight);
                    this.UpdateHand(idleHand);

                    if (this.glove.InternalGlove is SGCore.SG.SenseGlove)
                    {
                        //  Debug.Log("Generated glove model for " + this.glove.GetInternalObject().GetDeviceID());
                        SGCore.SG.SG_GloveInfo gloveModel = ((SGCore.SG.SenseGlove) this.glove.InternalGlove).GetGloveModel();
                        GenerateGlove(gloveModel);
                        SGCore.SG.SG_GlovePose idlePose = SGCore.SG.SG_GlovePose.IdlePose(gloveModel);
                        this.UpdateGlove(idlePose);
                    }
                }
                if (this.wristTransform != null && this.foreArmTransform != null)
                {
                    if (Input.GetKeyDown(this.resetWristKey))
                    {
                        this.CalibrateWrist();
                    }
                    Quaternion imu;
                    if (this.glove.GetIMURotation(out imu))
                    {
                        this.UpdateWrist(imu);
                    }
                }
                if (this.gloveBase.activeInHierarchy)
                {
                    this.UpdateGlove();
                }
                if (this.handBase.activeInHierarchy)
                {
                    this.UpdateHand();
                }
            }
        }
Пример #3
0
        // Update is called once per frame
        void Update()
        {
            if (activeHand == null)
            {
                if (leftHand.gloveHardware.IsConnected || rightHand.gloveHardware.IsConnected)
                {
                    activeHand = rightHand.gloveHardware.IsConnected ? rightHand : leftHand;

                    activeHand.handModel.gameObject.SetActive(true);
                    activeHand.handAnimation.updateWrist = true;
                    activeHand.handAnimation.CalibrateWrist();
                    activeHand.handAnimation.UpdateWrist(activeHand.GetIMURotation());

                    activeHand.handAnimation.UpdateHand(SG_HandPose.Idle(activeHand.TracksRightHand));
                    activeHand.feedbackScript.DebugEnabled       = true;
                    activeHand.grabScript.DebugEnabled           = true;
                    activeHand.rigidBodyLayer.DebugEnabled       = true;
                    activeHand.physicsTrackingLayer.DebugEnabled = true;
                    calibrateWristBtn.gameObject.SetActive(true);
                    if (this.showing != ShowingLayer.PhysicsLayer)
                    {
                        activeHand.physicsTrackingLayer.gameObject.SetActive(false);
                    }
                    gestureUI.gestureLayer = activeHand.gestureLayer;
                    if (gestureUI.gestureLayer != null)
                    {
                        gestureUI.gestureToCheck = activeHand.gestureLayer.gestures.Length > 0 ? activeHand.gestureLayer.gestures[0] : null;
                    }
                }
            }
            else
            {
                if (Input.GetKeyDown(nextKey))
                {
                    NextStep();
                }
                else if (Input.GetKeyDown(prevKey))
                {
                    PreviousStep();
                }
                if (Input.GetKeyDown(wristKey))
                {
                    CalibrateWrist();
                }
            }
        }