public override Matrix4x4 GetViewProjectionMatrix(float width, float height) { // Calculate up vector Matrix4x4 rotation = Matrix4x4.CreateFromYawPitchRoll(RotationY, -RotationX, 0); Vector3 up = MathC.HomogenousTransform(Vector3.UnitY, rotation); //new Vector3(0, 150, 0), Vector3.Up); Matrix4x4 View = MathC.Matrix4x4CreateLookAtLH(GetPosition(), Target, up); float aspectRatio = width / height; Matrix4x4 Projection = MathC.Matrix4x4CreatePerspectiveFieldOfViewLH(FieldOfView, aspectRatio, 20.0f, 1000000.0f); Matrix4x4 result = View * Projection; return(result); }
public override Matrix4x4 GetViewProjectionMatrix(float width, float height) { Matrix4x4 rotation = GetRotationMatrix(); Vector3 look = MathC.HomogenousTransform(Vector3.UnitZ, rotation); Vector3 right = MathC.HomogenousTransform(Vector3.UnitX, rotation); Vector3 up = Vector3.Cross(look, right); Target = Position + 1024.0f * look; Matrix4x4 View = MathC.Matrix4x4CreateLookAtLH(Position, Target, up); float aspectRatio = width / height; Matrix4x4 Projection = MathC.Matrix4x4CreatePerspectiveFieldOfViewLH(FieldOfView, aspectRatio, 20.0f, 1000000.0f); Matrix4x4 result = View * Projection; return(result); }