Beispiel #1
0
 /// <summary>
 /// Method to be implemented by provider to get the camera frame for the subsystem.
 /// </summary>
 /// <param name="cameraParams">The current Unity <c>Camera</c> parameters.</param>
 /// <param name="cameraFrame">The current camera frame returned by the method.</param>
 /// <returns>
 /// <c>true</c> if the method successfully got a frame. Otherwise, <c>false</c>.
 /// </returns>
 public virtual bool TryGetFrame(
     XRCameraParams cameraParams,
     out XRCameraFrame cameraFrame)
 {
     cameraFrame = default(XRCameraFrame);
     return(false);
 }
Beispiel #2
0
        /// <summary>
        /// Get the latest frame from the provider.
        /// </summary>
        /// <param name="cameraParams">The Unity <c>Camera</c> parameters.</param>
        /// <param name="frame">The camera frame to be populated if the subsystem is running and successfully provides
        /// the latest camera frame.</param>
        /// <returns>
        /// <c>true</c> if the camera frame is successfully returned. Otherwise, <c>false</c>.
        /// </returns>
        public bool TryGetLatestFrame(
            XRCameraParams cameraParams,
            out XRCameraFrame frame)
        {
            if (m_Running && m_Provider.TryGetFrame(cameraParams, out frame))
            {
                return(true);
            }

            frame = default(XRCameraFrame);
            return(false);
        }
            public override bool TryGetFrame(XRCameraParams cameraParams, out UnityEngine.XR.ARSubsystems.XRCameraFrame cameraFrame)
            {
                var frame = new XRCameraFrame();
                XRCameraFrameProperties properties = 0;

                if (m_LastLightEstimation.m_AmbientBrightness.HasValue)
                {
                    frame.AverageBrightness = m_LastLightEstimation.m_AmbientBrightness.Value;
                    properties |= XRCameraFrameProperties.AverageBrightness;
                }

                if (m_LastLightEstimation.m_AmbientColorTemperature.HasValue)
                {
                    frame.AverageColorTemperature = m_LastLightEstimation.m_AmbientColorTemperature.Value;
                    properties |= XRCameraFrameProperties.AverageColorTemperature;
                }

                if (m_LastLightEstimation.m_ColorCorrection.HasValue)
                {
                    frame.ColorCorrection = m_LastLightEstimation.m_ColorCorrection.Value;
                    properties           |= XRCameraFrameProperties.ColorCorrection;
                }

#if ARSUBSYSTEMS_3_OR_NEWER
                if (m_LastLightEstimation.m_AmbientIntensityInLumens.HasValue)
                {
                    frame.AverageIntensityInLumens = m_LastLightEstimation.m_AmbientIntensityInLumens.Value;
                    properties |= XRCameraFrameProperties.AverageIntensityInLumens;
                }
#endif

#if ARSUBSYSTEMS_4_OR_NEWER
                if (m_LastLightEstimation.m_MainLightColor.HasValue)
                {
                    frame.MainLightColor = m_LastLightEstimation.m_MainLightColor.Value;
                    properties          |= XRCameraFrameProperties.MainLightColor;
                }

                if (m_LastLightEstimation.m_MainLightDirection.HasValue)
                {
                    frame.MainLightDirection = m_LastLightEstimation.m_MainLightDirection.Value;
                    properties |= XRCameraFrameProperties.MainLightDirection;
                }

                if (m_LastLightEstimation.m_MainLightIntensityLumens.HasValue)
                {
                    frame.MainLightIntensityLumens = m_LastLightEstimation.m_MainLightIntensityLumens.Value;
                    properties |= XRCameraFrameProperties.MainLightIntensityLumens;
                }

                if (m_LastLightEstimation.m_SphericalHarmonics.HasValue)
                {
                    frame.AmbientSphericalHarmonics = m_LastLightEstimation.m_SphericalHarmonics.Value;
                    properties |= XRCameraFrameProperties.AmbientSphericalHarmonics;
                }
#endif

                frame.Properties = properties;

                var union = new XRCameraFrameUnion {
                    m_OurXRCameraFrame = frame
                };
                cameraFrame = union.m_TheirXRCameraFrame;
                return(true);
            }
 /// <summary>
 /// Constructs a <c>XRCameraFrameReceivedArgs</c>.
 /// </summary>
 /// <param name="cameraSubsystem">The camera subsystem that is raising the event.</param>
 internal XRCameraFrameReceivedArgs(XRCameraSubsystem cameraSubsystem, XRCameraFrame cameraFrame)
 {
     this.cameraSubsystem = cameraSubsystem;
     this.cameraFrame     = cameraFrame;
 }