예제 #1
0
        public override void StartController(InstantVR ivr)
        {
            extension = ivr.GetComponent <IVR_Traditional>();
            base.StartController(ivr);
            tracking = true;

            handAnimator = GetComponent <IVR_AnimatorHand>();
#if INSTANTVR_ADVANCED
            handMovements = GetComponent <IVR_HandMovementsBase>();
#endif
        }
예제 #2
0
        public void Initialize(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements)
        {
            this.ivr = ivr;

            this.bodySide = bodySide;
            animator      = ivr.GetComponentInChildren <Animator>();

            if (bodySide == BodySide.Left)
            {
                upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
                forearm  = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
                hand     = animator.GetBoneTransform(HumanBodyBones.LeftHand);

#if INSTANTVR_ADVANCED
                handMovements = ivr.leftHandMovements;
#endif
            }
            else
            {
                upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
                forearm  = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
                hand     = animator.GetBoneTransform(HumanBodyBones.RightHand);

#if INSTANTVR_ADVANCED
                handMovements = ivr.rightHandMovements;
#endif
            }

            if (upperArm != null)
            {
                upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
                forearmLength  = Vector3.Distance(forearm.position, hand.position);
                length         = upperArmLength + forearmLength;
                if (length == 0)
                {
                    Debug.LogError("Avatar arm positions are incorrect. Please restore avatar in T-pose.");
                }

                upperArmLength2 = upperArmLength * upperArmLength;
                forearmLength2  = forearmLength * forearmLength;

                upperArmStartPosition = upperArm.position;
            }
        }
예제 #3
0
        protected virtual void Awake()
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            extensions = this.GetComponents <IVR_Extension>();
            foreach (IVR_Extension extension in extensions)
            {
                extension.StartExtension(this);
            }

            headControllers      = headTarget.GetComponents <IVR_Controller>();
            leftHandControllers  = leftHandTarget.GetComponents <IVR_Controller>();
            rightHandControllers = rightHandTarget.GetComponents <IVR_Controller>();
            hipControllers       = hipTarget.GetComponents <IVR_Controller>();
            leftFootControllers  = leftFootTarget.GetComponents <IVR_Controller>();
            rightFootControllers = rightFootTarget.GetComponents <IVR_Controller>();

            headController      = FindActiveController(headControllers);
            leftHandController  = FindActiveController(leftHandControllers);
            rightHandController = FindActiveController(rightHandControllers);
            hipController       = FindActiveController(hipControllers);
            leftFootController  = FindActiveController(leftFootControllers);
            rightFootController = FindActiveController(rightFootControllers);

            headMovements = headTarget.GetComponent <IVR_Movements>();

            leftHandMovements = leftHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (leftHandMovements != null)
            {
                leftHandMovements.selectedController = (IVR_HandController)FindActiveController(leftHandControllers);
            }

            rightHandMovements = rightHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (rightHandMovements != null)
            {
                rightHandMovements.selectedController = (IVR_HandController)FindActiveController(rightHandControllers);
            }


            Animator[] animators = GetComponentsInChildren <Animator>();
            for (int i = 0; i < animators.Length; i++)
            {
                Avatar avatar = animators[i].avatar;
                if (avatar.isValid && avatar.isHuman)
                {
                    characterTransform = animators[i].transform;

                    AddRigidbody(characterTransform.gameObject);
                    bodyCapsule = AddHipCollider(hipTarget.gameObject, proximitySpeed);
                }
            }

            foreach (IVR_Controller c in headControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in hipControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftFootControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightFootControllers)
            {
                c.StartController(this);
            }

            IVR_BodyMovements bm = GetComponent <IVR_BodyMovements>();

            if (bm != null)
            {
                bm.StartMovements();
            }

            if (headMovements && headMovements.enabled)
            {
                headMovements.StartMovements(this);
            }
            if (leftHandMovements != null && leftHandMovements.enabled)
            {
                leftHandMovements.StartMovements(this);
            }
            if (rightHandMovements != null && rightHandMovements.enabled)
            {
                rightHandMovements.StartMovements(this);
            }
        }
예제 #4
0
        protected virtual void Awake()
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            extensions = this.GetComponents <IVR_Extension>();
            foreach (IVR_Extension extension in extensions)
            {
                extension.StartExtension(this);
            }

            headControllers      = headTarget.GetComponents <IVR_Controller>();
            leftHandControllers  = leftHandTarget.GetComponents <IVR_Controller>();
            rightHandControllers = rightHandTarget.GetComponents <IVR_Controller>();
            hipControllers       = hipTarget.GetComponents <IVR_Controller>();
            leftFootControllers  = leftFootTarget.GetComponents <IVR_Controller>();
            rightFootControllers = rightFootTarget.GetComponents <IVR_Controller>();

            headController      = FindActiveController(headControllers);
            leftHandController  = FindActiveController(leftHandControllers);
            rightHandController = FindActiveController(rightHandControllers);
            hipController       = FindActiveController(hipControllers);
            leftFootController  = FindActiveController(leftFootControllers);
            rightFootController = FindActiveController(rightFootControllers);

            headMovements = headTarget.GetComponent <IVR_Movements>();

            leftHandMovements = leftHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (leftHandMovements != null)
            {
                leftHandMovements.selectedController = (IVR_HandController)FindActiveController(leftHandControllers);
            }

            rightHandMovements = rightHandTarget.GetComponent <IVR_HandMovementsBase>();
            if (rightHandMovements != null)
            {
                rightHandMovements.selectedController = (IVR_HandController)FindActiveController(rightHandControllers);
            }

            DetermineAvatar();

            foreach (IVR_Controller c in headControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightHandControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in hipControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in leftFootControllers)
            {
                c.StartController(this);
            }
            foreach (IVR_Controller c in rightFootControllers)
            {
                c.StartController(this);
            }

            bodyMovements = GetComponent <IVR_BodyMovements>();
            if (bodyMovements != null)
            {
                bodyMovements.StartMovements();
            }

            if (headMovements && headMovements.enabled)
            {
                headMovements.StartMovements(this);
            }
            if (leftHandMovements != null && leftHandMovements.enabled)
            {
                leftHandMovements.StartMovements(this);
            }
            if (rightHandMovements != null && rightHandMovements.enabled)
            {
                rightHandMovements.StartMovements(this);
            }

            InitGroundcheck();
        }