Example #1
0
        public override bool ReadFromBitstream(ref UdpBitStream bitstream, MsgType msgType, Frame targetFrame, int i, bool forcedUpdate, bool isKeyframe)
        {
            // Only read for the sent bit if not forced, there is no check bit for forced updates (since all clients and server know it is forced)
            bool hasChanged = forcedUpdate || bitstream.ReadBool();

            if (!hasChanged)
            {
                targetFrame.rotations[i] = GenericX.NULL;
            }

            else if (rotationType == XType.Quaternion)
            {
                targetFrame.rotations[i] = bitstream.ReadULong(totalBitsForQuat).DecompressBitBufferToQuat(totalBitsForQuat);
            }
            else
            {
                targetFrame.rotations[i] =
                    new GenericX(
                        (rotationType.IsX()) ?
                        (bitstream.ReadUInt(xyzBits[0]) * xyzUnmult[0] + xyzMin[0]) : 0,

                        (rotationType.IsY()) ?
                        (bitstream.ReadUInt(xyzBits[1]) * xyzUnmult[1] + xyzMin[1]) : 0,

                        (rotationType.IsZ()) ?
                        (bitstream.ReadUInt(xyzBits[2]) * xyzUnmult[2] + xyzMin[2]) : 0,

                        rotationType);
            }

            return(hasChanged);
        }