void OnEnable()
    {
        ivrRift = (IVR_Rift) target;
        ivr = ivrRift.GetComponent<InstantVR>();

        if (ivr != null) {
            riftHead = ivr.headTarget.GetComponent<IVR_RiftHead>();
            if (riftHead == null) {
                riftHead = ivr.headTarget.gameObject.AddComponent<IVR_RiftHead>();
                riftHead.extension = ivrRift;
            }

            IVR_Extension[] extensions = ivr.GetComponents<IVR_Extension>();
            if (ivrRift.priority == -1)
                ivrRift.priority = extensions.Length - 1;
            for (int i = 0; i < extensions.Length; i++) {
                if (ivrRift == extensions[i]) {
                    while (i < ivrRift.priority) {
                        MoveUp(riftHead);
                        ivrRift.priority--;
                        //Debug.Log ("Rift Move up to : " + i + " now: " + ivrRift.priority);
                    }
                    while (i > ivrRift.priority) {
                        MoveDown(riftHead);
                        ivrRift.priority++;
                        //Debug.Log ("Rift Move down to : " + i + " now: " + ivrRift.priority);
                    }
                }
            }
        }
    }
    public override void StartController(InstantVR ivr)
    {
        base.StartController(ivr);
        present = true;

        rightInput = ivr.rightHandTarget.GetComponent<IVR_Input>();
    }
    public override void OnPointerClick(PointerEventData eventData)
    {
        base.OnPointerClick(eventData);

#if INSTANTVR_ADVANCED
        if (eventData.currentInputModule.GetType() == typeof(IVR_Interaction))
        {
            InteractionEventData interactionData = (InteractionEventData)eventData;
            InstantVR            ivr             = eventData.currentInputModule.transform.GetComponent <InstantVR>();

            switch (interactionData.inputDevice)
            {
            case InputDeviceIDs.LeftHand:
                if (ivr.leftHandMovements.GetType() == typeof(IVR_HandMovements))
                {
                    IVR_HandMovements handMovements = (IVR_HandMovements)ivr.leftHandMovements;
                    handMovements.Grab(this.gameObject);
                }
                break;

            case InputDeviceIDs.RightHand:
                if (ivr.rightHandMovements.GetType() == typeof(IVR_HandMovements))
                {
                    IVR_HandMovements handMovements = (IVR_HandMovements)ivr.rightHandMovements;
                    handMovements.Grab(this.gameObject);
                }
                break;
            }
        }
#endif
    }
예제 #4
0
    public override void StartController(InstantVR ivr)
    {
        present = true;
        tracking = true;

        base.StartController (ivr);
    }
예제 #5
0
    public override void StartController(InstantVR ivr) {
        base.StartController(ivr);

        present = true;
        headStartPosition = ivr.headTarget.position - ivr.transform.position;
        spineLength = ivr.headTarget.position - ivr.hipTarget.position;
    }
예제 #6
0
    public override void StartController(InstantVR ivr) {
        if (VRSettings.enabled) {
            if (extension == null)
                extension = ivr.GetComponent<IVR_RiftGearVR>();

            present = VRDevice.isPresent;
            extension.present = present;

            headcam = this.transform.FindChild("Headcam");
            localNeckOffset = headcam.localPosition;

            headcamRoot = new GameObject("HeadcamRoot");
            headcamRoot.transform.parent = ivr.transform;
            headcamRoot.transform.position = this.transform.position;
            headcamRoot.transform.rotation = this.transform.rotation;

            headcam.parent = headcamRoot.transform;

            base.StartController(ivr);
            this.position = startPosition - extension.trackerPosition;
            this.rotation = Quaternion.identity;

            OVRManager ovrManager = this.gameObject.AddComponent<OVRManager>();
            ovrManager.resetTrackerOnLoad = true;

            positionTracking = false;
        }
    }
예제 #7
0
    public void Start()
    {
        ivr = GetComponent <InstantVR>();
        ivr.SetPlayerHeight(playerHeight);

        Debug.Log("Please press <tab> to calibrate player height.");

        headMovements = ivr.headTarget.GetComponent <HeadMovements>();
#if INSTANTVR_ADVANCED
        leftHandMovements  = ivr.leftHandTarget.GetComponent <IVR_HandMovements>();
        rightHandMovements = ivr.rightHandTarget.GetComponent <IVR_HandMovements>();
#endif

        // get the first player's controller
        controller0 = Controllers.GetController(0);

        // register for button down events
        controller0.left.OnButtonDownEvent  += OnButtonDownLeft;
        controller0.right.OnButtonDownEvent += OnButtonDownRight;

        // register for button up events
        controller0.left.OnButtonUpEvent  += OnButtonUpLeft;
        controller0.right.OnButtonUpEvent += OnButtonUpRight;
#if INSTANTVR_ADVANCED
        if (walkingType == WalkTypes.PointingTeleport)
        {
            pointingDevice = GetPointingDevice();
        }
#endif
    }
    public override void StartController(InstantVR ivr)
    {
        base.StartController(ivr);
        present = true;

        joystick2present = CheckJoystick2Present();
        ivrInput = this.gameObject.GetComponent<IVR_Input>();

        hipStartRotationY = ivr.hipTarget.eulerAngles.y;
    }
예제 #9
0
    public override void StartMovements(InstantVR ivr) {
        this.ivr = ivr;

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

        if (this.transform == ivr.leftHandTarget) {
            handObj = animator.GetBoneTransform(HumanBodyBones.LeftHand).gameObject;

        } else {
            handObj = animator.GetBoneTransform(HumanBodyBones.RightHand).gameObject;
        }
    }
예제 #10
0
	public override void StartController(InstantVR ivr) {
		base.StartController(ivr);
		present = true;

		ivrInput = GetComponent<IVR_Input>();
        handMovements = GetComponent<IVR_HandMovementsBase>();

        joystick2available = CheckJoystick2Present();
        bumpersAvailable = CheckBumpersAvailable();
        triggersAvailable = CheckTriggersAvailable();
        startBackAvailable = CheckStartBackAvailable();

        hipStartRotationY = ivr.hipTarget.eulerAngles.y;
	}
예제 #11
0
	public override void StartController(InstantVR ivr) {
		base.StartController(ivr);
		present = true;
	
		animatorHip = ivr.hipTarget.GetComponent<IVR_AnimatorHip>();
		lastHipPosition = ivr.hipTarget.position;
		animatorHipStartPosition = ivr.hipTarget.position;

        hip2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.hipTarget.position - this.transform.position);
		if (this.transform == ivr.leftHandTarget) {
			foot2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.leftHandTarget.position - ivr.rightFootTarget.position);
		} else {
			foot2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.rightHandTarget.position - ivr.leftFootTarget.position);
		}
	}
예제 #12
0
    void Start()
    {
        character = GetComponent <InstantVR>();

#if INSTANTVR_ADVANCED
        leftHandMovements  = (IVR_HandMovements)character.leftHandMovements;
        rightHandMovements = (IVR_HandMovements)character.rightHandMovements;
#endif

        // get the first player's controller
        controller0 = Controllers.GetController(0);

        // register for button down events
        controller0.right.OnButtonDownEvent += OnButtonDown;
    }
예제 #13
0
    void Start()
    {
        Debug.Log("Please press <tab> to calibrate player height.");
        character = GetComponent <InstantVR>();

#if INSTANTVR_ADVANCED
        leftHandMovements  = character.leftHandTarget.GetComponent <IVR_HandMovements>();
        rightHandMovements = character.rightHandTarget.GetComponent <IVR_HandMovements>();
#endif

        // get the first player's controller
        controller0 = Controllers.GetController(0);

        // register for button down events
        controller0.right.OnButtonDownEvent += OnButtonDown;
    }
예제 #14
0
    void OnEnable()
    {
        ivrTraditional = (IVR_Traditional) target;
        ivr = ivrTraditional.GetComponent<InstantVR>();

        if (ivr != null) {
            traditionalHead = ivr.headTarget.GetComponent<IVR_TraditionalHead>();
            if (traditionalHead == null) {
                traditionalHead = ivr.headTarget.gameObject.AddComponent<IVR_TraditionalHead>();
                traditionalHead.extension = ivrTraditional;
            }

            traditionalLeftHand = ivr.leftHandTarget.GetComponent<IVR_TraditionalHand>();
            if (traditionalLeftHand == null) {
                traditionalLeftHand = ivr.leftHandTarget.gameObject.AddComponent<IVR_TraditionalHand>();
                traditionalLeftHand.extension = ivrTraditional;
            }

            traditionalRightHand = ivr.rightHandTarget.GetComponent<IVR_TraditionalHand>();
            if (traditionalRightHand == null) {
                traditionalRightHand = ivr.rightHandTarget.gameObject.AddComponent<IVR_TraditionalHand>();
                traditionalRightHand.extension = ivrTraditional;
            }

            IVR_Extension[] extensions = ivr.GetComponents<IVR_Extension>();
            if (ivrTraditional.priority == -1)
                ivrTraditional.priority = extensions.Length - 1;
            for (int i = 0; i < extensions.Length; i++) {
                if (ivrTraditional == extensions[i]) {
                    while (i < ivrTraditional.priority) {
                        MoveUp(traditionalHead);
                        MoveUp(traditionalLeftHand);
                        MoveUp(traditionalRightHand);
                        ivrTraditional.priority--;
                        //Debug.Log ("Traditional Move up to : " + i + " now: " + ivrTraditional.priority);
                    }
                    while (i > ivrTraditional.priority) {
                        MoveDown(traditionalHead);
                        MoveDown(traditionalLeftHand);
                        MoveDown(traditionalRightHand);
                        ivrTraditional.priority++;
                        //Debug.Log ("Traditional Move down to : " + i + " now: " + ivrTraditional.priority);
                    }
                }
            }
        }
    }
예제 #15
0
    public ArmBasics(InstantVR ivr, BodySide bodySide_in, BodyMovementsBasics bodyMovements_in)
    {
        this.ivr = ivr;
        animator = ivr.GetComponentInChildren<Animator>();

        this.bodyMovements = bodyMovements_in;
        this.bodySide = bodySide_in;

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

            if (bodyMovements.fromNormLeftHand == Quaternion.identity) {
                bodyMovements.fromNormLeftUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormLeftForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormLeftHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);

            if (bodyMovements.fromNormRightHand == Quaternion.identity) {
                bodyMovements.fromNormRightUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormRightForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormRightHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        }

        float upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        float forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;

        upperArmStartPosition = upperArm.position;
    }
예제 #16
0
    public static Vector3 GetHeadEyeDelta(InstantVR ivr)
    {
        Animator animator = ivr.characterTransform.GetComponent <Animator>();

        if (animator != null)
        {
            Transform neckBone     = animator.GetBoneTransform(HumanBodyBones.Neck);
            Transform leftEyeBone  = animator.GetBoneTransform(HumanBodyBones.LeftEye);
            Transform rightEyeBone = animator.GetBoneTransform(HumanBodyBones.RightEye);
            if (neckBone != null && leftEyeBone != null && rightEyeBone != null)
            {
                Vector3 centerEyePosition = (leftEyeBone.position + rightEyeBone.position) / 2;
                Vector3 worldHeadEyeDelta = (centerEyePosition - neckBone.position);
                Vector3 localHeadEyeDelta = ivr.headTarget.InverseTransformDirection(worldHeadEyeDelta);
                return(localHeadEyeDelta);
            }
        }

        return(new Vector3(0, 0.13F, 0.13F));;
    }
예제 #17
0
    public override void StartController(InstantVR ivr)
    {
        base.StartController(ivr);

        if (this.transform == ivr.leftFootTarget) {
            isLeftFoot = true;
            leftFoot = this;
            rightFoot = ivr.rightFootTarget.GetComponent<IVR_AnimatorFoot>();
            leftFootAnimation = this.gameObject.AddComponent<IVR_Animate>();
        } else {
            rightFoot = this;
            leftFoot = ivr.leftFootTarget.GetComponent<IVR_AnimatorFoot>();
            rightFootAnimation = this.gameObject.AddComponent<IVR_Animate>();
        }

        startHipFootL = ivr.hipTarget.InverseTransformPoint(ivr.leftFootTarget.position);//ivr.leftFootTarget.position - ivr.hipTarget.position;
        startHipFootR = ivr.hipTarget.InverseTransformPoint(ivr.rightFootTarget.position);//ivr.rightFootTarget.position - ivr.hipTarget.position;

        startFootLposition = ivr.leftFootTarget.position - ivr.BasePosition;
        startFootRposition = ivr.rightFootTarget.position - ivr.BasePosition;
    }
예제 #18
0
    public override void StartController(InstantVR ivr) {
        base.StartController(ivr);
#if UNITY_ANDROID
        Transform headcam = this.transform.FindChild("Headcam");
        if (headcam != null) {
            headcam.gameObject.SetActive(false);

            Cardboard cardboardPrefab = Resources.Load<Cardboard>("CardboardPrefab");
            cardboard = (Cardboard)Instantiate(cardboardPrefab, headcam.position, headcam.rotation);


            if (cardboard == null)
                Debug.LogError("Could not instantiate Cardboard. CardboardCameraRig is missing?");
            else {
                cardboard.transform.parent = ivr.transform;

                cardboardStartPoint = cardboard.transform.position;
                baseStartPoint = ivr.transform.position;
                cardboardStartRotation = cardboard.transform.rotation;
                baseStartAngle = ivr.transform.eulerAngles.y;

                present = true;
                if (!present) {
                    cardboard.gameObject.SetActive(false);
                    headcam.gameObject.SetActive(true);
                } else
                    headcam.gameObject.SetActive(false);
#if !UNITY_4_5
                if (raycaster) {
                    GameObject mainCamera = cardboard.GetComponentInChildren<StereoController>().gameObject;
                    mainCamera.AddComponent<PhysicsRaycaster>();
                }
#endif
            }
            startRotation = Quaternion.Inverse(ivr.transform.rotation);
        }
#endif
    }
 public virtual void StartMovements(InstantVR ivr)
 {
 }
예제 #20
0
    void Start() {
        ivr = this.GetComponent<InstantVR>();

        leftInput = ivr.leftHandTarget.GetComponent<IVR_Input>();
        bodyCapsule = AddHipCollider(ivr.hipTarget.gameObject);
    }
    public virtual void StartController(InstantVR ivr)
    {
        this.ivr = ivr;
        startPosition = transform.position - ivr.BasePosition;
        startRotation = Quaternion.Inverse(ivr.BaseRotation) * transform.rotation;

        lastPosition = startPosition;
        lastRotation = startRotation;
    }
예제 #22
0
 public ArmMovements_Free(InstantVR ivr, ArmBasics.BodySide bodySide_in, BodyMovementsBasics bodyMovements)
     : base(ivr, bodySide_in, bodyMovements)
 {
 }
예제 #23
0
	void OnEnable() {
		ivranimator = (IVR_Animator) target;
		ivr = ivranimator.GetComponent<InstantVR>();

		if (ivr != null) {
			animatorHead = ivr.headTarget.GetComponent<IVR_AnimatorHead>();
			if (animatorHead == null) {
				animatorHead = ivr.headTarget.gameObject.AddComponent<IVR_AnimatorHead>();
				animatorHead.extension = ivranimator;
			}

			animatorLeftHand = ivr.leftHandTarget.GetComponent<IVR_AnimatorHand>();
			if (animatorLeftHand == null) {
				animatorLeftHand = ivr.leftHandTarget.gameObject.AddComponent<IVR_AnimatorHand>();
				animatorLeftHand.extension = ivranimator;
			}

			animatorRightHand = ivr.rightHandTarget.GetComponent<IVR_AnimatorHand>();
			if (animatorRightHand == null) {
				animatorRightHand = ivr.rightHandTarget.gameObject.AddComponent<IVR_AnimatorHand>();
				animatorRightHand.extension = ivranimator;
			}

			animatorHip = ivr.hipTarget.GetComponent<IVR_AnimatorHip>();
			if (animatorHip == null) {
				animatorHip = ivr.hipTarget.gameObject.AddComponent<IVR_AnimatorHip>();
				animatorHip.extension = ivranimator;
			}

			animatorLeftFoot = ivr.leftFootTarget.GetComponent<IVR_AnimatorFoot>();
			if (animatorLeftFoot== null) {
				animatorLeftFoot = ivr.leftFootTarget.gameObject.AddComponent<IVR_AnimatorFoot>();
				animatorLeftFoot.extension = ivranimator;
			}

			animatorRightFoot = ivr.rightFootTarget.GetComponent<IVR_AnimatorFoot>();
			if (animatorRightFoot == null) {
				animatorRightFoot = ivr.rightFootTarget.gameObject.AddComponent<IVR_AnimatorFoot>();
				animatorRightFoot.extension = ivranimator;
			}

			IVR_Extension[] extensions = ivr.GetComponents<IVR_Extension>();
			if (ivranimator.priority == -1)
				ivranimator.priority = extensions.Length - 1;
			for (int i = 0; i < extensions.Length; i++) {
				if (ivranimator == extensions[i]) {
					while (i < ivranimator.priority) {
						MoveUp(animatorHead);
						MoveUp(animatorLeftHand);
						MoveUp(animatorRightHand);
						MoveUp(animatorHip);
						MoveUp(animatorLeftFoot);
						MoveUp(animatorRightFoot);
						ivranimator.priority--;
						//Debug.Log ("Animator Move up to : " + i + " now: " + ivranimator.priority);
					}
					while (i > ivranimator.priority) {
						MoveDown(animatorHead);
						MoveDown(animatorLeftHand);
						MoveDown(animatorRightHand);
						MoveDown(animatorHip);
						MoveDown(animatorLeftFoot);
						MoveDown(animatorRightFoot);
						ivranimator.priority++;
						//Debug.Log ("Animator Move down to : " + i + " now: " + ivranimator.priority);
					}
				}
			}
		}
	}
예제 #24
0
 public virtual void StartInput(InstantVR ivr)
 {
 }
예제 #25
0
	public void StartMovements() {
		ivr = this.GetComponent<InstantVR>();

		headTarget = ivr.headTarget;
		leftHandTarget = ivr.leftHandTarget;
		rightHandTarget = ivr.rightHandTarget;
		hipTarget = ivr.hipTarget;
		leftFootTarget = ivr.leftFootTarget;
		rightFootTarget = ivr.rightFootTarget;

		animator = ivr.transform.GetComponentInChildren<Animator>();
        if (animator == null) {
            StopMovements();
        } else {

            characterRigidbody = animator.GetComponent<Rigidbody>();

            if (characterRigidbody != null)
                characterTransform = characterRigidbody.GetComponent<Transform>();

            if (leftArm == null)
                leftArm = new ArmMovements(ivr, ArmMovements.BodySide.Left, this);
            leftArm.Initialize(ivr, ArmMovements.BodySide.Left, this);

            if (rightArm == null)
                rightArm = new ArmMovements(ivr, ArmMovements.BodySide.Right, this);
            rightArm.Initialize(ivr, ArmMovements.BodySide.Right, this);

            Transform neck, spine, hips;

            neck = animator.GetBoneTransform(HumanBodyBones.Neck);
            if (neck == null)
                neck = animator.GetBoneTransform(HumanBodyBones.Head);
            spine = animator.GetBoneTransform(HumanBodyBones.Spine);
            hips = animator.GetBoneTransform(HumanBodyBones.Hips);
            torso = new Torso(neck, spine, hips, hipTarget, headTarget, rightArm);

            leftLeg = new Leg(ArmMovements.BodySide.Left, animator, hipTarget);
            rightLeg = new Leg(ArmMovements.BodySide.Right, animator, hipTarget);

            if (rightHandTarget != null) {
                rightHandOTarget = rightHandTarget;
                /*
                float targetScaleZ = rightHandTarget.transform.localScale.z;
                rightPalmTarget = new GameObject();
                rightPalmTarget.name = "Palm_R_Target";
                rightPalmTarget.transform.parent = rightHandTarget.transform;
                rightPalmTarget.transform.localPosition = new Vector3(0, 0, -palmLength/targetScaleZ);
                rightPalmTarget.transform.localEulerAngles = Vector3.zero;
				
                rightHandTarget = rightPalmTarget.transform;
                */
            }

            if (leftHandTarget != null) {
                leftHandOTarget = leftHandTarget;
                /*
                float targetScaleZ = leftHandTarget.transform.localScale.z;
                leftPalmTarget = new GameObject();
                leftPalmTarget.name = "Palm_L_Target";
                leftPalmTarget.transform.parent = leftHandTarget.transform;
                leftPalmTarget.transform.localPosition = new Vector3(0, 0, -palmLength/targetScaleZ);
                leftPalmTarget.transform.localEulerAngles = Vector3.zero;

                leftHandTarget = leftPalmTarget.transform;
                */
            }

            if (headTarget == null && enableTorso) {
                GameObject neckTargetGO = new GameObject("Neck_Target");
                headTarget = neckTargetGO.transform;
                headTarget.parent = characterTransform;
                headTarget.position = torso.neck.position;
                headTarget.rotation = characterTransform.rotation;
            }

            if (enableLegs) {
                if (rightFootTarget == null) {
                    //userLegTargets = false;
                    GameObject rightFootTargetGO = new GameObject("Foot_R_Target");
                    rightFootTarget = rightFootTargetGO.transform;
                    rightFootTarget.parent = characterTransform;
                    rightFootTarget.position = rightLeg.foot.position;
                    rightFootTarget.rotation = characterTransform.rotation;
                }

                if (leftFootTarget == null) {
                    //userLegTargets = false;
                    GameObject leftFootTargetGO = new GameObject("Foot_L_Target");
                    leftFootTarget = leftFootTargetGO.transform;
                    leftFootTarget.parent = characterTransform;
                    leftFootTarget.position = leftLeg.foot.position;
                    leftFootTarget.rotation = characterTransform.rotation;
                }
            }


            if (IsInTPose(leftArm, rightArm)) {
                CalculateFromNormTPose(leftArm, rightArm);
            } else {
                CalculateFromNormTracking(leftArm, rightArm, leftHandTarget, rightHandTarget);
            }
        }
    }
예제 #26
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);
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);
        }

        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;
    }
예제 #27
0
 public ArmMovements(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
     Initialize(ivr, bodySide, bodyMovements);
 }