コード例 #1
0
        void AlignArmHUD(HandModel handModel)
        {
            ArmHUDgeom.SetActive(true);

            if (targetHandID != handModel.GetInstanceID())
            {
                // Reinitialize ArmHUD alignment
                //Debug.Log ("Reinitialize ArmHUD alignment Time.time = " + Time.time);
                smoothedPosition.reset = true;
                smoothedRotation.reset = true;
                targetHandID           = handModel.GetInstanceID();
            }
            float sqrCos = handModel.GetArmDirection().y;

            sqrCos *= sqrCos;
            float delay = sqrCos * verticalFilterTime + (1f - sqrCos) * horizontalFilterTime;

            //Debug.Log ("delay(sqrCos = " + sqrCos + ", Time.deltaTime = " + Time.deltaTime + ") = " + delay);
            smoothedPosition.delay = delay;
            smoothedRotation.delay = delay;
            Vector3    localArmCenter   = transform.parent.InverseTransformPoint(handModel.GetArmCenter());
            Quaternion localArmRotation = Quaternion.Inverse(transform.parent.rotation) * handModel.GetArmRotation();

            transform.localPosition = smoothedPosition.Update(localArmCenter, Time.deltaTime);
            transform.localRotation = smoothedRotation.Update(localArmRotation, Time.deltaTime);

            if (ArmHUDisOpen == false)            //Change this to state transition from ARMHUDSTATE_NOLEFTHAND -> ARMHUDSTATE_STATUS_ETC
            {
                if (Activate())
                {
                    ArmHUDAnimator.Play("Take 001_Opening");
                    ArmHUDeventsAnimator.Play("WristGraphicsEvents");
                    ArmHUDisOpen = true;
                }
                else
                {
                    ArmHUDState.Change(ARMHUDSTATE_STATUS_ETC);
                    return;
                }
            }
//			ArmHUDbaseLookAtGRP.LookAt(LookTarget);
            Vector3 localEulerAngles = ArmHUDbaseLookAtGRP.localEulerAngles;

            if (ArmHUDisOpen == true)
            {
                if (localEulerAngles.x < 340.0f && localEulerAngles.x > 280.0f)
                {
                    ArmHUDState.Change(ARMHUDSTATE_STATUS_ETC);
                }
                else if (localEulerAngles.x > 26.0f && localEulerAngles.x < 80.0f && ArmHUDState.state != ARMHUDSTATE_PANELVISIBLE)
                {
                    ArmHUDState.Change(ARMHUDSTATE_SETTINGS_ONLY);
                }
            }
//			localEulerAngles.y = 90f;
//			localEulerAngles.z = 0f;
//			ArmHUDbaseLookAtGRP.localEulerAngles = localEulerAngles;
        }
コード例 #2
0
ファイル: ArmHUDMGR.cs プロジェクト: ryanwang/VR-Planetarium
        void AlignArmHUD(HandModel handModel)
        {
            ArmHUDgeom.SetActive(true);

            if (targetHandID != handModel.GetInstanceID()) {
                // Reinitialize ArmHUD alignment
                //Debug.Log ("Reinitialize ArmHUD alignment Time.time = " + Time.time);
                smoothedPosition.reset = true;
                smoothedRotation.reset = true;
                targetHandID = handModel.GetInstanceID();
            }
            float sqrCos = handModel.GetArmDirection().y;
            sqrCos *= sqrCos;
            float delay = sqrCos * verticalFilterTime + (1f - sqrCos) * horizontalFilterTime;
            //Debug.Log ("delay(sqrCos = " + sqrCos + ", Time.deltaTime = " + Time.deltaTime + ") = " + delay);
            smoothedPosition.delay = delay;
            smoothedRotation.delay = delay;
            Vector3 localArmCenter = transform.parent.InverseTransformPoint (handModel.GetArmCenter ());
            Quaternion localArmRotation = Quaternion.Inverse (transform.parent.rotation) * handModel.GetArmRotation ();
            transform.localPosition = smoothedPosition.Update(localArmCenter, Time.deltaTime);
            transform.localRotation = smoothedRotation.Update(localArmRotation, Time.deltaTime);

            if(ArmHUDisOpen == false){//Change this to state transition from ARMHUDSTATE_NOLEFTHAND -> ARMHUDSTATE_STATUS_ETC
                if(Activate()){
                    ArmHUDAnimator.Play("Take 001_Opening");
                    ArmHUDeventsAnimator.Play("WristGraphicsEvents");
                    ArmHUDisOpen = true;
                }
                else{
                    ArmHUDState.Change (ARMHUDSTATE_STATUS_ETC);
                    return;
                }
            }
            //			ArmHUDbaseLookAtGRP.LookAt(LookTarget);
            Vector3 localEulerAngles = ArmHUDbaseLookAtGRP.localEulerAngles;
            if(ArmHUDisOpen == true){
                if(localEulerAngles.x < 340.0f && localEulerAngles.x > 280.0f){
                    ArmHUDState.Change (ARMHUDSTATE_STATUS_ETC);
                }
                else if(localEulerAngles.x >26.0f && localEulerAngles.x < 80.0f && ArmHUDState.state != ARMHUDSTATE_PANELVISIBLE)
                {
                    ArmHUDState.Change (ARMHUDSTATE_SETTINGS_ONLY);
                }
            }
            //			localEulerAngles.y = 90f;
            //			localEulerAngles.z = 0f;
            //			ArmHUDbaseLookAtGRP.localEulerAngles = localEulerAngles;
        }
コード例 #3
0
ファイル: FingerButton.cs プロジェクト: zikazika/VRKeyboard
    void OnFingertipTriggerEnter(FingertipData fingertipData)
    {
        bool acceptFingertip = false;

        if ((fingertipData.finger == FingerFilter.index) && (RespondToIndex))
        {
            acceptFingertip = true;
        }
        if ((fingertipData.finger == FingerFilter.middle) && (RespondToMiddle))
        {
            acceptFingertip = true;
        }
        if ((fingertipData.finger == FingerFilter.thumb) && (RespondToThumb))
        {
            acceptFingertip = true;
        }

        if (acceptFingertip)
        {
            if (FingertipsInCollisionBounds.Count == 0)
            {
                HandModel = fingertipData.HandModel;
            }
            else
            {
                // check incoming hand model to make sure it matches the existing one.
                int oldHandModelID = HandModel.GetInstanceID();
                int newHandModelID = fingertipData.HandModel.GetInstanceID();
                if (oldHandModelID != newHandModelID)
                {
                    Debug.Log("Tried using two different hands at once to push a button. Ignoring second hand.");
                    return;
                }
                else
                {
                    int          candidateID     = fingertipData.Owner.GetInstanceID();
                    FingerFilter candidateFilter = fingertipData.finger;

                    for (int i = 0; i < FingertipsInCollisionBounds.Count; i++)
                    {
                        FingerFilter knownFilter = FingerTipFilters[i];
                        int          knownID     = FingertipsInCollisionBounds[i].GetInstanceID();

                        if ((knownID == candidateID) || (knownFilter == candidateFilter))
                        {
                            Debug.Log("Fingertip exists already, why wasn't it removed?");
                            return;
                        }
                    }
                }
            }

            FingertipsInCollisionBounds.Add(fingertipData.Owner);
            FingerTipFilters.Add(fingertipData.finger);
            fingerDots.Add(0);

            if (FingertipsInCollisionBounds.Count == 1)
            {
                Hover();
            }
        }
    }