Beispiel #1
0
 public override void Write(Library.Collections.BitStream stream, ref Quaternion value, MySerializeInfo info)
 {
     if (info.IsNormalized)
     {
         stream.WriteBool(value.W < 0.0f);
         stream.WriteBool(value.X < 0.0f);
         stream.WriteBool(value.Y < 0.0f);
         stream.WriteBool(value.Z < 0.0f);
         stream.WriteUInt16((ushort)(Math.Abs(value.X) * 65535.0));
         stream.WriteUInt16((ushort)(Math.Abs(value.Y) * 65535.0));
         stream.WriteUInt16((ushort)(Math.Abs(value.Z) * 65535.0));
     }
     else
     {
         Debug.Fail("Not normalized quaternion?");
         stream.WriteFloat(value.X);
         stream.WriteFloat(value.Y);
         stream.WriteFloat(value.Z);
         stream.WriteFloat(value.W);
     }
 }
Beispiel #2
0
 public override void Write(Library.Collections.BitStream stream, ref float value, MySerializeInfo info)
 {
     if (info.IsNormalized && info.IsFixed8)
     {
         stream.WriteByte((byte)(value * 255.0f));
     }
     else if (info.IsNormalized && info.IsFixed16)
     {
         stream.WriteUInt16((ushort)(value * 65535.0f));
     }
     else
     {
         stream.WriteFloat(value);
     }
 }