Exemple #1
0
        protected override void Initialize()
        {
            graphics.GraphicsProfile = GraphicsProfile.HiDef;
            UpdateAntiAlias();
            UpdateVSync();
            graphics.ApplyChanges();

            IsMouseVisible = false;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera      = new FirstPersonCamera(this);
            rightCamera = new FirstPersonCamera(this);
            leftCamera  = new FirstPersonCamera(this);
            skycamera   = new FirstPersonCamera(this);

            UpdateEffects();

            for (PlayerIndex i = PlayerIndex.One; i <= PlayerIndex.Four; i++)
            {
                GamePadState state = GamePad.GetState(i);
                if (state.IsConnected)
                {
                    activeGamePad = i;
                    break;
                }
            }

            Samplers.Refresh();
            Samplers.InitRasterizers();

            SwitchDisplayMode();

            base.Initialize();
        }
Exemple #2
0
        public void Render(GraphicsDeviceManager graphics, BasicEffect effect)
        {
            if (indices != null && verts != null)
            {
                if (verts.Count > 0)
                {
                    effect.TextureEnabled = textureEnabled;

                    if (textureEnabled)
                    {
                        if (Game1.textures.ContainsKey(textureName))
                        {
                            effect.Texture = Game1.textures[textureName];
                        }
                        else
                        {
                            //Console.WriteLine("missing texture: " + textureName);
                            effect.Texture = Game1.textures["test"];
                        }
                    }

                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();

                        graphics.GraphicsDevice.DrawUserIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            verts_sealed, 0, verts_sealed.Length,
                            indices, 0, indices.Length / 3,
                            VertexPositionColorTexture.VertexDeclaration
                            );
                    }

                    if (Samplers.EnableWireframe)
                    {
                        effect.TextureEnabled = false;

                        Samplers.SetToDevice(graphics, EngineRasterizer.Wireframe);

                        foreach (var pass in effect.CurrentTechnique.Passes)
                        {
                            pass.Apply();

                            graphics.GraphicsDevice.DrawUserIndexedPrimitives(
                                PrimitiveType.TriangleList,
                                verts_sealed, 0, verts_sealed.Length,
                                indices, 0, indices.Length / 3,
                                VertexPositionColorTexture.VertexDeclaration
                                );
                        }

                        Samplers.SetToDevice(graphics, EngineRasterizer.Default);
                    }
                }
                else
                {
                    Console.WriteLine("Empty QuadList!");
                }
            }
        }
Exemple #3
0
        public void Render(GraphicsDeviceManager graphics, BasicEffect effect)
        {
            Samplers.SetToDevice(graphics, EngineSampler.Default);

            foreach (var ql in normalq)
            {
                ql.Value.Render(graphics, effect);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Animated);

            foreach (var ql in animatedq)
            {
                ql.Value.Render(graphics, effect);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Default);

            if (flagq.ContainsKey(((QuadFlags)(1 << Game1.currentflag)).ToString()))
            {
                flagq[((QuadFlags)(1 << Game1.currentflag)).ToString()].Render(graphics, effect);
            }

            if (!Game1.HideInvisible)
            {
                effect.Alpha = 0.25f;

                if (flagq.ContainsKey("invis"))
                {
                    flagq["invis"].Render(graphics, effect);
                }

                effect.Alpha = 1f;
            }
        }
Exemple #4
0
        public void Draw(GraphicsDeviceManager graphics, BasicEffect effect, AlphaTestEffect alpha)
        {
            Samplers.SetToDevice(graphics, EngineSampler.Default);

            foreach (var ql in normalq)
            {
                ql.Value.Draw(graphics, effect, null);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Animated);

            foreach (var ql in animatedq)
            {
                ql.Value.Draw(graphics, effect, null);
            }

            Samplers.SetToDevice(graphics, EngineSampler.Default);

            graphics.GraphicsDevice.BlendState = BlendState.Additive;

            if (flagq.ContainsKey(((QuadFlags)(1 << Game1.currentflag)).ToString()))
            {
                flagq[((QuadFlags)(1 << Game1.currentflag)).ToString()].Draw(graphics, effect, alpha);
            }

            graphics.GraphicsDevice.BlendState = BlendState.NonPremultiplied;

            foreach (var ql in alphaq)
            {
                ql.Value.Draw(graphics, effect, alpha);
            }

            effect.Alpha = 0.5f;

            if (!Game1.HideWater)
            {
                foreach (var ql in waterq)
                {
                    ql.Value.Draw(graphics, effect, null);
                }
            }

            if (!Game1.HideInvisible)
            {
                if (flagq.ContainsKey("invis"))
                {
                    flagq["invis"].Draw(graphics, effect, null);
                }
            }


            effect.Alpha = 1f;
        }
Exemple #5
0
        protected override void Initialize()
        {
            graphics.PreferMultiSampling            = true;
            graphics.GraphicsProfile                = GraphicsProfile.HiDef;
            graphics.SynchronizeWithVerticalRetrace = true;
            IsFixedTimeStep = true;
            graphics.ApplyChanges();
            graphics.GraphicsDevice.PresentationParameters.MultiSampleCount = 4;


            Samplers.Refresh();

            GoWindowed();

            IsMouseVisible = false;

            effect = new BasicEffect(graphics.GraphicsDevice);
            effect.VertexColorEnabled = true;
            effect.TextureEnabled     = true;
            effect.DiffuseColor       = new Vector3(2f, 2f, 2f);

            instanceEffect = new BasicEffect(graphics.GraphicsDevice);
            instanceEffect.VertexColorEnabled = true;
            instanceEffect.TextureEnabled     = false;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera    = new FirstPersonCamera(this);
            lowcamera = new FirstPersonCamera(this);
            skycamera = new FirstPersonCamera(this);

            DisableLodCamera();

            for (PlayerIndex i = PlayerIndex.One; i <= PlayerIndex.Four; i++)
            {
                GamePadState state = GamePad.GetState(i);
                if (state.IsConnected)
                {
                    activeGamePad = i;
                    break;
                }
            }

            Samplers.InitRasterizers();

            base.Initialize();
        }
Exemple #6
0
        protected override void Initialize()
        {
            eng = new MainEngine(this);

            eng.Settings.onWindowedChanged       += SwitchDisplayMode;
            eng.Settings.onVertexLightingChanged += UpdateEffects;
            eng.Settings.onAntiAliasChanged      += UpdateAntiAlias;
            eng.Settings.onVerticalSyncChanged   += UpdateVSync;

            graphics.GraphicsProfile = GraphicsProfile.HiDef;
            UpdateAntiAlias();
            UpdateVSync();
            graphics.ApplyChanges();

            IsMouseVisible = false;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            UpdateEffects();

            for (PlayerIndex i = PlayerIndex.One; i <= PlayerIndex.Four; i++)
            {
                if (GamePad.GetState(i).IsConnected)
                {
                    activeGamePad = i;
                    break;
                }
            }

            Samplers.Refresh();
            Samplers.InitRasterizers();

            SwitchDisplayMode();

            base.Initialize();
        }
Exemple #7
0
        //public static bool twoSided = false;

        private void DrawLevel()
        {
            if (RenderEnabled)
            {
                //if (loading != null && gameLoaded)
                //{
                //if we have a sky
                if (sky != null)
                {
                    effect.View       = skycamera.ViewMatrix;
                    effect.Projection = skycamera.ProjectionMatrix;

                    effect.DiffuseColor = new Vector3(1, 1, 1);
                    sky.RenderSky(graphics, effect);
                    effect.DiffuseColor = new Vector3(2.0f, 2.0f, 2.0f);
                }

                //clear z buffer
                GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Green, 1, 0);

                //render depending on lod
                if (lodEnabled)
                {
                    effect.View       = lowcamera.ViewMatrix;
                    effect.Projection = lowcamera.ProjectionMatrix;

                    if (show_inst)
                    {
                        Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);
                        foreach (var v in instanced)
                        {
                            v.Render(graphics, instanceEffect, lowcamera);
                        }
                    }

                    if (show_paths)
                    {
                        Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);
                        foreach (var v in paths)
                        {
                            v.Render(graphics, instanceEffect, lowcamera);
                        }
                    }

                    Samplers.SetToDevice(graphics, EngineRasterizer.Default);

                    foreach (MGLevel qb in quads_low)
                    {
                        qb.Render(graphics, effect);
                    }

                    foreach (Kart k in karts)
                    {
                        k.Render(graphics, instanceEffect, lowcamera);
                    }
                }
                else
                {
                    if (show_inst)
                    {
                        Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);
                        foreach (var v in instanced)
                        {
                            v.Render(graphics, instanceEffect, camera);
                        }
                    }

                    if (show_paths)
                    {
                        Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);
                        foreach (var v in paths)
                        {
                            v.Render(graphics, instanceEffect, camera);
                        }
                    }

                    Samplers.SetToDevice(graphics, EngineRasterizer.Default);

                    effect.View       = camera.ViewMatrix;
                    effect.Projection = camera.ProjectionMatrix;

                    foreach (MGLevel qb in levels)
                    {
                        qb.Render(graphics, effect);
                    }

                    foreach (Kart k in karts)
                    {
                        k.Render(graphics, instanceEffect, camera);
                    }
                }
            }
        }
Exemple #8
0
        protected override void Update(GameTime gameTime)
        {
            if (loading == null)
            {
                LoadGame();
            }

            newstate = GamePad.GetState(activeGamePad);
            newkb    = Keyboard.GetState();


            foreach (Kart k in karts)
            {
                k.Update(gameTime);
            }

            //x += 0.01f ;
            //if (x > Math.PI * 2)
            //    x = 0;
            //camera.SetRotation(x, y);
            //Console.WriteLine(x);

            if (newstate.Buttons.Start == ButtonState.Pressed && newstate.Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.RightAlt) && Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                if (graphics.IsFullScreen)
                {
                    GoWindowed();
                }
                else
                {
                    GoFullScreen();
                }
            }


            if (Keyboard.GetState().IsKeyDown(Keys.OemMinus))
            {
                float x = camera.ViewAngle;
                x--;
                if (x < 20)
                {
                    x = 20;
                }

                camera.ViewAngle    = x;
                lowcamera.ViewAngle = x;
                skycamera.ViewAngle = x;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.OemPlus))
            {
                float x = camera.ViewAngle;
                x++;
                if (x > 150)
                {
                    x = 150;
                }

                camera.ViewAngle    = x;
                lowcamera.ViewAngle = x;
                skycamera.ViewAngle = x;
            }

            if ((newstate.Buttons.Start == ButtonState.Pressed && oldstate.Buttons.Start != newstate.Buttons.Start) ||
                (newkb.IsKeyDown(Keys.Escape) && newkb.IsKeyDown(Keys.Escape) != oldkb.IsKeyDown(Keys.Escape)))
            {
                InMenu = !InMenu;
            }

            if (InMenu)
            {
                menu.Update(oldstate, newstate, oldkb, newkb);

                //currentflag = menu.items.Find(x => x.Title == "current flag: {0}").rangeval;

                if (menu.Exec)
                {
                    switch (menu.SelectedItem.Action)
                    {
                    case "close":
                        InMenu = false;
                        break;

                    case "load":
                        LoadGame();
                        InMenu = false;
                        break;

                    case "link":
                        menu.SetMenu(font);
                        break;

                    case "toggle":
                        switch (menu.SelectedItem.Param)
                        {
                        case "inst": show_inst = !show_inst; break;

                        case "paths": show_paths = !show_paths; break;

                        case "lod": lodEnabled = !lodEnabled; if (lodEnabled)
                            {
                                EnableLodCamera();
                            }
                            else
                            {
                                DisableLodCamera();
                            } break;

                        case "antialias": graphics.PreferMultiSampling = !graphics.PreferMultiSampling; break;

                        case "invis": HideInvisible = !HideInvisible; break;

                        case "filter": Samplers.EnableBilinear = !Samplers.EnableBilinear; Samplers.Refresh(); break;

                        case "wire": Samplers.EnableWireframe = !Samplers.EnableWireframe; break;

                        case "window": if (graphics.IsFullScreen)
                            {
                                GoWindowed();
                            }
                            else
                            {
                                GoFullScreen();
                            } break;

                        case "lockfps":
                            lock_fps = !lock_fps;
                            graphics.SynchronizeWithVerticalRetrace = lock_fps;
                            IsFixedTimeStep = lock_fps;
                            graphics.ApplyChanges();
                            break;

                        default: Console.WriteLine("unimplemented toggle: " + menu.SelectedItem.Param); break;
                        }
                        break;

                    case "exit":
                        Exit();
                        break;
                    }

                    menu.Exec = !menu.Exec;
                }

                if (newstate.Buttons.B == ButtonState.Pressed && newstate.Buttons.B != oldstate.Buttons.B)
                {
                    bool togglemenu = true;

                    foreach (MenuItem m in menu.items)
                    {
                        Console.WriteLine(m.Action + " " + m.Title);
                        if (m.Action == "link" && m.Title == "BACK")
                        {
                            menu.SetMenu(font, m.Param);
                            togglemenu = false;
                        }
                    }

                    if (togglemenu)
                    {
                        InMenu = !InMenu;
                    }
                }
            }
            else
            {
                foreach (MGLevel mg in levels)
                {
                    mg.Update(gameTime);
                }

                if (ControlsEnabled)
                {
                    UpdateCameras(gameTime);
                }
            }

            oldstate = newstate;
            oldkb    = newkb;

            base.Update(gameTime);
        }
Exemple #9
0
        //public static bool twoSided = false;

        private void DrawLevel(FirstPersonCamera cam = null)
        {
            if (RenderEnabled)
            {
                //if (loading != null && gameLoaded)
                //{
                //if we have a sky and sky is enabled
                if (sky != null && settings.Sky)
                {
                    effect.View       = skycamera.ViewMatrix;
                    effect.Projection = skycamera.ProjectionMatrix;

                    effect.DiffuseColor /= 2;
                    sky.DrawSky(graphics, effect, null);
                    effect.DiffuseColor *= 2;

                    alphaTestEffect.DiffuseColor = effect.DiffuseColor;

                    //clear z buffer
                    GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Green, 1, 0);
                }

                effect.View       = (cam != null ? cam.ViewMatrix : camera.ViewMatrix);
                effect.Projection = (cam != null ? cam.ProjectionMatrix : camera.ProjectionMatrix);

                alphaTestEffect.View       = effect.View;
                alphaTestEffect.Projection = effect.Projection;


                if (settings.Models || settings.BotsPath)
                {
                    Samplers.SetToDevice(graphics, EngineRasterizer.DoubleSided);

                    if (settings.Models)
                    {
                        foreach (var v in instanced)
                        {
                            v.Draw(graphics, instanceEffect, null, (cam != null ? cam : camera));
                        }

                        //render karts
                        foreach (Kart k in karts)
                        {
                            k.Draw(graphics, instanceEffect, null, (cam != null ? cam : camera));
                        }
                    }

                    if (settings.BotsPath)
                    {
                        foreach (var v in paths)
                        {
                            v.Draw(graphics, instanceEffect, null, (cam != null ? cam : camera));
                        }
                    }

                    Samplers.SetToDevice(graphics, EngineRasterizer.Default);
                }

                Samplers.SetToDevice(graphics, EngineRasterizer.Default);

                //render depending on lod
                foreach (MGLevel qb in (settings.UseLowLod ? MeshLow : MeshHigh))
                {
                    qb.Draw(graphics, effect, alphaTestEffect);
                }


                if (settings.VisData)
                {
                    //GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Green, 1, 0);

                    //texture enabled makes visdata invisible
                    effect.TextureEnabled = false;

                    foreach (var x in bbox)
                    {
                        foreach (var pass in effect.CurrentTechnique.Passes)
                        {
                            pass.Apply();
                            graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, x, 0, x.Length / 2);
                        }
                    }

                    if (settings.VisDataLeaves)
                    {
                        foreach (var x in bbox2)
                        {
                            foreach (var pass in effect.CurrentTechnique.Passes)
                            {
                                pass.Apply();
                                graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, x, 0, x.Length / 2);
                            }
                        }
                    }
                }
            }
        }
Exemple #10
0
        protected override void Update(GameTime gameTime)
        {
            if (loading == null)
            {
                LoadGame();
            }

            //x += 0.01f ;
            //if (x > Math.PI * 2)
            //    x = 0;
            //camera.SetRotation(x, y);
            //Console.WriteLine(x);

            if (IsActive)
            {
                newstate = GamePad.GetState(activeGamePad);
                newkb    = Keyboard.GetState();

                foreach (Kart k in karts)
                {
                    k.Update(gameTime);
                }

                if (newstate.Buttons.Start == ButtonState.Pressed && newstate.Buttons.Back == ButtonState.Pressed)
                {
                    Exit();
                }

                if (settings.StereoPair)
                {
                    if (newstate.IsButtonDown(Buttons.RightShoulder))
                    {
                        settings.StereoPairSeparation += 5;
                    }

                    if (newstate.IsButtonDown(Buttons.LeftShoulder))
                    {
                        settings.StereoPairSeparation -= 5;
                    }

                    if (settings.StereoPairSeparation < 0)
                    {
                        settings.StereoPairSeparation = 0;
                    }

                    if (newstate.IsButtonDown(Buttons.RightShoulder) && newstate.IsButtonDown(Buttons.LeftShoulder))
                    {
                        settings.StereoPairSeparation = 130;
                    }
                }

                if ((newkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt)) && !(oldkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt)))
                {
                    settings.Windowed = !settings.Windowed;
                }


                if (Keyboard.GetState().IsKeyDown(Keys.OemMinus))
                {
                    settings.FieldOfView--;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.OemPlus))
                {
                    settings.FieldOfView++;
                }

                if ((newstate.Buttons.Start == ButtonState.Pressed && oldstate.Buttons.Start != newstate.Buttons.Start) ||
                    (newkb.IsKeyDown(Keys.Escape) && newkb.IsKeyDown(Keys.Escape) != oldkb.IsKeyDown(Keys.Escape)))
                {
                    InMenu = !InMenu;
                }

                if (InMenu)
                {
                    menu.Update(oldstate, newstate, oldkb, newkb);

                    //currentflag = menu.items.Find(x => x.Title == "current flag: {0}").rangeval;

                    if (menu.Exec)
                    {
                        switch (menu.SelectedItem.Action)
                        {
                        case "close":
                            InMenu = false;
                            break;

                        case "load":
                            LoadGame();
                            InMenu = false;
                            break;

                        case "loadbig":
                            LoadLevelFromBig(menu.SelectedItem.Value);    //, 0, 2);
                            break;

                        case "loadbigadv":
                            LoadLevelFromBig(menu.SelectedItem.Value, 0, 3);
                            break;

                        case "tod_day":
                            TimeOfDay = new Vector3(2f);
                            UpdateEffects();
                            break;

                        case "tod_evening":
                            TimeOfDay = new Vector3(1.7f, 1.4f, 0.7f);
                            UpdateEffects();
                            break;

                        case "tod_night":
                            TimeOfDay = new Vector3(0.5f, 0.7f, 1.7f);
                            UpdateEffects();
                            break;

                        case "link":
                            menu.SetMenu(font);
                            break;

                        case "toggle":
                            switch (menu.SelectedItem.Param)
                            {
                            case "inst": settings.Models = !settings.Models; break;

                            case "paths": settings.BotsPath = !settings.BotsPath; break;

                            case "lod": settings.UseLowLod = !settings.UseLowLod; break;

                            case "antialias": settings.AntiAlias = !settings.AntiAlias; break;

                            case "invis": HideInvisible = !HideInvisible; break;

                            case "water": HideWater = !HideWater; break;

                            case "campos": settings.ShowCamPos = !settings.ShowCamPos; break;

                            case "visbox": settings.VisData = !settings.VisData; break;

                            case "visboxleaf": settings.VisDataLeaves = !settings.VisDataLeaves; break;

                            case "filter": Samplers.EnableFiltering = !Samplers.EnableFiltering; Samplers.Refresh(); break;

                            case "wire": Samplers.EnableWireframe = !Samplers.EnableWireframe; break;

                            case "genmips": settings.GenerateMips = !settings.GenerateMips; break;

                            case "window": settings.Windowed = !settings.Windowed; break;

                            case "vcolor": settings.VertexLighting = !settings.VertexLighting; break;

                            case "stereo": settings.StereoPair = !settings.StereoPair; break;

                            case "sky": settings.Sky = !settings.Sky; break;

                            case "vsync": settings.VerticalSync = !settings.VerticalSync; break;

                            default: Console.WriteLine("unimplemented toggle: " + menu.SelectedItem.Param); break;
                            }
                            break;

                        case "exit":
                            Exit();
                            break;
                        }

                        menu.Exec = !menu.Exec;
                    }

                    if (newstate.Buttons.B == ButtonState.Pressed && newstate.Buttons.B != oldstate.Buttons.B)
                    {
                        bool togglemenu = true;

                        foreach (MenuItem m in menu.items)
                        {
                            Console.WriteLine(m.Action + " " + m.Title);
                            if (m.Action == "link" && m.Title == "BACK")
                            {
                                menu.SetMenu(font, m.Param);
                                togglemenu = false;
                            }
                        }

                        if (togglemenu)
                        {
                            InMenu = !InMenu;
                        }
                    }
                }
                else
                {
                    foreach (MGLevel mg in MeshHigh)
                    {
                        mg.Update(gameTime);
                    }

                    if (ControlsEnabled)
                    {
                        UpdateCameras(gameTime);
                    }
                }

                foreach (InstancedModel im in instanced)
                {
                    im.Update(gameTime);
                }

                foreach (InstancedModel im in paths)
                {
                    im.Update(gameTime);
                }

                oldms = newms;
                newms = Mouse.GetState();

                oldstate = newstate;
                oldkb    = newkb;
            }

            base.Update(gameTime);
        }
Exemple #11
0
        protected override void Update(GameTime gameTime)
        {
            Window.Title = $"ctrviewer [{Math.Round(1000.0f / gameTime.ElapsedGameTime.TotalMilliseconds)} FPS]";

            //if (loading == null)
            //    LoadGame();

            //x += 0.01f ;
            //if (x > Math.PI * 2)
            //    x = 0;
            //camera.SetRotation(x, y);
            //Console.WriteLine(x);

            oldgs = newgs;
            oldkb = newkb;
            oldms = newms;

            newms = Mouse.GetState();
            newgs = GamePad.GetState(activeGamePad);
            newkb = Keyboard.GetState();

            if (IsActive)
            {
                newmenu.Update(gameTime, new Point(newms.X, newms.Y));

                foreach (Kart k in karts)
                {
                    k.Update(gameTime);
                }

                if (newgs.Buttons.Start == ButtonState.Pressed && newgs.Buttons.Back == ButtonState.Pressed)
                {
                    Exit();
                }

                if (eng.Settings.StereoPair)
                {
                    if (newgs.IsButtonDown(Buttons.RightShoulder))
                    {
                        eng.Settings.StereoPairSeparation += 5;
                    }

                    if (newgs.IsButtonDown(Buttons.LeftShoulder))
                    {
                        eng.Settings.StereoPairSeparation -= 5;
                    }

                    if (eng.Settings.StereoPairSeparation < 0)
                    {
                        eng.Settings.StereoPairSeparation = 0;
                    }

                    if (newgs.IsButtonDown(Buttons.RightShoulder) && newgs.IsButtonDown(Buttons.LeftShoulder))
                    {
                        eng.Settings.StereoPairSeparation = 130;
                    }
                }

                if ((newkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt)) && !(oldkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt)))
                {
                    eng.Settings.Windowed = !eng.Settings.Windowed;
                }

                if (
                    (newkb.IsKeyDown(Keys.OemTilde) && !oldkb.IsKeyDown(Keys.OemTilde)) ||
                    (newgs.IsButtonDown(Buttons.Back) && !oldgs.IsButtonDown(Buttons.Back))
                    )
                {
                    eng.Settings.ShowConsole = !eng.Settings.ShowConsole;
                }

                if (newkb.IsKeyDown(Keys.OemMinus))
                {
                    eng.Settings.FieldOfView--;
                }
                if (newkb.IsKeyDown(Keys.OemPlus))
                {
                    eng.Settings.FieldOfView++;
                }

                if ((newgs.Buttons.Start == ButtonState.Pressed && oldgs.Buttons.Start != newgs.Buttons.Start) ||
                    (newkb.IsKeyDown(Keys.Escape) && newkb.IsKeyDown(Keys.Escape) != oldkb.IsKeyDown(Keys.Escape)))
                {
                    menu.Visible = !menu.Visible;
                }

                if (menu.Visible)
                {
                    menu.Update(oldgs, newgs, oldkb, newkb);

                    //currentflag = menu.items.Find(x => x.Title == "current flag: {0}").rangeval;

                    if (menu.Exec)
                    {
                        switch (menu.SelectedItem.Action)
                        {
                        case "close":
                            menu.Visible = false;
                            break;

                        //case "load":
                        //    LoadGame();
                        //    InMenu = false;
                        //    break;
                        case "loadbig":
                            LoadLevelsFromBig(menu.SelectedItem.Value);    //, 0, 2);
                            break;

                        case "loadbigadv":
                            LoadLevelsFromBig(200, 203, 206, 209, 212);
                            break;

                        case "tod_day":
                            SetTimeOfDay(PreferredTimeOfDay.Day);
                            break;

                        case "tod_evening":
                            SetTimeOfDay(PreferredTimeOfDay.Evening);
                            break;

                        case "tod_night":
                            SetTimeOfDay(PreferredTimeOfDay.Night);
                            break;

                        case "link":
                            menu.SetMenu(font);
                            break;

                        case "setleveltype":
                            levelType = (LevelType)menu.SelectedItem.Value;
                            break;

                        case "toggle":
                            switch (menu.SelectedItem.Param)
                            {
                            case "inst": eng.Settings.ShowModels = !eng.Settings.ShowModels; break;

                            case "paths": eng.Settings.ShowBotsPath = !eng.Settings.ShowBotsPath; break;

                            case "lod": eng.Settings.UseLowLod = !eng.Settings.UseLowLod; break;

                            case "antialias": eng.Settings.AntiAlias = !eng.Settings.AntiAlias; break;

                            case "invis": HideInvisible = !HideInvisible; break;

                            case "water": HideWater = !HideWater; break;

                            case "console": eng.Settings.ShowConsole = !eng.Settings.ShowConsole; break;

                            case "campos": eng.Settings.ShowCamPos = !eng.Settings.ShowCamPos; break;

                            case "visbox": eng.Settings.VisData = !eng.Settings.VisData; break;

                            case "nocull": ForceNoCulling = !ForceNoCulling; break;

                            case "visboxleaf": eng.Settings.VisDataLeaves = !eng.Settings.VisDataLeaves; break;

                            case "filter": Samplers.EnableFiltering = !Samplers.EnableFiltering; Samplers.Refresh(); break;

                            case "wire": Samplers.EnableWireframe = !Samplers.EnableWireframe; break;

                            case "genmips": eng.Settings.GenerateMips = !eng.Settings.GenerateMips; break;

                            case "window": eng.Settings.Windowed = !eng.Settings.Windowed; break;

                            case "vcolor": eng.Settings.VertexLighting = !eng.Settings.VertexLighting; break;

                            case "stereo": eng.Settings.StereoPair = !eng.Settings.StereoPair; break;

                            case "sky": eng.Settings.ShowSky = !eng.Settings.ShowSky; break;

                            case "vsync": eng.Settings.VerticalSync = !eng.Settings.VerticalSync; break;

                            default: GameConsole.Write("unimplemented toggle: " + menu.SelectedItem.Param); break;
                            }
                            break;

                        case "exit":
                            Exit();
                            break;
                        }

                        menu.Exec = !menu.Exec;
                    }

                    if ((newgs.Buttons.B == ButtonState.Pressed && newgs.Buttons.B != oldgs.Buttons.B) ||
                        (newgs.Buttons.Y == ButtonState.Pressed && newgs.Buttons.Y != oldgs.Buttons.Y))
                    {
                        bool togglemenu = true;

                        foreach (MenuItem m in menu.items)
                        {
                            if (m.Action == "link" && m.Title == "BACK")
                            {
                                menu.SetMenu(font, m.Param);
                                togglemenu = false;
                            }
                        }

                        if (togglemenu)
                        {
                            menu.Visible = !menu.Visible;
                        }
                    }
                }
                else
                {
                    foreach (var mg in eng.MeshHigh)
                    {
                        mg.Update(gameTime);
                    }

                    foreach (var mg in eng.MeshLow)
                    {
                        mg.Update(gameTime);
                    }

                    foreach (var im in eng.instanced)
                    {
                        im.Update(gameTime);
                    }

                    foreach (var im in eng.paths)
                    {
                        im.Update(gameTime);
                    }

                    if (ControlsEnabled)
                    {
                        UpdateCameras(gameTime);
                    }
                }
            }

            base.Update(gameTime);
        }