Exemple #1
0
        public static Quaternion ReadQuaternion(this Lidgren.Network.NetIncomingMessage im)
        {
            var maxIndex = im.ReadRangedInteger(0, 3);

            var a = im.ReadRangedSingle(UNIT_MIN, UNIT_MAX, BITS_COMPONENT);
            var b = im.ReadRangedSingle(UNIT_MIN, UNIT_MAX, BITS_COMPONENT);
            var c = im.ReadRangedSingle(UNIT_MIN, UNIT_MAX, BITS_COMPONENT);
            var d = (float)Math.Sqrt(1f - (a * a + b * b + c * c));

            im.ReadPadBits();
            Quaternion q;

            if (maxIndex == 0)
            {
                return(new Quaternion(d, a, b, c));
            }
            if (maxIndex == 1)
            {
                return(new Quaternion(a, d, b, c));
            }
            if (maxIndex == 2)
            {
                return(new Quaternion(a, b, d, c));
            }
            return(new Quaternion(a, b, c, d));
        }
Exemple #2
0
        public static Canvas Receive(Lidgren.Network.NetIncomingMessage message, Palette pal)
        {
            var width  = message.ReadVariableInt32();
            var height = message.ReadVariableInt32();

            message.ReadPadBits();
            var stream = message.ReadStream();

            var canvas = new MemoryCanvas(new Size(width, height));

            Pablo.Load(stream, canvas, pal);
            return(canvas);
        }