internal Baroque_OculusVRManager() { GameObject rig = LoadCameraRig("OVRCameraRig"); camera_rig = rig.GetComponent <OVRCameraRig>(); Debug.Assert(camera_rig != null); avatar = rig.GetComponentInChildren <OvrAvatar>(); Debug.Assert(avatar != null); camera_rig.EnsureGameObjectIntegrity(); head_transform = camera_rig.centerEyeAnchor; camerarig_transform = camera_rig.transform; controller_albedo_with_mask = Resources.Load <Texture>("BaroqueUI/ControllerOculusTouch/AlbedoWithMask"); screen_fade_material = new Material(Resources.Load <Material>("BaroqueUI/Manual Fade Material")); }
bool InitializeTrackingReference() { if (_initialized) { return(true); } if (_handedness != Handedness.Left && _handedness != Handedness.Right) { return(false); } _cameraRig = FindObjectOfType <OVRCameraRig>(); _initialized = _cameraRig != null; if (_initialized) { _cameraRig.EnsureGameObjectIntegrity(); _controllerAnchor = _handedness == Handedness.Left ? _cameraRig.leftControllerAnchor : _cameraRig.rightControllerAnchor; } return(_initialized); }
void InitializeRuntime() { if (!Application.isPlaying || ovrRig != null) { return; } ovrRig = FindObjectOfType <OVRCameraRig>(); ovrRig.EnsureGameObjectIntegrity(); foreach (var skeleton in ovrRig.GetComponentsInChildren <OVRSkeleton>()) { if (skeleton.GetSkeletonType() != GetSkeletonTypeFromHandedness(handedness)) { continue; } skeletonReference = skeleton; break; } Debug.Log($"Hand Runtime {handedness} initilized"); }
private void SetupInput() { cameraRig = GameObject.FindObjectOfType <OVRCameraRig>(); if (cameraRig == null) { var mainCamera = CameraCache.Main; // Instantiate camera rig as a child of the MixedRealityPlayspace var cameraRigObject = GameObject.Instantiate(SettingsProfile.OVRCameraRigPrefab); cameraRig = cameraRigObject.GetComponent <OVRCameraRig>(); // Ensure all related game objects are configured cameraRig.EnsureGameObjectIntegrity(); if (mainCamera != null) { // We already had a main camera MRTK probably started using, let's replace the CenterEyeAnchor MainCamera with it GameObject prefabMainCamera = cameraRig.trackingSpace.Find("CenterEyeAnchor").gameObject; prefabMainCamera.SetActive(false); mainCamera.transform.SetParent(cameraRig.trackingSpace.transform); mainCamera.name = prefabMainCamera.name; GameObject.Destroy(prefabMainCamera); } cameraRig.transform.SetParent(MixedRealityPlayspace.Transform); } else { // Ensure all related game objects are configured cameraRig.EnsureGameObjectIntegrity(); } bool useAvatarHands = SettingsProfile.RenderAvatarHandsInsteadOfController; // If using Avatar hands, de-activate ovr controller rendering foreach (var controllerHelper in cameraRig.gameObject.GetComponentsInChildren <OVRControllerHelper>()) { controllerHelper.gameObject.SetActive(!useAvatarHands); } if (useAvatarHands) { // Initialize the local avatar controller GameObject.Instantiate(SettingsProfile.LocalAvatarPrefab, cameraRig.trackingSpace); } var ovrHands = cameraRig.GetComponentsInChildren <OVRHand>(); foreach (var ovrHand in ovrHands) { // Manage Hand skeleton data var skeletonDataProvider = ovrHand as OVRSkeleton.IOVRSkeletonDataProvider; var skeletonType = skeletonDataProvider.GetSkeletonType(); var ovrSkeleton = ovrHand.GetComponent <OVRSkeleton>(); if (ovrSkeleton == null) { continue; } switch (skeletonType) { case OVRSkeleton.SkeletonType.HandLeft: leftHand = ovrHand; leftSkeleton = ovrSkeleton; break; case OVRSkeleton.SkeletonType.HandRight: rightHand = ovrHand; rightSkeleton = ovrSkeleton; break; } } }
private void SetupInput() { cameraRig = GameObject.FindObjectOfType <OVRCameraRig>(); if (cameraRig == null) { var mainCamera = Camera.main; Transform cameraParent = null; if (mainCamera != null) { cameraParent = mainCamera.transform.parent; // Destroy main camera GameObject.Destroy(cameraParent.gameObject); } // Instantiate camera rig as a child of the MixedRealityPlayspace cameraRig = GameObject.Instantiate(MRTKOculusConfig.Instance.OVRCameraRigPrefab); } // Ensure all related game objects are configured cameraRig.EnsureGameObjectIntegrity(); bool useAvatarHands = MRTKOculusConfig.Instance.RenderAvatarHandsInsteadOfController; // If using Avatar hands, de-activate ovr controller rendering foreach (var controllerHelper in cameraRig.gameObject.GetComponentsInChildren <OVRControllerHelper>()) { controllerHelper.gameObject.SetActive(!useAvatarHands); } if (useAvatarHands && !MRTKOculusConfig.Instance.AllowDevToManageAvatarPrefab) { // Initialize the local avatar controller GameObject.Instantiate(MRTKOculusConfig.Instance.LocalAvatarPrefab, cameraRig.trackingSpace); } var ovrHands = cameraRig.GetComponentsInChildren <OVRHand>(); foreach (var ovrHand in ovrHands) { // Manage Hand skeleton data var skeltonDataProvider = ovrHand as OVRSkeleton.IOVRSkeletonDataProvider; var skeltonType = skeltonDataProvider.GetSkeletonType(); var meshRenderer = ovrHand.GetComponent <OVRMeshRenderer>(); var ovrSkelton = ovrHand.GetComponent <OVRSkeleton>(); if (ovrSkelton == null) { continue; } switch (skeltonType) { case OVRSkeleton.SkeletonType.HandLeft: leftHand = ovrHand; leftSkeleton = ovrSkelton; leftMeshRenderer = meshRenderer; break; case OVRSkeleton.SkeletonType.HandRight: rightHand = ovrHand; rightSkeleton = ovrSkelton; righMeshRenderer = meshRenderer; break; } } }