Esempio n. 1
0
 /// <summary>
 /// Writes a 8-byte <see cref="Quaternion"/> to the data stream. This is a packed format of a normal 32-bit quaternion with
 /// some data loss.
 /// </summary>
 /// <param name="binaryWriter">The current <see cref="BinaryWriter"/> object.</param>
 /// <param name="quaternion">The quaternion to write.</param>
 public static void WriteQuaternion16(this BinaryWriter binaryWriter, Quaternion quaternion)
 {
     binaryWriter.Write(ExtendedData.FloatQuatValueToShort(quaternion.X));
     binaryWriter.Write(ExtendedData.FloatQuatValueToShort(quaternion.Y));
     binaryWriter.Write(ExtendedData.FloatQuatValueToShort(quaternion.Z));
     binaryWriter.Write(ExtendedData.FloatQuatValueToShort(quaternion.W));
 }
Esempio n. 2
0
        /// <summary>
        /// Reads a 8-byte 16-bit <see cref="Quaternion"/> structure from the data stream, and advances the position of the stream by
        /// 8 bytes.
        /// </summary>
        /// <returns>The quaternion.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        public static Quaternion ReadQuaternion16(this BinaryReader binaryReader)
        {
            short x = binaryReader.ReadInt16();
            short y = binaryReader.ReadInt16();
            short z = binaryReader.ReadInt16();
            short w = binaryReader.ReadInt16();

            return(new Quaternion(ExtendedData.ShortQuatValueToFloat(x), ExtendedData.ShortQuatValueToFloat(y), ExtendedData.ShortQuatValueToFloat(z), ExtendedData.ShortQuatValueToFloat(w)));
        }
Esempio n. 3
0
        /// <summary>
        /// Writes a 8-byte <see cref="Quaternion"/> to the data stream. This is a packed format of a normal 32-bit quaternion with
        /// some data loss.
        /// </summary>
        /// <param name="binaryWriter">The current <see cref="BinaryWriter"/> object.</param>
        /// <param name="quaternion">The quaternion to write.</param>
        public static void WriteQuaternion16(this BinaryWriter binaryWriter, Quaternion quaternion)
        {
            var vector = new Vector3s
                         (
                ExtendedData.FloatQuatValueToShort(quaternion.X),
                ExtendedData.FloatQuatValueToShort(quaternion.Y),
                ExtendedData.FloatQuatValueToShort(quaternion.Z)
                         );

            binaryWriter.WriteVector3s(vector);
            binaryWriter.Write(ExtendedData.FloatQuatValueToShort(quaternion.W));
        }
Esempio n. 4
0
        /// <summary>
        /// Reads a 8-byte 16-bit <see cref="Quaternion"/> structure from the data stream, and advances the position of the stream by
        /// 8 bytes.
        /// </summary>
        /// <returns>The quaternion.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        public static Quaternion ReadQuaternion16(this BinaryReader binaryReader)
        {
            var   vector = binaryReader.ReadVector3s();
            short w      = binaryReader.ReadInt16();

            return(new Quaternion
                   (
                       ExtendedData.ShortQuatValueToFloat(vector.X),
                       ExtendedData.ShortQuatValueToFloat(vector.Y),
                       ExtendedData.ShortQuatValueToFloat(vector.Z),
                       ExtendedData.ShortQuatValueToFloat(w)
                   ));
        }