public override void StartController(InstantVR ivr) { base.StartController(ivr); tracking = true; handAnimator = GetComponent <IVR_AnimatorHand>(); }
//[HideInInspector] //private IVR_HandMovements handMovements; public override void StartController(InstantVR ivr) { extension = ivr.GetComponent <IVR_Animator>(); base.StartController(ivr); animatorHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>(); lastHipPosition = ivr.hipTarget.position; //handMovements = GetComponent<IVR_HandMovements>(); 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); footController = ivr.rightFootTarget.GetComponent <IVR_Controller>(); } else { foot2hand = Quaternion.Inverse(ivr.transform.rotation) * (ivr.rightHandTarget.position - ivr.leftFootTarget.position); footController = ivr.leftFootTarget.GetComponent <IVR_Controller>(); } if (footController.GetType() == typeof(IVR_AnimatorFoot) && !footController.enabled) { footController = null; } }
public static Vector3 GetNeckEyeDelta(InstantVR ivr) { if (ivr.characterTransform == null) { return(neckEyeDelta); } Animator animator = ivr.characterTransform.GetComponent <Animator>(); if (animator == null) { return(neckEyeDelta); } 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.transform.position + rightEyeBone.transform.position) / 2; Vector3 worldNeckEyeDelta = (centerEyePosition - neckBone.position); neckEyeDelta = ivr.headTarget.InverseTransformDirection(worldNeckEyeDelta); } return(neckEyeDelta); }
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>()); } }
public override void StartController(InstantVR ivr) { extension = ivr.GetComponent <IVR_Traditional>(); base.StartController(ivr); controller = Controllers.GetController(0); }
public override void StartMovements(InstantVR _ivr) { base.StartMovements(_ivr); Animator animator = ivr.GetComponentInChildren <Animator>(); if (animator != null) { GameObject hand; if (this.transform == ivr.leftHandTarget) { hand = animator.GetBoneTransform(HumanBodyBones.LeftHand).gameObject; } else { hand = animator.GetBoneTransform(HumanBodyBones.RightHand).gameObject; } handRigidbody = hand.GetComponentInChildren <Rigidbody>(); if (handRigidbody == null) { handRigidbody = hand.AddComponent <Rigidbody>(); } handRigidbody.mass = 1; handRigidbody.drag = 0; handRigidbody.angularDrag = 10; handRigidbody.useGravity = false; handRigidbody.isKinematic = true; handRigidbody.interpolation = RigidbodyInterpolation.None; handRigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete; } }
// private IVR.HeadMovementsBase headMovements; // /private Transform cameraTransform; public override void StartController(InstantVR ivr) { base.StartController(ivr); tracking = true; // headMovements = GetComponent<IVR.HeadMovementsBase>(); // cameraTransform = ivr.GetComponentInChildren<Camera>().transform; }
public override void StartController(InstantVR ivr) { extension = ivr.GetComponent <IVR_Traditional>(); base.StartController(ivr); tracking = true; handAnimator = GetComponent <IVR_AnimatorHand>(); }
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); } } } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); checkInstantVRpackage(); InstantVR ivr = (InstantVR)target; CheckAvatar(ivr); }
public override void StartExtension(InstantVR ivr) { base.StartExtension(ivr); IVR_UnityVRHead unityVrHead = ivr.headTarget.GetComponent <IVR_UnityVRHead>(); unityVrHead.cameraRoot = new GameObject("UnityVR Root"); unityVrHead.cameraRoot.transform.parent = ivr.transform; }
public override void StartController(InstantVR ivr) { base.StartController(ivr); headStartPosition = ivr.headTarget.position - ivr.transform.position; spineLength = ivr.headTarget.position - ivr.hipTarget.position; controllerPosition = startPosition; controllerRotation = startRotation; }
public override void StartController(InstantVR ivr) { extension = ivr.GetComponent <IVR_Animator>(); base.StartController(ivr); headStartPosition = ivr.headTarget.position - ivr.transform.position; spineLength = Vector3.Distance(ivr.headTarget.position, ivr.hipTarget.position); controllerPosition = startPosition; controllerRotation = startRotation; }
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 }
public override void StartController(InstantVR ivr) { base.StartController(ivr); #if UNITY_ANDROID if (extension == null) { extension = ivr.GetComponent <IVR_Cardboard>(); } Camera camera = CheckCamera(); if (camera != null) { cameraTransform = camera.transform; neck2eyes = HeadUtils.GetNeckEyeDelta(ivr); cameraTransform.gameObject.SetActive(false); GvrViewer cardboardPrefab = Resources.Load <GvrViewer>("CardboardPrefab"); cardboard = Instantiate(cardboardPrefab); if (cardboard == null) { Debug.LogError("Could not instantiate Cardboard. CardboardCameraRig is missing?"); } else { cameraRoot = cardboard.gameObject; cameraRoot.transform.parent = ivr.transform; cameraRoot.transform.position = transform.position; cameraRoot.transform.rotation = ivr.transform.rotation; GvrHead gvrHead = cardboard.GetComponentInChildren <GvrHead>(); if (gvrHead != null) { camera = Camera.main; cameraTransform = Camera.main.transform; } } } controller = Controllers.GetController(0); #if INSTANTVR_ADVANCED vicoVRHead = GetComponent <IVR_VicoVRHead>(); #endif #endif }
public override void StartController(InstantVR ivr) { base.StartController(ivr); 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); } }
public override void StartController(InstantVR ivr) { if (extension == null) { extension = ivr.GetComponent <IVR_UnityVR>(); } #if UNITY_IOS extension.present = true; // maybe only when GVR SDK is present? #elif UNITY_2017_2_OR_NEWER extension.present = XRDevice.isPresent; #else extension.present = VRDevice.isPresent; #endif Camera camera = CheckCamera(); if (camera != null) { cameraTransform = camera.transform; neck2eyes = HeadUtils.GetNeckEyeDelta(ivr); DeterminePlatform(); if (vrTracking) { if (!originOnFloor) { cameraRoot.transform.position = transform.position; extension.trackerPosition = cameraRoot.transform.localPosition; } cameraRoot.transform.rotation = ivr.transform.rotation; cameraTransform.SetParent(cameraRoot.transform, false); } base.StartController(ivr); #if INSTANTVR_ADVANCED #if IVR_KINECT kinect2Head = GetComponent <IVR_Kinect2Head>(); #endif #endif } }
void OnDestroy() { InstantVR ivr = this.GetComponent <InstantVR>(); if (ivr != null) { IVR_AnimatorHead defaultHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>(); if (defaultHead != null) { DestroyImmediate(defaultHead); } IVR_AnimatorHand defaultLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>(); if (defaultLeftHand != null) { DestroyImmediate(defaultLeftHand); } IVR_AnimatorHand defaultRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>(); if (defaultRightHand != null) { DestroyImmediate(defaultRightHand); } IVR_AnimatorHip defaultHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>(); if (defaultHip != null) { DestroyImmediate(defaultHip); } IVR_AnimatorFoot defaultLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>(); if (defaultLeftFoot != null) { DestroyImmediate(defaultLeftFoot); } IVR_AnimatorFoot defaultRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>(); if (defaultRightFoot != null) { DestroyImmediate(defaultRightFoot); } } }
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));; }