Beispiel #1
0
 void WriteTransform(BitStream stream, MyEntity entity, Vector3D? deltaPosBase, bool lowPrecisionOrientation)
 {
     var matrix = entity.WorldMatrix;
     stream.WriteBool(deltaPosBase == null);
     if (deltaPosBase == null)
     {
         stream.Write(matrix.Translation); // 24 B
     }
     else
     {
         stream.Write((Vector3)(matrix.Translation - deltaPosBase.Value)); // 6 B
     }
     var orientation = Quaternion.CreateFromForwardUp(matrix.Forward, matrix.Up);
     stream.WriteBool(lowPrecisionOrientation);
     if (lowPrecisionOrientation)
     {
         stream.WriteQuaternionNormCompressed(orientation); // 29b
     }
     else
     {
         stream.WriteQuaternionNorm(orientation); // 52b
     }
 }