public FirstPersonCameraCommandBindingManager(ICommandManager commandManager, InputCommandBinder inputCommandBinder, FirstPersonStand stand, Game game)
            : base(commandManager, inputCommandBinder, stand, game)
        {
            commandManager.Add(TURN_LEFT, () => stand.Yaw(-FrameTime));
            commandManager.Add(TURN_RIGHT, () => stand.Yaw(FrameTime));
            commandManager.Add(TURN_UP, () => stand.Pitch(-FrameTime));
            commandManager.Add(TURN_DOWN, () => stand.Pitch(FrameTime));
            commandManager.Add(ROLL_LEFT, () => stand.Roll(FrameTime));
            commandManager.Add(ROLL_RIGHT, () => stand.Roll(-FrameTime));

            inputCommandBinder.Bind(Button.J, TURN_LEFT);
            inputCommandBinder.Bind(Button.L, TURN_RIGHT);
            inputCommandBinder.Bind(Button.I, TURN_UP);
            inputCommandBinder.Bind(Button.K, TURN_DOWN);
            inputCommandBinder.Bind(Button.U, ROLL_LEFT);
            inputCommandBinder.Bind(Button.O, ROLL_RIGHT);
        }
Пример #2
0
        protected override void Initialize()
        {
            var sphereMesh = new Sphere(Window.Device);

            mSphereMaterial = new Material("normal_as_color.fx", Window.Device);
            mSphereBinding = new MeshMaterialBinding(Window.Device, mSphereMaterial, sphereMesh);

            mKeyboard = new Keyboard();

            var stand = new FirstPersonStand { Position = new Vector3(0, 0, 3), Direction = -Vector3.ZAxis };
            var lens = new PerspectiveProjectionLens();
            mCamera = new Camera(stand, lens);

            var commands = new CommandManager();

            mInputCommandBinder = new InputCommandBinder(commands, mKeyboard);

            mCameraCommandBindingManager = new FirstPersonCameraCommandBindingManager(commands, mInputCommandBinder, stand, this);
        }
Пример #3
0
        protected override void Initialize()
        {
            var quadMesh = new Quad(Window.Device);
            var triangleMesh = new Triangle(Window.Device);
            var cubeMesh = new Cube(Window.Device);
            var sphereMesh = new Sphere(Window.Device);

            mMaterial = new Material("shader.fx", Window.Device);
            mQuadBinding = new MeshMaterialBinding(Window.Device, mMaterial, quadMesh);
            mTriangleBinding = new MeshMaterialBinding(Window.Device, mMaterial, triangleMesh);
            mCubeBinding = new MeshMaterialBinding(Window.Device, mMaterial, cubeMesh);
            mSphereBinding = new MeshMaterialBinding(Window.Device, mMaterial, sphereMesh);

            mKeyboard = new Keyboard();

            var stand = new FirstPersonStand { Position = new Vector3(0, 0, 3), Direction = -Vector3.ZAxis };
            var lens = new PerspectiveProjectionLens();
            mCamera = new Camera(stand, lens);

            var commands = new CommandManager();
            commands.Add(ESCAPE, Exit);
            commands.Add(TAKE_SCREENSHOT, Window.TakeScreenshot);
            commands.Add(TURN_LEFT, () => stand.Yaw(-Frametime));
            commands.Add(TURN_RIGHT, () => stand.Yaw(Frametime));
            commands.Add(TURN_UP, () => stand.Pitch(-Frametime));
            commands.Add(TURN_DOWN, () => stand.Pitch(Frametime));
            commands.Add(ROLL_LEFT, () => stand.Roll(Frametime));
            commands.Add(ROLL_RIGHT, () => stand.Roll(-Frametime));

            mInputCommandBinder = new InputCommandBinder(commands, mKeyboard);
            mInputCommandBinder.Bind(Button.Escape, ESCAPE);
            mInputCommandBinder.Bind(Button.PrintScreen, TAKE_SCREENSHOT);
            mInputCommandBinder.Bind(Button.J, TURN_LEFT);
            mInputCommandBinder.Bind(Button.L, TURN_RIGHT);
            mInputCommandBinder.Bind(Button.I, TURN_UP);
            mInputCommandBinder.Bind(Button.K, TURN_DOWN);
            mInputCommandBinder.Bind(Button.U, ROLL_LEFT);
            mInputCommandBinder.Bind(Button.O, ROLL_RIGHT);

            mCameraCommandManager = new CameraCommandManager(commands, mInputCommandBinder, stand);

            mVector3Random = new Vector3RandomGenerator(new Vector3(-2, -1, -2), new Vector3(2, 1, 2), 1);
            mCubePositions = new[]
            {
                mVector3Random.Next(),
                mVector3Random.Next(),
                mVector3Random.Next()
            };

            mTrianglePositions = new[]
            {
                mVector3Random.Next(),
                mVector3Random.Next(),
                mVector3Random.Next()
            };

            mQuadPositions = new[]
            {
                mVector3Random.Next(),
                mVector3Random.Next(),
                mVector3Random.Next()
            };
        }