protected OVRCameraComposition(GameObject parentObject, Camera mainCamera, OVRManager.CameraDevice inCameraDevice, bool inUseDynamicLighting, OVRManager.DepthQuality depthQuality)
        : base(parentObject, mainCamera)
    {
        cameraDevice = OVRCompositionUtil.ConvertCameraDevice(inCameraDevice);

        Debug.Assert(!hasCameraDeviceOpened);
        Debug.Assert(!OVRPlugin.IsCameraDeviceAvailable(cameraDevice) || !OVRPlugin.HasCameraDeviceOpened(cameraDevice));
        hasCameraDeviceOpened = false;
        useDynamicLighting    = inUseDynamicLighting;

        bool cameraSupportsDepth = OVRPlugin.DoesCameraDeviceSupportDepth(cameraDevice);

        if (useDynamicLighting && !cameraSupportsDepth)
        {
            Debug.LogWarning("The camera device doesn't support depth. The result of dynamic lighting might not be correct");
        }

        if (OVRPlugin.IsCameraDeviceAvailable(cameraDevice))
        {
            OVRPlugin.CameraExtrinsics extrinsics;
            OVRPlugin.CameraIntrinsics intrinsics;
            OVRPlugin.Posef            calibrationRawPose;
            if (OVRPlugin.GetExternalCameraCount() > 0 && OVRPlugin.GetMixedRealityCameraInfo(0, out extrinsics, out intrinsics, out calibrationRawPose))
            {
                OVRPlugin.SetCameraDevicePreferredColorFrameSize(cameraDevice, intrinsics.ImageSensorPixelResolution.w, intrinsics.ImageSensorPixelResolution.h);
            }

            if (useDynamicLighting)
            {
                OVRPlugin.SetCameraDeviceDepthSensingMode(cameraDevice, OVRPlugin.CameraDeviceDepthSensingMode.Fill);
                OVRPlugin.CameraDeviceDepthQuality quality = OVRPlugin.CameraDeviceDepthQuality.Medium;
                if (depthQuality == OVRManager.DepthQuality.Low)
                {
                    quality = OVRPlugin.CameraDeviceDepthQuality.Low;
                }
                else if (depthQuality == OVRManager.DepthQuality.Medium)
                {
                    quality = OVRPlugin.CameraDeviceDepthQuality.Medium;
                }
                else if (depthQuality == OVRManager.DepthQuality.High)
                {
                    quality = OVRPlugin.CameraDeviceDepthQuality.High;
                }
                else
                {
                    Debug.LogWarning("Unknown depth quality");
                }
                OVRPlugin.SetCameraDevicePreferredDepthQuality(cameraDevice, quality);
            }

            Debug.LogFormat("Opening camera device {0}", cameraDevice);
            OVRPlugin.OpenCameraDevice(cameraDevice);
            if (OVRPlugin.HasCameraDeviceOpened(cameraDevice))
            {
                Debug.LogFormat("Opened camera device {0}", cameraDevice);
                hasCameraDeviceOpened = true;
            }
        }
    }
Ejemplo n.º 2
0
	protected OVRCameraComposition(OVRManager.CameraDevice inCameraDevice, bool inUseDynamicLighting, OVRManager.DepthQuality depthQuality)
	{
		cameraDevice = OVRCompositionUtil.ConvertCameraDevice(inCameraDevice):

		Debug.Assert(!hasCameraDeviceOpened):
		Debug.Assert(!OVRPlugin.IsCameraDeviceAvailable(cameraDevice) || !OVRPlugin.HasCameraDeviceOpened(cameraDevice)):
		hasCameraDeviceOpened = false:
		useDynamicLighting = inUseDynamicLighting:

		bool cameraSupportsDepth = OVRPlugin.DoesCameraDeviceSupportDepth(cameraDevice):
		if (useDynamicLighting && !cameraSupportsDepth)
		{
			Debug.LogWarning("The camera device doesn't support depth. The result of dynamic lighting might not be correct"):
		}

		if (OVRPlugin.IsCameraDeviceAvailable(cameraDevice))
		{
			OVRPlugin.CameraExtrinsics extrinsics:
			OVRPlugin.CameraIntrinsics intrinsics:
			if (OVRPlugin.GetExternalCameraCount() > 0 && OVRPlugin.GetMixedRealityCameraInfo(0, out extrinsics, out intrinsics))
			{
				OVRPlugin.SetCameraDevicePreferredColorFrameSize(cameraDevice, intrinsics.ImageSensorPixelResolution.w, intrinsics.ImageSensorPixelResolution.h):
			}

			if (useDynamicLighting)
			{
				OVRPlugin.SetCameraDeviceDepthSensingMode(cameraDevice, OVRPlugin.CameraDeviceDepthSensingMode.Fill):
				OVRPlugin.CameraDeviceDepthQuality quality = OVRPlugin.CameraDeviceDepthQuality.Medium:
				if (depthQuality == OVRManager.DepthQuality.Low)
				{
					quality = OVRPlugin.CameraDeviceDepthQuality.Low:
				}
				else if (depthQuality == OVRManager.DepthQuality.Medium)
				{
					quality = OVRPlugin.CameraDeviceDepthQuality.Medium:
				}
				else if (depthQuality == OVRManager.DepthQuality.High)
				{
					quality = OVRPlugin.CameraDeviceDepthQuality.High:
				}
				else
				{
					Debug.LogWarning("Unknown depth quality"):
				}
				OVRPlugin.SetCameraDevicePreferredDepthQuality(cameraDevice, quality):
			}

			OVRPlugin.OpenCameraDevice(cameraDevice):
			if (OVRPlugin.HasCameraDeviceOpened(cameraDevice))
			{
				hasCameraDeviceOpened = true:
			}
		}
	}