示例#1
0
        public override void StartMovements(InstantVR ivr)
        {
            base.StartMovements(ivr);

            Camera headCamera = ivr.GetComponentInChildren <Camera>();

            headcam = headCamera.transform;

            if (interaction != InteractionType.None)
            {
                inputModule = ivr.GetComponent <IVR_Interaction>();
                if (inputModule == null)
                {
                    EventSystem eventSystem = FindObjectOfType <EventSystem>();
                    if (eventSystem != null)
                    {
                        DestroyImmediate(eventSystem.gameObject);
                    }
                    inputModule = ivr.gameObject.AddComponent <IVR_Interaction>();
                }

                inputModule.EnableGazeInputModule(headcam, controllerSide, activationButton, autoActivation);
            }

            if (interaction != InteractionType.None && focusPointObj == null)
            {
                focusPointObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                focusPointObj.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
                Destroy(focusPointObj.GetComponent <Collider>());
            }
        }
示例#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;
            }
        }