コード例 #1
0
ファイル: Game.cs プロジェクト: xphillyx/XNALara
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            CheckContentDirectory();

            textureManager = new TextureManager(this);

            camera = new CameraTurnTable(this.GraphicsDevice, this.Window);
            ResetCamera(camera);

            ModelLoader modelLoader = new ModelLoader(this);

            boneSelector = new BoneSelector(this);

            ResetLights();

            ForceShadersV3 = LightingParamsDialog.DefaultForceShadersV3;

            ResetPostProcessParams();

            renderer = new Renderer(this);
            renderer.Init();

            hud = new HUD(this);

            controlGUI = new ControlGUI(this);
            if (splash == null)
            {
                controlGUI.TopMost = controlGUI.PreferredAlwaysOnTop;
            }
            controlGUI.Show();
        }
コード例 #2
0
        public UndoHistory(ControlGUI gui)
        {
            this.gui = gui;

            isEnabled = true;
            history   = new LinkedList <UndoHistoryState>();
            lastState = null;

            stateInterrupt = new UndoHistoryStateInterrupt();
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: xphillyx/XNALara
        private void ProcessKeyboard(float deltaMilliseconds)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            KeyboardEventHandler.ProcessKeyboardState(keyboardState);

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.NumPad0))
            {
                Armature.Bone selectedBone = controlGUI.SelectedBone;
                if (selectedBone != null)
                {
                    controlGUI.HandleBoneRotationXChanged(selectedBone, 0);
                    controlGUI.HandleBoneRotationYChanged(selectedBone, 0);
                    controlGUI.HandleBoneRotationZChanged(selectedBone, 0);
                }
            }

            bool ctrlKeyPressed = keyboardState.IsKeyDown(Keys.LeftControl) ||
                                  keyboardState.IsKeyDown(Keys.RightControl);
            bool shiftKeyPressed = keyboardState.IsKeyDown(Keys.LeftShift) ||
                                   keyboardState.IsKeyDown(Keys.RightShift);
            bool altKeyPressed = keyboardState.IsKeyDown(Keys.LeftAlt) ||
                                 keyboardState.IsKeyDown(Keys.RightAlt);

            if (keyboardState.IsKeyDown(Keys.Up) ||
                keyboardState.IsKeyDown(Keys.Down) ||
                keyboardState.IsKeyDown(Keys.Left) ||
                keyboardState.IsKeyDown(Keys.Right))
            {
                Item selectedItem = controlGUI.SelectedItem;
                if (selectedItem != null)
                {
                    Armature armature = selectedItem.Model.Armature;
                    float    speed    = shiftKeyPressed ? 3e-3f : 1e-3f;
                    if (!altKeyPressed)
                    {
                        Vector3 dir = Vector3.Zero;
                        if (keyboardState.IsKeyDown(Keys.Up))
                        {
                            dir += DetermineMovementVector(Keys.Up);
                        }
                        if (keyboardState.IsKeyDown(Keys.Down))
                        {
                            dir += DetermineMovementVector(Keys.Down);
                        }
                        if (keyboardState.IsKeyDown(Keys.Left))
                        {
                            dir += DetermineMovementVector(Keys.Left);
                        }
                        if (keyboardState.IsKeyDown(Keys.Right))
                        {
                            dir += DetermineMovementVector(Keys.Right);
                        }
                        armature.WorldTranslation += dir * speed;
                        controlGUI.HandlePositionChanged(armature.WorldTranslation);
                    }
                    else
                    {
                        float dir = 0;
                        if (keyboardState.IsKeyDown(Keys.Up))
                        {
                            dir += 1;
                        }
                        if (keyboardState.IsKeyDown(Keys.Down))
                        {
                            dir -= 1;
                        }
                        float height = armature.WorldTranslation.Y;
                        height += dir * speed;
                        controlGUI.HandleHeightChanged(height);
                    }
                }
            }

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.F2))
            {
                cameraSavedState = camera.CameraState;
                hud.Message      = "camera state saved";
            }

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.F3))
            {
                if (cameraSavedState != null)
                {
                    camera.CameraState = cameraSavedState;
                    hud.Message        = "camera state loaded";
                }
            }

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.F5))
            {
                controlGUI.QuickSaveImage();
            }

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.F8))
            {
                controlGUI.ReloadTextures();
            }

            if (KeyboardEventHandler.HasKeyBeenPressed(Keys.F12))
            {
                if (controlGUI.IsDisposed)
                {
                    controlGUI = new ControlGUI(this);
                }
                controlGUI.Show();
            }

            if (!controlGUI.IsCameraLocked)
            {
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D1))
                {
                    controlGUI.SetCameraPivot(0);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D2))
                {
                    controlGUI.SetCameraPivot(1);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D3))
                {
                    controlGUI.SetCameraPivot(2);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D4))
                {
                    controlGUI.SetCameraPivot(3);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D5))
                {
                    controlGUI.SetCameraPivot(4);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D6))
                {
                    controlGUI.SetCameraPivot(5);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D7))
                {
                    controlGUI.SetCameraPivot(6);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D8))
                {
                    controlGUI.SetCameraPivot(7);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D9))
                {
                    controlGUI.SetCameraPivot(8);
                }
                if (KeyboardEventHandler.HasKeyBeenPressed(Keys.D0))
                {
                    controlGUI.SetCameraPivot(9);
                }
            }

            if (ctrlKeyPressed && KeyboardEventHandler.HasKeyBeenPressed(Keys.Z) ||
                KeyboardEventHandler.HasKeyBeenPressed(Keys.NumPad5))
            {
                controlGUI.Undo();
            }
        }