Example #1
0
        protected override void Initialize()
        {
            mMaterial = new Material("texture.fx", Window.Device);
            mQuadBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Quad(Window.Device, new Vector4(0.6f, 0.6f, 0.6f, 0)));
            mTexture = new Texture(Window.Device, "texture.png");

            mKeyboard = new Keyboard();

            var stand = new OrbitingStand {Radius = 7, Azimuth = Constants.HALF_PI};
            var lens = new PerspectiveProjectionLens();
            mCamera = new Camera(stand, lens);

            var commands = new CommandManager();
            commands.Add(ESCAPE, Exit);
            commands.Add(TAKE_SCREENSHOT, Window.TakeScreenshot);

            mInputCommandBinder = new InputCommandBinder(commands, mKeyboard);
            mInputCommandBinder.Bind(Button.Escape, ESCAPE);
            mInputCommandBinder.Bind(Button.PrintScreen, TAKE_SCREENSHOT);

            commands.Add(MOVE_BACKWARD, () => stand.Radius += Frametime);
            commands.Add(MOVE_FORWARD, () => stand.Radius -= Frametime);
            commands.Add(STRAFE_RIGHT, () => stand.Azimuth -= Frametime);
            commands.Add(STRAFE_LEFT, () => stand.Azimuth += Frametime);
            commands.Add(UP, () => stand.Declination += Frametime);
            commands.Add(DOWN, () => stand.Declination -= Frametime);

            mInputCommandBinder.Bind(Button.W, MOVE_FORWARD);
            mInputCommandBinder.Bind(Button.S, MOVE_BACKWARD);
            mInputCommandBinder.Bind(Button.D, STRAFE_RIGHT);
            mInputCommandBinder.Bind(Button.A, STRAFE_LEFT);
            mInputCommandBinder.Bind(Button.R, UP);
            mInputCommandBinder.Bind(Button.F, DOWN);
        }
Example #2
0
        protected override void Initialize()
        {
            mMaterial = new Material("shader.fx", Window.Device);
            mRefugeeBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Cube(Window.Device, new Vector4(0.8f, 0, 0, 0)));
            mSeekerBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Cube(Window.Device, new Vector4(0, 0, 0.8f, 0)));
            mArriveBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Cube(Window.Device, new Vector4(0, 0.8f, 0, 0)));
            mGroundBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Quad(Window.Device, new Vector4(0.2f, 0.2f, 0.2f, 0)));

            mKeyboard = new Keyboard();

            var stand = new Stand();
            stand.Position = new Vector3(0, 140, 0);
            stand.Direction = -Vector3.YAxis;
            stand.Up = -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);

            mInputCommandBinder = new InputCommandBinder(commands, mKeyboard);
            mInputCommandBinder.Bind(Button.Escape, ESCAPE);
            mInputCommandBinder.Bind(Button.PrintScreen, TAKE_SCREENSHOT);

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

            mSeekSteering = new SeekSteering(mSeekerKinematic, mRefugeeKinematic, 15);
            mArriveSteering = new ArrivingSteering(mArriveKinematic, mRefugeeKinematic, maxAcceleration: 15, slowRadius: 4, satisfactionRadius: 2);
            mRefugeeSteering = new RefugeeSteering(mRefugeeKinematic, mSeekerKinematic, 15);
        }
Example #3
0
        public RocketCommanderGame(int width, int height)
            : base("RocketCommander", width, height)
        {
            this.framework.AssetManager.RegisterAssetFactory(new LayoutFactory());

            // Initialize input system
            this.keyboard = new Keyboard(form.Handle);
            this.mouse = new Mouse(form.Handle);

            this.camera = new FreeCamera(this.mouse, this.keyboard);
            this.roamingRocketScene = new RoamingRocketScene(this);
        }
Example #4
0
        protected override void Initialize()
        {
            mMaterial = new Material("texture.fx", Window.Device);
            mQuadBinding = new MeshMaterialBinding(Window.Device, mMaterial, new Quad(Window.Device, new Vector4(0.6f, 0.6f, 0.6f, 0)));
            mTexture = new Texture(Window.Device, "texture.png");

            mKeyboard = new Keyboard();

            var stand = new OrbitingStand {Radius = 7, Azimuth = Constants.HALF_PI};
            var lens = new PerspectiveProjectionLens();
            mCamera = new Camera(stand, lens);

            var commands = new CommandManager();

            var inputCommandBinder = new InputCommandBinder(commands, mKeyboard);

            mOrbitingCameraCommandBindingManager = new OrbitingCameraCommandBindingManager(commands, inputCommandBinder, stand, this);
        }
        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);
        }
Example #6
0
 public RoamingCamera(Mouse mouse, Keyboard keyboard, Game game)
     : base(mouse, keyboard)
 {
     this.game = game;
 }
Example #7
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()
            };
        }
Example #8
0
 public FreeCamera(Mouse mouse, Keyboard keyboard)
     : base(mouse, keyboard)
 {
     this.lastMousePos = mouse.Position;
 }
Example #9
0
 public GameCamera(Mouse mouse, Keyboard keyboard)
 {
     this.mouse = mouse;
     this.keyboard = keyboard;
 }