SHARE
TWEET

Follow Camera

a guest Feb 14th, 2020 56 in 15 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (tipoCamera == TipoCamera.ThirdPerson)
  2.             {
  3.                 Vector3 scale;
  4.                 Quaternion rotation;
  5.                 Vector3 shipPosition;
  6.                 ship.World.Decompose(out scale, out rotation, out shipPosition);
  7.                 Matrix rotationMatrix = Matrix.CreateFromQuaternion(rotation);
  8.  
  9.                 //Vector3 thirdPersonReference = new Vector3(0, 5f, 8f);
  10.                 Vector3 thirdPersonReference = new Vector3(0, 25f, 100f);
  11.  
  12.                 Vector3 transformedReference =
  13.                     Vector3.Transform(thirdPersonReference, rotationMatrix);
  14.  
  15.                 Vector3 cameraPosition = transformedReference + ship.Position;
  16.  
  17.                 View = Matrix.CreateLookAt(cameraPosition, ship.Position + rotationMatrix.Forward * 3,
  18.                     Vector3.Cross(rotationMatrix.Left, transformedReference));
  19.  
  20.                 position = cameraPosition;
  21.                 direction = ship.Position - position;
  22.  
  23.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top