Exemplo n.º 1
0
    private void OnGUI()
    {
        float fps = 0;

        fps = 1.0f / Time.deltaTime;
        GUILayout.Label("FPS: " + (int)fps + "  " + "Camera mode:" + _cameraMode.ToString());
    }
Exemplo n.º 2
0
        public static void SetCameraMode(CameraMode mode)
        {
            Dictionary <string, object> data = new Dictionary <string, object>()
            {
                { "mode", mode.ToString() },
            };

            Program.PostRequestCallback(BaseUrl + "camera_mode", null, JsonConvert.SerializeObject(data), null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the camera logic - switch mode and reads position from the holding human.
        /// </summary>
        /// <param name="gameTime">Game time</param>
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Game.Settings.CameraSwitch) && (gameTime.TotalGameTime - lastChange) > changeTimeOut)
            {
                switch (mode)
                {
                case CameraMode.FirstPersonLook:
                    mode = CameraMode.ThirdPersonLook;
                    break;

                case CameraMode.ThirdPersonLook:
                    mode = CameraMode.FirstPersonLook;
                    break;

                default:
                    mode = CameraMode.FirstPersonLook;
                    break;
                }

                lastChange = gameTime.TotalGameTime;
            }

            switch (mode)
            {
            case CameraMode.FirstPersonLook:
                cameraPosition        = holdingHuman.FirstHeadPosition;
                cameraSubjectPosition = holdingHuman.LookingAt;
                break;

            case CameraMode.ThirdPersonLook:
                cameraPosition        = holdingHuman.ThirdHeadPosition;
                cameraSubjectPosition = holdingHuman.LookingAt;
                break;

            default:
                cameraPosition        = Vector3.Zero;
                cameraSubjectPosition = Vector3.Zero;
                break;
            }

            Debug.Write("Camera mode", mode.ToString());
            Debug.Write("Camera", cameraPosition.ToString());
            Debug.Write("Camera subject", cameraSubjectPosition.ToString());

            ViewMatrix = Matrix.CreateLookAt(cameraPosition, cameraSubjectPosition, Vector3.Up);


            base.Update(gameTime);
        }
Exemplo n.º 4
0
    private void Apply()
    {
        if (interiorObjects == null)
        {
            interiorObjects = GameObject.FindGameObjectsWithTag("Interior");
        }
        if (exteriorObjects == null)
        {
            exteriorObjects = GameObject.FindGameObjectsWithTag("Exterior");
        }

        if (mode == CameraMode.INTERIOR)
        {
            interiorCamera.enabled = interiorAudioListener.enabled = true;
            foreach (var obj in interiorObjects)
            {
                obj.SetActive(true);
            }
            exteriorCamera.enabled = exteriorAudioListener.enabled = false;
            foreach (var obj in exteriorObjects)
            {
                obj.SetActive(false);
            }
        }
        else
        {
            exteriorCamera.enabled = exteriorAudioListener.enabled = true;
            foreach (var obj in exteriorObjects)
            {
                obj.SetActive(true);
            }
            interiorCamera.enabled = interiorAudioListener.enabled = false;
            foreach (var obj in interiorObjects)
            {
                obj.SetActive(false);
            }
        }
        if (modeText != null)
        {
            modeText.text = mode.ToString();
        }
    }
Exemplo n.º 5
0
    protected override void FrameMove()
    {
        int fps = (int)framePerSecond;

        debugText  = "FPS:  " + fps.ToString() + "\r\n";
        debugText += "ShipLocation:\r\n" + playerShip.Location.ToString();

        debugText += "CameraMode:  " + cameraMode.ToString() + "\r\n";
        debugText += "Use the mouse to rotate your ship, and W  or the \r\n" +
                     "up arrow to thrust forward.  The C key changes the camera views.  F5-F10 for sounds \r\n\r\n";
        ProcessInput();
        MouseControlValues v = mouseInput.Values;

        if (v.FireButtonPushed)
        {
            playerShip.Shoot();
        }

        float yawAmount   = mouseLoc.X - screenCenter.X;
        float pitchAmount = mouseLoc.Y - screenCenter.Y;

        playerShip.YawPitchRoll(yawAmount, pitchAmount, elapsedTime);
        playerShip.SetThrust(v.ThrustButtonPushed | kbThrust, elapsedTime);
        playerShip.UpdatePosition(elapsedTime);

        /*Here we set up the view matrix and space dome location.  The space dome moves but not rotates with the player
         * and is alway drawn first, so it looks like it is infinitely distant.
         *
         * In chase mode, the chaseMatrix determines the offset from the ship.  If you want to move our viewpoint
         * back from the ship more, increase the negative z value.
         *
         * The fixed mode camera sits at the origin and always tracks the player ship.  Very hard to control from
         * this viewpoint, but cool to watch.
         */

        Vector3 spaceSphereLocation = new Vector3(0, 0, 0);

        switch (cameraMode)
        {
        case CameraMode.ChaseMode: {
            Matrix chaseMatrix = Matrix.Translation(0, 6, -14);
            chaseMatrix        *= playerShip.Position.WorldMatrix;
            viewMatrix          = Matrix.Invert(chaseMatrix);
            spaceSphereLocation = playerShip.Position.Location;
            break;
        }

        case CameraMode.CockpitMode: {
            viewMatrix          = Matrix.Invert(playerShip.Position.WorldMatrix);
            spaceSphereLocation = playerShip.Position.Location;
            break;
        }

        case CameraMode.Fixed: {
            camera.Point(0, 0, 0,
                         playerShip.Position.XPos,
                         playerShip.Position.YPos,
                         playerShip.Position.ZPos);
            viewMatrix          = camera.ViewMatrix;
            spaceSphereLocation = new Vector3(0, 0, 0);
            break;
        }
        }
        device.Transform.View         = viewMatrix;
        spaceSphere.Position.Location = spaceSphereLocation;

        //rotate space very slowly for that nice twinkly star effect
        spaceSphere.Position.RotateRel(-.001f * elapsedTime, -0.0001f * elapsedTime, 0);


        //Play the sounds
        soundHandler.Play(playerShip.Sounds);
        playerShip.Sounds = (Sounds)0;
    }
Exemplo n.º 6
0
 /// <summary>
 /// Get the field of view of a specific mode of the camera
 /// </summary>
 public float GetFieldOfView(CameraMode mode)
 {
     return(MtaClient.GetCameraFieldOfView(mode.ToString("f").ToLower()));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Set the field of view of this camera on a specific mode
 /// </summary>
 public bool SetFieldOfView(CameraMode mode, float fieldOfView)
 {
     return(MtaClient.SetCameraFieldOfView(mode.ToString("f").ToLower(), fieldOfView));
 }