示例#1
0
    /// <summary>
    /// Updates the internal state of the Mixed Reality Camera. Called by OVRManager.
    /// </summary>

    public static void Update(GameObject parentObject, Camera mainCamera, OVRManager.CompositionMethod compositionMethod, bool useDynamicLighting, OVRManager.CameraDevice cameraDevice, OVRManager.DepthQuality depthQuality)
    {
        if (!OVRPlugin.initialized)
        {
            Debug.LogError("OVRPlugin not initialized");
            return;
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            OVRPlugin.InitializeMixedReality();
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            Debug.LogError("Unable to initialize MixedReality");
            return;
        }

        OVRPlugin.UpdateExternalCamera();
        OVRPlugin.UpdateCameraDevices();

        if (currentComposition != null && currentComposition.CompositionMethod() != compositionMethod)
        {
            currentComposition.Cleanup();
            currentComposition = null;
        }

        if (compositionMethod == OVRManager.CompositionMethod.External)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRExternalComposition(parentObject, mainCamera);
            }
        }
        else if (compositionMethod == OVRManager.CompositionMethod.Direct)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRDirectComposition(parentObject, mainCamera, cameraDevice, useDynamicLighting, depthQuality);
            }
        }
        else if (compositionMethod == OVRManager.CompositionMethod.Sandwich)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRSandwichComposition(parentObject, mainCamera, cameraDevice, useDynamicLighting, depthQuality);
            }
        }
        else
        {
            Debug.LogError("Unknown CompositionMethod : " + compositionMethod);
            return;
        }
        currentComposition.Update(mainCamera);
    }
示例#2
0
 public static void Cleanup()
 {
     if (currentComposition != null)
     {
         currentComposition.Cleanup();
         currentComposition = null;
     }
     if (OVRPlugin.IsMixedRealityInitialized())
     {
         OVRPlugin.ShutdownMixedReality();
     }
 }
示例#3
0
    /// <summary>
    /// Updates the internal state of the Mixed Reality Camera. Called by OVRManager.
    /// </summary>

    public static void Update(GameObject parentObject, Camera mainCamera, OVRMixedRealityCaptureConfiguration configuration, OVRManager.TrackingOrigin trackingOrigin)
    {
        if (!OVRPlugin.initialized)
        {
            Debug.LogError("OVRPlugin not initialized");
            return;
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            OVRPlugin.InitializeMixedReality();
            if (OVRPlugin.IsMixedRealityInitialized())
            {
                Debug.Log("OVRPlugin_MixedReality initialized");
            }
            else
            {
                Debug.LogError("Unable to initialize OVRPlugin_MixedReality");
                return;
            }
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            return;
        }

        OVRPlugin.UpdateExternalCamera();
#if !OVR_ANDROID_MRC
        OVRPlugin.UpdateCameraDevices();
#endif

#if OVR_ANDROID_MRC
        useFakeExternalCamera = OVRPlugin.Media.UseMrcDebugCamera();
#endif

        if (currentComposition != null && (currentComposition.CompositionMethod() != configuration.compositionMethod))
        {
            currentComposition.Cleanup();
            currentComposition = null;
        }

        if (configuration.compositionMethod == OVRManager.CompositionMethod.External)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRExternalComposition(parentObject, mainCamera, configuration);
            }
        }
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        else if (configuration.compositionMethod == OVRManager.CompositionMethod.Direct)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRDirectComposition(parentObject, mainCamera, configuration);
            }
        }
#endif
        else
        {
            Debug.LogError("Unknown CompositionMethod : " + configuration.compositionMethod);
            return;
        }
        currentComposition.Update(parentObject, mainCamera, configuration, trackingOrigin);
    }
示例#4
0
        public void Update()
        {
            if (!enableMixedReality && !prevEnableMixedReality)
            {
                return;
            }

            if ((UnityEngine.Object)Camera.main != (UnityEngine.Object)null)
            {
                suppressDisableMixedRealityBecauseOfNoMainCameraWarning = false;

                Camera mainCamera = MainCamera;
                if ((Camera)mainCamera == (UnityEngine.Object)null)
                {
                    Console.Write("mainCamera null");
                    return;
                }

                if (enableMixedReality)
                {
                    if (base.gameObject == null)
                    {
                        Console.Write("base.gameObject is null");
                        return;
                    }

                    System.Object[] parameters = { base.gameObject, mainCamera, oVRManager.compositionMethod, oVRManager.useDynamicLighting, oVRManager.capturingCameraDevice, oVRManager.depthQuality };
                    getUpdateMethod().Invoke(null, parameters);
                    //OVRMixedReality.Update(base.gameObject, MainCamera, OVRManager.CompositionMethod.Sandwich, false, OVRManager.CameraDevice.WebCamera0, OVRManager.DepthQuality.High);

                    // it seems we need to add post processing effects to the final image, as somehow they don't get applied automatically!
                    // for that PostProcess will apply them, but we need to add the HackPostProcess gameobject into the just created camera (which we didn't create)
                    // so we need to get the camera out of the OVRMixedReality package and add the post process hack to them
                    // - is there a better way to do this ?
                    if (!addedPostProcess)
                    {
                        OVRComposition ovrComposition = (OVRComposition)getOvrMixedRealityType().GetField("currentComposition", BindingFlags.Static | BindingFlags.Public).GetValue(null);
                        if (ovrComposition != null)
                        {
                            if (ovrComposition is OVRDirectComposition)
                            {
                                ((OVRDirectComposition)ovrComposition).directCompositionCamera.gameObject.AddComponent <OVRManagerHackPostProcess>();
                            }
                            else if (ovrComposition is OVRExternalComposition)
                            {
                                Camera backgroundCamera = (Camera)ovrComposition.GetType().GetField("backgroundCamera", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ovrComposition);
                                backgroundCamera.gameObject.AddComponent <OVRManagerHackPostProcess>();

                                Camera foregroundCamera = (Camera)ovrComposition.GetType().GetField("foregroundCamera", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ovrComposition);
                                foregroundCamera.gameObject.AddComponent <OVRManagerHackPostProcess>();
                            }
                            else if (ovrComposition is OVRSandwichComposition)
                            {
                                ((OVRSandwichComposition)ovrComposition).bgCamera.gameObject.AddComponent <OVRManagerHackPostProcess>();
                                ((OVRSandwichComposition)ovrComposition).fgCamera.gameObject.AddComponent <OVRManagerHackPostProcess>();
                            }
                        }


                        addedPostProcess = true;
                    }
                }
                if (prevEnableMixedReality && !enableMixedReality)
                {
                    Console.WriteLine("Cleanup!");
                    getCleanupMethod().Invoke(null, null);
                    addedPostProcess = false;
                    //OVRMixedReality.Cleanup();
                }
                prevEnableMixedReality = enableMixedReality;
            }
            else if (!suppressDisableMixedRealityBecauseOfNoMainCameraWarning)
            {
                Debug.LogWarning("x Main Camera is not set, Mixed Reality disabled");
                suppressDisableMixedRealityBecauseOfNoMainCameraWarning = true;
            }
        }
示例#5
0
    /// <summary>
    /// Updates the internal state of the Mixed Reality Camera. Called by OVRManager.
    /// </summary>

    public static void Update(GameObject parentObject, Camera mainCamera, OVRManager.CompositionMethod compositionMethod, bool useDynamicLighting, OVRManager.CameraDevice cameraDevice, OVRManager.DepthQuality depthQuality)
    {
        if (!OVRPlugin.initialized)
        {
            Debug.LogError("OVRPlugin not initialized");
            return;
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            OVRPlugin.InitializeMixedReality();
            if (OVRPlugin.IsMixedRealityInitialized())
            {
                Debug.Log("OVRPlugin_MixedReality initialized");
            }
            else
            {
                Debug.LogError("Unable to initialize OVRPlugin_MixedReality");
                return;
            }
        }

        if (!OVRPlugin.IsMixedRealityInitialized())
        {
            return;
        }

        OVRPlugin.UpdateExternalCamera();
#if !OVR_ANDROID_MRC
        OVRPlugin.UpdateCameraDevices();
#endif

#if OVR_ANDROID_MRC
        useFakeExternalCamera = OVRPlugin.Media.UseMrcDebugCamera();
#endif

        if (currentComposition != null && currentComposition.CompositionMethod() != compositionMethod)
        {
            currentComposition.Cleanup();
            currentComposition = null;
        }

        if (compositionMethod == OVRManager.CompositionMethod.External)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRExternalComposition(parentObject, mainCamera);
            }
        }
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        else if (compositionMethod == OVRManager.CompositionMethod.Direct)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRDirectComposition(parentObject, mainCamera, cameraDevice, useDynamicLighting, depthQuality);
            }
        }
        else if (compositionMethod == OVRManager.CompositionMethod.Sandwich)
        {
            if (currentComposition == null)
            {
                currentComposition = new OVRSandwichComposition(parentObject, mainCamera, cameraDevice, useDynamicLighting, depthQuality);
            }
        }
#endif
        else
        {
            Debug.LogError("Unknown CompositionMethod : " + compositionMethod);
            return;
        }
        currentComposition.Update(mainCamera);
    }