Ejemplo n.º 1
0
        internal void RenderToFrameBuffer(FrameBuffer frameBuffer, ref Matrix4 transform, bool useOrthoProjection)
        {
            if (frameBuffer == null)
            {
                throw new ArgumentNullException("frameBuffer");
            }
            if (!frameBuffer.Status)
            {
                throw new ArgumentException("Frame buffer is not renderable.", "frameBuffer");
            }
            UISystem.IsOffScreenRendering = true;
            GraphicsContext graphicsContext      = UISystem.GraphicsContext;
            int             num                  = frameBuffer.Width;
            int             num2                 = frameBuffer.Height;
            Matrix4         viewProjectionMatrix = UISystem.ViewProjectionMatrix;
            Matrix4         transform3D          = this.Transform3D;
            PivotType       pivotType            = this.PivotType;

            this.Transform3D = transform;
            this.PivotType   = PivotType.TopLeft;
            LinkedTree <Widget> parent     = this.linkedTree.Parent;
            LinkedTree <Widget> linkedTree = null;

            if (parent != null)
            {
                linkedTree = this.LinkedTree.NextSibling;
                this.linkedTree.RemoveChild();
            }
            graphicsContext.SetFrameBuffer(frameBuffer);
            graphicsContext.SetColorMask((ColorMask)15);
            UISystem.SetClipRegionFull();
            graphicsContext.SetViewport(0, 0, num, num2);
            graphicsContext.SetClearColor(0f, 0f, 0f, 1f);
            graphicsContext.Clear();
            if (useOrthoProjection)
            {
                float num3 = 100000f;
                float num4 = -100000f;
                UISystem.ViewProjectionMatrix = new Matrix4(2f / (float)num * UISystem.Scale, 0f, 0f, 0f, 0f, -2f / (float)num2 * UISystem.Scale, 0f, 0f, 0f, 0f, -2f / (num3 - num4), 0f, -1f, 1f, (num3 + num4) / (num3 - num4), 1f);
            }
            UISystem.Render(this);
            graphicsContext.Enable((EnableMode)4u, true);
            graphicsContext.SetBlendFuncRgb((BlendFuncMode)0, (BlendFuncFactor)0, (BlendFuncFactor)1);
            graphicsContext.SetBlendFuncAlpha((BlendFuncMode)0, (BlendFuncFactor)9, (BlendFuncFactor)0);
            UISystem.SetClipRegionFull();
            UISprite     uISprite = new UISprite(1);
            UISpriteUnit unit     = uISprite.GetUnit(0);

            unit.SetPosition(-1f, -1f);
            unit.Width  = (float)frameBuffer.Width + 2f;
            unit.Height = (float)frameBuffer.Height + 2f;
            unit.Color  = new UIColor(0f, 0f, 0f, 1f);
            uISprite.Render();
            graphicsContext.SetFrameBuffer(null);
            UISystem.SetClipRegionFull();
            graphicsContext.SetColorMask((ColorMask)7);
            UISystem.ViewProjectionMatrix = viewProjectionMatrix;
            if (linkedTree != null)
            {
                this.linkedTree.InsertChildBefore(linkedTree);
            }
            else if (parent != null)
            {
                parent.AddChildLast(this.linkedTree);
            }
            this.pivotType   = pivotType;
            this.Transform3D = transform3D;
            UISystem.IsOffScreenRendering = false;
        }
Ejemplo n.º 2
0
        protected override void OnStart()
        {
            switch (this.MoveTarget)
            {
            case MoveTarget.NextScene:
            {
                ImageAsset nextSceneRenderedImage = base.GetNextSceneRenderedImage();
                this.nextSprt            = new UISprite(1);
                this.nextSprt.ShaderType = ShaderType.OffscreenTexture;
                this.nextSprt.BlendMode  = BlendMode.Premultiplied;
                this.nextSprt.Image      = nextSceneRenderedImage;
                UISpriteUnit unit = this.nextSprt.GetUnit(0);
                unit.Width  = (float)UISystem.FramebufferWidth;
                unit.Height = (float)UISystem.FramebufferHeight;
                base.TransitionUIElement.AddChildLast(this.nextSprt);
                this.to = 0f;
                switch (this.MoveDirection)
                {
                case FourWayDirection.Up:
                    this.nextSprt.X = 0f;
                    this.nextSprt.Y = (this.from = (float)UISystem.FramebufferHeight);
                    break;

                case FourWayDirection.Down:
                    this.nextSprt.X = 0f;
                    this.nextSprt.Y = (this.from = (float)(-(float)UISystem.FramebufferHeight));
                    break;

                case FourWayDirection.Left:
                    this.nextSprt.X = (this.from = (float)UISystem.FramebufferWidth);
                    this.nextSprt.Y = 0f;
                    break;

                case FourWayDirection.Right:
                    this.nextSprt.X = (this.from = (float)(-(float)UISystem.FramebufferWidth));
                    this.nextSprt.Y = 0f;
                    break;
                }
                break;
            }

            case MoveTarget.CurrentScene:
            {
                ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();
                this.currentSprt            = new UISprite(1);
                this.currentSprt.ShaderType = ShaderType.OffscreenTexture;
                this.currentSprt.BlendMode  = BlendMode.Premultiplied;
                this.currentSprt.Image      = currentSceneRenderedImage;
                UISpriteUnit unit = this.currentSprt.GetUnit(0);
                unit.Width  = (float)UISystem.FramebufferWidth;
                unit.Height = (float)UISystem.FramebufferHeight;
                base.TransitionUIElement.AddChildLast(this.currentSprt);
                this.from = 0f;
                switch (this.MoveDirection)
                {
                case FourWayDirection.Up:
                    this.to = (float)(-(float)UISystem.FramebufferHeight);
                    break;

                case FourWayDirection.Down:
                    this.to = (float)UISystem.FramebufferHeight;
                    break;

                case FourWayDirection.Left:
                    this.to = (float)(-(float)UISystem.FramebufferWidth);
                    break;

                case FourWayDirection.Right:
                    this.to = (float)UISystem.FramebufferWidth;
                    break;
                }
                break;
            }
            }
            switch (this.Interpolator)
            {
            case SlideTransitionInterpolator.Linear:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;

            case SlideTransitionInterpolator.EaseOutQuad:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.EaseOutQuadInterpolator);
                return;

            case SlideTransitionInterpolator.Overshoot:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.OvershootInterpolator);
                return;

            case SlideTransitionInterpolator.Elastic:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.ElasticInterpolator);
                return;

            case SlideTransitionInterpolator.Custom:
                if (this.CustomInterpolator != null)
                {
                    this.interpolatorCallback = this.CustomInterpolator;
                    return;
                }
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;

            default:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;
            }
        }