public ReadSignedSingle ( int numberOfBits ) : float | ||
numberOfBits | int | The number of bits used when writing the value |
return | float |
/// <summary> /// Reads a unit quaternion written using WriteRotation(... ,bitsPerElement) /// </summary> public static Quaternion ReadRotation(this NetBuffer message, int bitsPerElement) { Quaternion retval; retval.x = message.ReadSignedSingle(bitsPerElement); retval.y = message.ReadSignedSingle(bitsPerElement); retval.z = message.ReadSignedSingle(bitsPerElement); retval.w = message.ReadSignedSingle(bitsPerElement); return(retval); }
/// <summary> /// Reads a unit vector written using WriteUnitVector3(numberOfBits) /// </summary> public static Vector3 ReadUnitVector3(this NetBuffer message, int numberOfBits) { int halfBits = numberOfBits / 2; float phi = message.ReadSignedSingle(halfBits) * (float)Math.PI; float theta = message.ReadSignedSingle(numberOfBits - halfBits) * (float)(Math.PI * 0.5); Vector3 retval; retval.x = (float)(Math.Sin(phi) * Math.Cos(theta)); retval.y = (float)(Math.Cos(phi) * Math.Cos(theta)); retval.z = (float)Math.Sin(theta); return(retval); }