Esempio n. 1
0
        private void Start()
        {
            m_grabber = GetComponent <OVRGrabber>();
            grabPose  = this.gameObject.GetComponent <HandPose>();

            // Collision starts disabled. We'll enable it for certain cases such as making a fist.
            m_colliders = this.GetComponentsInChildren <Collider>().Where(childCollider => !childCollider.isTrigger).ToArray();

            // Get animator layer indices by name, for later use switching between hand visuals
            m_animLayerIndexPoint = m_animator.GetLayerIndex(ANIM_LAYER_NAME_POINT);
            m_animLayerIndexThumb = m_animator.GetLayerIndex(ANIM_LAYER_NAME_THUMB);
            m_animParamIndexFlex  = Animator.StringToHash(ANIM_PARAM_NAME_FLEX);

#if UNITY_EDITOR
            OVRPlugin.SendEvent("custom_hand", (SceneManager.GetActiveScene().name == "CustomHands").ToString(), "sample_framework");
#endif
        }
Esempio n. 2
0
        private void UpdateAnimStates()
        {
            bool     grabbing = m_grabber.grabbedObject != null;
            HandPose grabPose = m_defaultGrabPose;

            if (grabbing)
            {
                HandPose customPose = m_grabber.grabbedObject.GetComponent <HandPose>();
                if (customPose != null)
                {
                    grabPose = customPose;
                }
            }
            // Pose
            HandPoseId handPoseId = grabPose.PoseId;

            m_animator.SetInteger(m_animParamIndexPose, (int)handPoseId);

            // Flex
            // blend between open hand and fully closed fist
            float flex = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller);

            m_animator.SetFloat(m_animParamIndexFlex, flex);

            // Point
            bool  canPoint = !grabbing || grabPose.AllowPointing;
            float point    = canPoint ? m_pointBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexPoint, point);

            if (canPoint)
            {
                CollisionEnable(true);
            }

            // Thumbs up
            bool  canThumbsUp = !grabbing || grabPose.AllowThumbsUp;
            float thumbsUp    = canThumbsUp ? m_thumbsUpBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexThumb, thumbsUp);

            float pinch = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, m_controller);

            m_animator.SetFloat("Pinch", pinch);
        }
Esempio n. 3
0
        private void UpdateAnimStates()
        {
            bool     grabbing = false;
            HandPose grabPose = m_defaultGrabPose;
            //if (grabbing)
            //{
            //    HandPose customPose = m_grabber.grabbedObject.GetComponent<HandPose>();
            //    if (customPose != null) grabPose = customPose;
            //}
            // Pose
            HandPoseId handPoseId = grabPose.PoseId;

            m_animator.SetInteger(m_animParamIndexPose, (int)handPoseId);

            // Flex
            // blend between open hand and fully closed fist
            InputManagerVR.AxisCode aFlex = _isLeft ? InputManagerVR.AxisCode.LeftGrip : InputManagerVR.AxisCode.RightGrip;
            float flex = InputManagerVR.GetAxis(aFlex);

            //float flex = InputManager.GetAxis("flex");
            m_animator.SetFloat(m_animParamIndexFlex, flex);

            // Point
            bool  canPoint = !grabbing || grabPose.AllowPointing;
            float point    = canPoint ? m_pointBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexPoint, point);

            // Thumbs up
            bool  canThumbsUp = !grabbing || grabPose.AllowThumbsUp;
            float thumbsUp    = canThumbsUp ? m_thumbsUpBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexThumb, thumbsUp);

            InputManagerVR.AxisCode aPinch = _isLeft ? InputManagerVR.AxisCode.LeftTrigger : InputManagerVR.AxisCode.RightTrigger;
            float pinch = InputManagerVR.GetAxis(aPinch);

            //float pinch = InputManager.GetAxis("pinch");
            m_animator.SetFloat("Pinch", pinch);
        }
Esempio n. 4
0
        private void UpdateAnimStates()
        {
            bool     grabbing = m_grabber.grabbedObject != null;
            HandPose grabPose = m_defaultGrabPose;

            if (grabbing)
            {
                HandPose customPose = m_grabber.grabbedObject.GetComponent <HandPose>();
                if (customPose != null)
                {
                    grabPose = customPose;
                }
            }
            // Pose
            HandPoseId handPoseId = grabPose.PoseId;

            m_animator.SetInteger(m_animParamIndexPose, (int)handPoseId);

            // Flex
            // blend between open hand and fully closed fist
            float flex = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller);

            m_animator.SetFloat(m_animParamIndexFlex, flex);

            // Point
            bool  canPoint = !grabbing || grabPose.AllowPointing;
            float point    = canPoint ? m_pointBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexPoint, point);

            // Thumbs up
            bool  canThumbsUp = !grabbing || grabPose.AllowThumbsUp;
            float thumbsUp    = canThumbsUp ? m_thumbsUpBlend : 0.0f;

            m_animator.SetLayerWeight(m_animLayerIndexThumb, thumbsUp);

            float pinch = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, m_controller);

            m_animator.SetFloat("Pinch", pinch);


            //******
            if ((transform.position - testTube.transform.position).sqrMagnitude < .05)
            {
                tubeIsGrabbed = true;
            }
            else
            {
                tubeIsGrabbed = false;
            }
            if ((transform.position - slide.transform.position).sqrMagnitude < .05)
            {
                slideIsGrabbed = true;
            }
            else
            {
                slideIsGrabbed = false;
            }

            // Grab Slide
            if (slideIsGrabbed == true)
            {
                m_animator.SetBool("grabSlide", true);
            }
            else
            {
                m_animator.SetBool("grabSlide", false);
            }
            // Grab Tube
            if (tubeIsGrabbed == true)
            {
                m_animator.SetBool("grabTube", true);
            }
            else
            {
                m_animator.SetBool("grabTube", false);
            }
            //******
        }