Ejemplo n.º 1
0
        public void ShowLayer(ShowingLayer layer)
        {
            if (this.showing != layer)
            {
                this.showing = layer;
                if (activeHand != null)
                {
                    SG.Util.SG_Util.SetChildren(activeHand.transform, false); //all layers are off
                    SetAllObjects(false);
                    if (layer >= ShowingLayer.None)
                    {
                        activeHand.handModel.gameObject.SetActive(true);
                    }
                    if (layer >= ShowingLayer.AnimationLayer)
                    {
                        activeHand.handAnimation.gameObject.SetActive(true);
                    }
                    activeHand.handModel.DebugEnabled = layer <ShowingLayer.FeedbackLayer && layer> ShowingLayer.None;

                    bool updateWrist = layer >= ShowingLayer.AnimationLayer;

                    if (updateWrist && !activeHand.handAnimation.updateWrist)
                    {
                        activeHand.handAnimation.updateWrist = true;
                        activeHand.handAnimation.CalibrateWrist();
                        activeHand.handAnimation.UpdateWrist(activeHand.GetIMURotation());
                    }
                    if (!updateWrist)
                    {
                        activeHand.handAnimation.CalibrateWrist();
                        activeHand.handAnimation.UpdateWrist(activeHand.GetIMURotation());
                    }
                    activeHand.handAnimation.updateWrist = updateWrist;

                    if (layer == ShowingLayer.FeedbackLayer || layer == ShowingLayer.All)
                    {
                        activeHand.feedbackScript.gameObject.SetActive(true);
                    }
                    if (layer == ShowingLayer.GrabLayer || layer == ShowingLayer.All)
                    {
                        activeHand.grabScript.gameObject.SetActive(true);
                    }
                    if (layer == ShowingLayer.RigidbodyLayer || layer == ShowingLayer.All)
                    {
                        activeHand.rigidBodyLayer.gameObject.SetActive(true);
                    }
                    if (layer == ShowingLayer.PhysicsLayer)
                    {
                        activeHand.physicsTrackingLayer.gameObject.SetActive(true);
                    }
                    if (layer == ShowingLayer.GestureLayer)
                    {
                        activeHand.gestureLayer.gameObject.SetActive(true);
                    }
                }
                SetLayerObjects((int)layer, true);
                UpdateOverview(layer);
            }
        }
Ejemplo n.º 2
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();
                }
            }
        }