/// <summary> /// Update method to implement /// </summary> /// <param name="state"></param> /// <param name="input"></param> protected abstract void Update(UpdateState state, InputState input);
/// <summary></summary> /// <param name="state"></param> /// <param name="input"></param> protected override sealed void Update(UpdateState state, InputState input) { Vector2 r = input.ThumbSticks.RightStick * (rotAcceleration * rotAcceleration * 0.05f + new Vector2(1, 1)); viewRotation += r * RotationSensitivity * 0.04f; float cap = v_cap; if (viewRotation.Y > cap) viewRotation.Y = cap; if (viewRotation.Y < -cap) viewRotation.Y = -cap; rotAcceleration += input.ThumbSticks.RightStick * (new Vector2(0.5f, 0.25f) * (1.5f - move.Length() * 0.5f)) * 1.25f; rotAcceleration *= 0.9f; #if !XBOX360 if (state.PlayerInput[PlayerIndex].ControlInput == ControlInput.KeyboardMouse) rotAcceleration *= 0;//no rotation acceleration for mouse #endif move *= 0.75f; move += input.ThumbSticks.LeftStick / 4; if (rotAcceleration.LengthSquared() > 0 && r.LengthSquared() > 0) { Vector2 v1 = rotAcceleration, v2 = r; v1.Normalize(); v2.Normalize(); float a = Vector2.Dot(v1, v2); if (a > 0) rotAcceleration *= a; else rotAcceleration *= 0.25f; } Matrix m1, rotation; if (zUp) { //z is up, so rotate left/right is around z. Matrix.CreateRotationZ(-viewRotation.X, out rotation); //x is always left to right, so rotate up/down is around x Matrix.CreateRotationX(viewRotation.Y + MathHelper.PiOver2, out m1); } else { //y is up, so rotate left/right is around y. Matrix.CreateRotationY(-viewRotation.X, out rotation); Matrix.CreateRotationX(viewRotation.Y, out m1); } Matrix.Multiply(ref m1, ref rotation, out rotation); Vector3 pos = Position; pos -= (rotation.Forward * move.Y * MovementSensitivity.Y * -8 + rotation.Left * move.X * MovementSensitivity.X * 8);// new Vector3(move.X * -8, 0, move.Y * 8); Matrix.CreateTranslation(ref pos, out m1); Matrix.Multiply(ref rotation, ref m1, out rotation); CameraMatrix = rotation; }