public static Matrix LookAt(Vector3f eye, Vector3f target, Vector3f up) { Vector3f zaxis = Vector3f.Normalize(target - eye); Vector3f xaxis = Vector3f.Normalize(Vector3f.Cross(up, zaxis)); Vector3f yaxis = Vector3f.Cross(zaxis, xaxis); Matrix result = Null; result.M11 = -xaxis.X; result.M12 = yaxis.X; result.M13 = -zaxis.X; result.M21 = -xaxis.Y; result.M22 = yaxis.Y; result.M23 = -zaxis.Y; result.M31 = -xaxis.Z; result.M32 = yaxis.Z; result.M33 = -zaxis.Z; result.M44 = 1.0f; return(Matrix.Translation(-eye) * result); }
public static Vector3f Normalize(Vector3f v) { v.Normalize(); return(v); }