Пример #1
0
        public void Unpack(Network.ByteInStream stream)
        {
            if (compressPosition)
            {
                position = new Vector3(
                    HalfUtilities.Unpack(stream.ReadUShort()),
                    HalfUtilities.Unpack(stream.ReadUShort()),
                    HalfUtilities.Unpack(stream.ReadUShort())
                );
            }
            else
            {
                position = stream.ReadVector3();
            }

            if (yawOnly)
            {
                yaw = stream.ReadByte() * 1.40625f;
                rotation = Quaternion.RotationAxis(Vector3.Up, yaw * SlimMath.Single.Deg2Rad);
            }
            else
            {
                rotation = Quaternion.RotationAxis(
                    new Vector3(
                        HalfUtilities.Unpack(stream.ReadUShort()),
                        HalfUtilities.Unpack(stream.ReadUShort()),
                        HalfUtilities.Unpack(stream.ReadUShort())
                    ),
                    (stream.ReadByte() * 1.40625f * SlimMath.Single.Deg2Rad)
                );
            }

            buffer.Push(Actor.Context.Time.GameTime,
                new State { Position = position, Rotation = rotation }
            );
        }