Beispiel #1
0
    public override QCARRenderer.VideoBGCfgData GetVideoBackgroundConfig()
    {
        if (QCARRuntimeUtilities.IsPlayMode())
        {
            return(this.mVideoBGConfig);
        }
        IntPtr bgCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(QCARRenderer.VideoBGCfgData)));

        QCARWrapper.Instance.RendererGetVideoBackgroundCfg(bgCfg);
        QCARRenderer.VideoBGCfgData data = (QCARRenderer.VideoBGCfgData)Marshal.PtrToStructure(bgCfg, typeof(QCARRenderer.VideoBGCfgData));
        Marshal.FreeHGlobal(bgCfg);
        return(data);
    }
Beispiel #2
0
 public override void SetVideoBackgroundConfig(QCARRenderer.VideoBGCfgData config)
 {
     if (QCARRuntimeUtilities.IsPlayMode())
     {
         this.mVideoBGConfig    = config;
         this.mVideoBGConfigSet = true;
     }
     else
     {
         IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(QCARRenderer.VideoBGCfgData)));
         Marshal.StructureToPtr(config, ptr, true);
         QCARWrapper.Instance.RendererSetVideoBackgroundCfg(ptr);
         Marshal.FreeHGlobal(ptr);
     }
 }
Beispiel #3
0
    // Configure the size and position of the video background rendered
    // natively when QCARManager.DrawVideoBackground is true
    private void ConfigureVideoBackground()
    {
        QCARRenderer.VideoBGCfgData config    = QCARRenderer.Instance.GetVideoBackgroundConfig();
        CameraDevice.VideoModeData  videoMode = CameraDevice.Instance.GetVideoMode(CameraDeviceModeSetting);

        config.enabled     = 1;
        config.synchronous = (SynchronousVideo ? 1 : 0);
        config.position    = new QCARRenderer.Vec2I(0, 0);

        if (Screen.width > Screen.height)
        {
            float height = videoMode.height * (Screen.width / (float)
                                               videoMode.width);
            config.size = new QCARRenderer.Vec2I(Screen.width, (int)height);

            if (config.size.y < Screen.height)
            {
                // Correcting rendering background size to handle missmatch
                // between screen and video aspect ratios
                config.size.x = (int)(Screen.height
                                      * (videoMode.width / (float)videoMode.height));
                config.size.y = Screen.height;
            }
        }
        else
        {
            float width = videoMode.height * (Screen.height / (float)
                                              videoMode.width);
            config.size = new QCARRenderer.Vec2I((int)width, Screen.height);

            if (config.size.x < Screen.width)
            {
                // Correcting rendering background size to handle missmatch
                // between screen and video aspect ratios
                config.size.x = Screen.width;
                config.size.y = (int)(Screen.width *
                                      (videoMode.width / (float)videoMode.height));
            }
        }

        QCARRenderer.Instance.SetVideoBackgroundConfig(config);

        int viewportX = config.position.x + (Screen.width - config.size.x) / 2;
        int viewportY = config.position.y + (Screen.height - config.size.y) / 2;

        mViewportRect = new Rect(viewportX, viewportY,
                                 config.size.x, config.size.y);
    }
Beispiel #4
0
    public void ConfigureVideoBackground(bool forceReflectionSetting)
    {
        QCARRenderer.VideoBGCfgData videoBackgroundConfig = QCARRenderer.Instance.GetVideoBackgroundConfig();
        CameraDevice.VideoModeData  videoMode             = CameraDevice.Instance.GetVideoMode(this.CameraDeviceModeSetting);
        this.VideoBackGroundMirrored      = videoBackgroundConfig.reflection == QCARRenderer.VideoBackgroundReflection.ON;
        videoBackgroundConfig.enabled     = 1;
        videoBackgroundConfig.synchronous = this.SynchronousVideo ? 1 : 0;
        videoBackgroundConfig.position    = new QCARRenderer.Vec2I(0, 0);
        if (!QCARRuntimeUtilities.IsPlayMode() && forceReflectionSetting)
        {
            videoBackgroundConfig.reflection = this.MirrorVideoBackground;
        }
        bool flag = Screen.width > Screen.height;

        if (QCARRuntimeUtilities.IsPlayMode())
        {
            flag = true;
        }
        if (flag)
        {
            float num = videoMode.height * (((float)Screen.width) / ((float)videoMode.width));
            videoBackgroundConfig.size = new QCARRenderer.Vec2I(Screen.width, (int)num);
            if (videoBackgroundConfig.size.y < Screen.height)
            {
                videoBackgroundConfig.size.x = (int)(Screen.height * (((float)videoMode.width) / ((float)videoMode.height)));
                videoBackgroundConfig.size.y = Screen.height;
            }
        }
        else
        {
            float num2 = videoMode.height * (((float)Screen.height) / ((float)videoMode.width));
            videoBackgroundConfig.size = new QCARRenderer.Vec2I((int)num2, Screen.height);
            if (videoBackgroundConfig.size.x < Screen.width)
            {
                videoBackgroundConfig.size.x = Screen.width;
                videoBackgroundConfig.size.y = (int)(Screen.width * (((float)videoMode.width) / ((float)videoMode.height)));
            }
        }
        QCARRenderer.Instance.SetVideoBackgroundConfig(videoBackgroundConfig);
        int num3 = videoBackgroundConfig.position.x + ((Screen.width - videoBackgroundConfig.size.x) / 2);
        int num4 = videoBackgroundConfig.position.y + ((Screen.height - videoBackgroundConfig.size.y) / 2);

        this.mViewportRect = new Rect((float)num3, (float)num4, (float)videoBackgroundConfig.size.x, (float)videoBackgroundConfig.size.y);
        foreach (IVideoBackgroundEventHandler handler in this.mVideoBgEventHandlers)
        {
            handler.OnVideoBackgroundConfigChanged();
        }
    }
    /// <summary>
    /// Configure the size and position of the video background rendered
    /// natively when QCARManager.DrawVideoBackground is true
    /// </summary>
    public void ConfigureVideoBackground(bool forceReflectionSetting)
    {
        QCARRenderer.VideoBGCfgData config    = QCARRenderer.Instance.GetVideoBackgroundConfig();
        CameraDevice.VideoModeData  videoMode = CameraDevice.Instance.GetVideoMode(CameraDeviceModeSetting);

        VideoBackGroundMirrored = config.reflection == QCARRenderer.VideoBackgroundReflection.ON;

        config.enabled     = 1;
        config.synchronous = (SynchronousVideo ? 1 : 0);
        config.position    = new QCARRenderer.Vec2I(0, 0);
        if (!QCARRuntimeUtilities.IsPlayMode())
        {
            // set the reflection parameter to the configured value (only on device)
            if (forceReflectionSetting)
            {
                config.reflection = MirrorVideoBackground;
            }
        }

        bool isLandscapeViewPort = Screen.width > Screen.height;

        if (QCARRuntimeUtilities.IsPlayMode())
        {
            isLandscapeViewPort = true; //editor only support landscape viewport
        }
        if (isLandscapeViewPort)
        {
            float height = videoMode.height * (Screen.width / (float)
                                               videoMode.width);
            config.size = new QCARRenderer.Vec2I(Screen.width, (int)height);

            if (config.size.y < Screen.height)
            {
                // Correcting rendering background size to handle missmatch
                // between screen and video aspect ratios
                config.size.x = (int)(Screen.height
                                      * (videoMode.width / (float)videoMode.height));
                config.size.y = Screen.height;
            }
        }
        else
        {
            float width = videoMode.height * (Screen.height / (float)
                                              videoMode.width);
            config.size = new QCARRenderer.Vec2I((int)width, Screen.height);

            if (config.size.x < Screen.width)
            {
                // Correcting rendering background size to handle missmatch
                // between screen and video aspect ratios
                config.size.x = Screen.width;
                config.size.y = (int)(Screen.width *
                                      (videoMode.width / (float)videoMode.height));
            }
        }

        QCARRenderer.Instance.SetVideoBackgroundConfig(config);

        int viewportX = config.position.x + (Screen.width - config.size.x) / 2;
        int viewportY = config.position.y + (Screen.height - config.size.y) / 2;

        mViewportRect = new Rect(viewportX, viewportY,
                                 config.size.x, config.size.y);

        foreach (IVideoBackgroundEventHandler handler in mVideoBgEventHandlers)
        {
            handler.OnVideoBackgroundConfigChanged();
        }
    }