Beispiel #1
0
        private void Update()
        {
            if (m_ARInterface == null)
            {
                return;
            }

            m_ARInterface.Update();
            m_ARInterface.UpdateCamera(m_ARCamera);

            Pose pose = new Pose();

            if (m_ARInterface.TryGetPose(ref pose))
            {
                m_ARCamera.transform.position = pose.position;
                m_ARCamera.transform.rotation = pose.rotation;
            }

            if (isConnected && m_ServiceRunning)
            {
                var serializedFrame = new SerializableFrame(
                    m_ARCamera.projectionMatrix,
                    m_ARCamera.transform.position,
                    m_ARCamera.transform.rotation,
                    m_ARInterface.GetDisplayTransform());

                SendToEditor(ARMessageIds.frame, serializedFrame);

                if (m_CachedSettings.enablePointCloud)
                {
                    if (m_ARInterface.TryGetPointCloud(ref m_PointCloud))
                    {
                        var serializedPointCloud = new SerializablePointCloud(m_PointCloud);
                        SendToEditor(ARMessageIds.pointCloud, serializedPointCloud);
                    }
                }

                if (m_CachedSettings.enableLightEstimation)
                {
                    var serializedLightEstimate = (SerializableLightEstimate)m_ARInterface.GetLightEstimate();
                    SendToEditor(ARMessageIds.lightEstimate, serializedLightEstimate);
                }

                if (m_SendVideo)
                {
                    if (m_ARInterface.TryGetCameraImage(ref m_CameraImage))
                    {
                        if (!m_HaveSentCameraParams)
                        {
                            var screenCaptureParams = new SerializableScreenCaptureParams(
                                m_CameraImage.width,
                                m_CameraImage.height,
                                (int)TextureFormat.YUY2);

                            SendToEditor(ARMessageIds.screenCaptureParams, screenCaptureParams);
                            m_HaveSentCameraParams = true;
                        }

                        SendToEditor(ARMessageIds.screenCaptureY, m_CameraImage.y);
                        SendToEditor(ARMessageIds.screenCaptureUV, m_CameraImage.uv);
                    }
                }
            }
        }