private void UpdateShapeAndStereo()
    {
        if (Shape != _LastShape || Stereo != _LastStereo || DisplayMono != _LastDisplayMono)
        {
            Rect destRect = new Rect(0, 0, 1, 1);
            switch (Shape)
            {
            case VideoShape._360:
                // set shape to Equirect
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Equirect;
                break;

            case VideoShape._180:
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Equirect;
                destRect = new Rect(0.25f, 0, 0.5f, 1.0f);
                break;

            case VideoShape.Quad:
            default:
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                break;
            }

            overlay.overrideTextureRectMatrix = true;

            Rect sourceLeft  = new Rect(0, 0, 1, 1);
            Rect sourceRight = new Rect(0, 0, 1, 1);
            switch (Stereo)
            {
            case VideoStereo.LeftRight:
                // set source matrices for left/right
                sourceLeft  = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                sourceRight = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
                break;

            case VideoStereo.TopBottom:
                // set source matrices for top/bottom
                sourceLeft  = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
                sourceRight = new Rect(0.0f, 0.0f, 1.0f, 0.5f);
                break;

            case VideoStereo.BottomTop:
                // set source matrices for top/bottom
                sourceLeft  = new Rect(0.0f, 0.0f, 1.0f, 0.5f);
                sourceRight = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
                break;
            }

            overlay.invertTextureRects = false;
            overlay.SetSrcDestRects(sourceLeft, DisplayMono ? sourceLeft : sourceRight, destRect, destRect);

            _LastDisplayMono = DisplayMono;
            _LastStereo      = Stereo;
            _LastShape       = Shape;
        }
    }
Exemple #2
0
    private void UpdateShapeAndStereo()
    {
        if (AutoDetectStereoLayout)
        {
            if (overlay.isExternalSurface)
            {
                int w = NativeVideoPlayer.VideoWidth;
                int h = NativeVideoPlayer.VideoHeight;
                switch (NativeVideoPlayer.VideoStereoMode)
                {
                case NativeVideoPlayer.StereoMode.Mono:
                    Stereo = VideoStereo.Mono;
                    break;

                case NativeVideoPlayer.StereoMode.LeftRight:
                    Stereo = VideoStereo.LeftRight;
                    break;

                case NativeVideoPlayer.StereoMode.TopBottom:
                    Stereo = VideoStereo.TopBottom;
                    break;

                case NativeVideoPlayer.StereoMode.Unknown:
                    if (w > h)
                    {
                        Stereo = VideoStereo.LeftRight;
                    }
                    else
                    {
                        Stereo = VideoStereo.TopBottom;
                    }
                    break;
                }
            }
        }

        if (Shape != _LastShape || Stereo != _LastStereo || DisplayMono != _LastDisplayMono)
        {
            Rect destRect = new Rect(0, 0, 1, 1);
            switch (Shape)
            {
            case VideoShape._360:
                // set shape to Equirect
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Equirect;
                break;

            case VideoShape._180:
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Equirect;
                destRect = new Rect(0.25f, 0, 0.5f, 1.0f);
                break;

            case VideoShape.Quad:
            default:
                overlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                break;
            }

            overlay.overrideTextureRectMatrix = true;
            overlay.invertTextureRects        = false;

            Rect sourceLeft  = new Rect(0, 0, 1, 1);
            Rect sourceRight = new Rect(0, 0, 1, 1);
            switch (Stereo)
            {
            case VideoStereo.LeftRight:
                // set source matrices for left/right
                sourceLeft  = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                sourceRight = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
                break;

            case VideoStereo.TopBottom:
                // set source matrices for top/bottom
                sourceLeft  = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
                sourceRight = new Rect(0.0f, 0.0f, 1.0f, 0.5f);
                break;

            case VideoStereo.BottomTop:
                // set source matrices for top/bottom
                sourceLeft  = new Rect(0.0f, 0.0f, 1.0f, 0.5f);
                sourceRight = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
                break;
            }

            overlay.SetSrcDestRects(sourceLeft, DisplayMono ? sourceLeft : sourceRight, destRect, destRect);

            _LastDisplayMono = DisplayMono;
            _LastStereo      = Stereo;
            _LastShape       = Shape;
        }
    }