예제 #1
0
        }   // end of UIGridModularMenu RefreshTexture()

        public void Render(Camera camera)
        {
            try
            {
                ShaderGlobals.SetValues(effect);
                ShaderGlobals.SetCamera(effect, camera);

                effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"];
                effect.Parameters["DiffuseTexture"].SetValue(diffuse);

                effect.Parameters["WorldMatrix"].SetValue(worldMatrix);
                effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix);

                effect.Parameters["Alpha"].SetValue(1.0f);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(1, 1, 1, 1));
                effect.Parameters["SpecularColor"].SetValue(specularColor);
                effect.Parameters["SpecularPower"].SetValue(specularPower);

                effect.Parameters["NormalMap"].SetValue(normalMap);

                geometry.Render(effect);
            }
            catch
            {
                // This Try/Catch is here since the first frame back from a device reset
                // the call to diffuse fails saying that the rendertarget is
                // still set on the device.  As far as I can tell it's not but I still
                // can't win the argument.
            }
        }   // end of UIGridModularMenu Render()
예제 #2
0
        public void Render()
        {
            ///  render entire pie
            if (Active)
            {
                ShaderGlobals.SetValues(effect);
                ShaderGlobals.SetCamera(effect, camera);

                RenderDisk(rootDisk);
            }
        }
예제 #3
0
            public override void Render(Camera camera)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                HelpOverlay.RefreshTexture();

                RenderTarget2D rt         = UI2D.Shared.RenderTargetDepthStencil1280_720;
                Vector2        screenSize = BokuGame.ScreenSize;
                Vector2        rtSize     = new Vector2(rt.Width, rt.Height);

                if (skipFrames > 0 || shared.waitingForStorage)
                {
                    InGame.Clear(Color.Black);
                    --skipFrames;
                    return;
                }

                shared.liveFeed.FeedSize = shared.liveFeed.ResetScrollBoxSize;
                InGame.SetRenderTarget(rt);

                // Clear the screen & z-buffer.
                InGame.Clear(Color.Black);

                // Apply the background.
                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                Vector2 position = Vector2.Zero;

                quad.Render(shared.backgroundTexture, position, rtSize, @"TexturedNoAlpha");

                Color textColor = new Color(21, 125, 178);

                if (parent.newWorldDialog.Active)
                {
                    // Hide the dialog if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // If options menu is active, render instead of main menu.
                        parent.newWorldDialog.Render(new Vector2(rt.Width, rt.Height));
                    }
                }
                else if (shared.optionsMenu.Active)
                {
                    // Hide the menu if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // If options menu is active, render instead of main menu.
                        shared.optionsMenu.Render();
                    }
                }
                else
                {
                    // Render url
                    SpriteBatch         batch = UI2D.Shared.SpriteBatch;
                    UI2D.Shared.GetFont Font  = UI2D.Shared.GetGameFont24;
                    Vector2             size  = Font().MeasureString(shared.screenUrl);
                    Vector2             pos   = new Vector2(rt.Width / 2 - size.X / 2, 586);
                    batch.Begin();
                    TextHelper.DrawString(Font, shared.screenUrl, pos, textColor);
                    batch.End();
                    shared.urlBox.Set(pos, pos + size);

                    // Hide the menu if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // Render menu using local cameras.
                        ShaderGlobals.SetCamera(shared.camera);
                        shared.menu.WorldMatrix = Matrix.CreateTranslation(0.0f, -0.3f, 0.0f);
                        shared.menu.Render(shared.camera);
                    }

                    // Render Boku.
                    ShaderGlobals.SetCamera(shared.bokuCamera);
                    string oldRig = BokuGame.bokuGame.shaderGlobals.PushLightRig(ShaderGlobals.GreeterRigName);

                    // TODO (****) How to temporarily disable point lights???
                    // Do we really need to?
                    //Luz.SetToEffect(true); // disable scene point lights

                    if (BokuGame.bMarsMode)
                    {
                        shared.boku.Movement.Position = new Vector3(-0.0f, 0.25f, -0.5f);
                        shared.boku.ReScale           = 0.50f;

                        //quad = ScreenSpaceQuad.GetInstance();
                        //float wid=shared.jplTexture.Width/2;
                        //position = new Vector2(1250-(wid), 20);
                        //quad.Render(shared.jplTexture, position, new Vector2(wid, shared.jplTexture.Height/2), @"TexturedRegularAlpha");
                    }
                    else
                    {
                        shared.boku.Movement.Position = new Vector3(0.0f, 0.0f, 0.0f);
                    }
                    fVal += 0.01f;

                    // Be sure to set the right camera so the env map looks correct.
                    ShaderGlobals.SetCamera(shared.bokuCamera);

                    shared.boku.RenderObject.Render(shared.bokuCamera);

                    // TODO (****) How to temporarily disable point lights???
                    //Luz.SetToEffect(false); // re-enable scene point lights
                    BokuGame.bokuGame.shaderGlobals.PopLightRig(oldRig);
                }

                InGame.RestoreRenderTarget();

                InGame.Clear(new Color(20, 20, 20));
                InGame.SetViewportToScreen();

                // Copy the rendered scene to the backbuffer.
                {
                    ScreenWarp.FitRtToScreen(rtSize);

                    quad.Render(rt, ScreenWarp.RenderPosition, ScreenWarp.RenderSize, @"TexturedNoAlpha");
                }

                // Render news feed.
                if (!shared.optionsMenu.Active)
                {
                    shared.liveFeed.Render();
                }

                // Hide overlay if auth UI is active.
                if (!AuthUI.IsModalActive)
                {
                    HelpOverlay.Render();
                }

                // Render text dialogs if being shown by OptionsMenu.
                // TODO (****) Need to get rid of rendering to RTs where possible.
                // TODO (****) Need to split OptionsMenu from MainMenu.
                if (shared.optionsMenu.Active)
                {
                    InGame.inGame.shared.smallTextDisplay.Render();
                    InGame.inGame.shared.scrollableTextDisplay.Render();
                }

                MainMenu.Instance.prevSessionCrashedMessage.Render();
                MainMenu.Instance.noCommunityMessage.Render();
                MainMenu.Instance.noSharingMessage.Render();
            }   // end of Render()
예제 #4
0
        public void PreRender()
        {
            RenderTarget2D rt = Shared.RenderTargetDepthStencil1280_720;

            Vector2 rtSize = new Vector2(rt.Width, rt.Height);

            ScreenWarp.FitRtToScreen(rtSize);

            // Render the scene to our rendertarget.
            InGame.SetRenderTarget(rt);
            InGame.Clear(Color.Transparent);

            // Set up params for rendering UI with this camera.
            ShaderGlobals.SetCamera(camera);

            ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

            SpriteBatch batch = Shared.SpriteBatch;

            var center    = new Vector2(640, 360);
            var dialogMin = center - new Vector2(dialogWidth / 2, dialogHeight / 2);
            var dialogMax = center + new Vector2(dialogWidth / 2, dialogHeight / 2);


            // Top and bottom of dialog.
            var     size = new Vector2(dialogWidth, whiteTop.Height);
            Vector2 pos  = dialogMin;

            quad.Render(whiteTop, new Vector4(0, 0, 0, 1), pos, size, "TexturedRegularAlpha");
            pos += new Vector2(0, dialogHeight - 16);
            quad.Render(whiteBottom, new Vector4(0, 0, 0, 1), pos, size, "TexturedRegularAlpha");

            //dialog center
            size    = new Vector2(dialogWidth, dialogHeight);
            pos     = dialogMin;
            pos.Y  += 16;
            size.Y  = dialogHeight - 32;
            pos.X  += 1; //to match size of top and bottom pieces
            size.X -= 2; //
            quad.Render(new Vector4(0, 0, 0, 1), pos, size);

            //top and bottom highlights
            int highlightMargin = 3;

            pos    = dialogMin + new Vector2(highlightMargin, 2);
            size.X = dialogWidth - 2 * highlightMargin;
            size.Y = 30;
            quad.Render(blackHighlight, new Vector4(1, 1, 1, 0.2f), pos, size, "AdditiveBlendWithAlpha");

            pos    = dialogMin + new Vector2(highlightMargin, dialogHeight - 60);
            size.X = dialogWidth - 2 * highlightMargin;
            size.Y = 30;
            quad.Render(blackHighlight, new Vector4(1, 1, 1, 0.2f), pos, size, "AdditiveBlendWithAlpha");

            batch.Begin();

            //Dialog title.
            TextHelper.DrawString(Shared.GetGameFont20, title, dialogMin + new Vector2(10, 10 + 5), Color.White);

            //Ok and Cancel buttons
            var buttonSize = cancelButton.GetSize();

            pos = dialogMax - buttonSize - new Vector2(10, 10);
            cancelButton.Render(pos);

            buttonSize = okButton.GetSize();
            pos       -= new Vector2(buttonSize.X + 20, 0);
            okButton.Render(pos);

            batch.End();

            // Render text box
            textLineEditor.Render(camera);

            InGame.RestoreRenderTarget();

            InGame.SetViewportToScreen();
        }   // end of Render()