Beispiel #1
0
 public static CompressedElement ReadCompressedPosFromBitstream(ref UdpKit.UdpBitStream bitstream, XYZBool _includeXYZ, bool lowerBitsOnly = false)
 {
     return(new CompressedElement(
                (_includeXYZ[0]) ? (bitstream.ReadUInt(lowerBitsOnly ? AxisRanges(0).lowerBits : AxisRanges(0).bits)) : 0,
                (_includeXYZ[1]) ? (bitstream.ReadUInt(lowerBitsOnly ? AxisRanges(1).lowerBits : AxisRanges(1).bits)) : 0,
                (_includeXYZ[2]) ? (bitstream.ReadUInt(lowerBitsOnly ? AxisRanges(2).lowerBits : AxisRanges(2).bits)) : 0));
 }
Beispiel #2
0
        /// <param name="forcedUpdate">Indicates that this update is expected, so there will be no bool bit before it indicating whether it was sent.</param>
        /// <returns></returns>
        public override bool ReadFromBitstream(ref UdpKit.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.positions[i] = GenericX.NULL;
                return(false);
            }

            for (int axis = 0; axis < 3; axis++)
            {
                if (axisRanges[axis].useAxis)
                {
                    xyz[axis] =
                        (compression == Compression.HalfFloat) ? bitstream.ReadHalf() :
                        //(compression == Compression.Global) ? NSTCompressVector.ReadAxisFromBitstream(ref bitstream, axis, (cullUpperBits && !isKeyframe)) :
                        (compression == Compression.LocalRange) ? axisRanges[axis].Decode(bitstream.ReadUInt(axisRanges[axis].bits)) :
                        bitstream.ReadFloat();
                }
            }

            targetFrame.positions[i] = new Vector3
                                       (
                (axisRanges[0].useAxis) ? xyz[0] : Localized[0],
                (axisRanges[1].useAxis) ? xyz[1] : Localized[1],
                (axisRanges[2].useAxis) ? xyz[2] : Localized[2]
                                       );

            return(true);
        }
Beispiel #3
0
        public static float ReadAxisFromBitstream(ref UdpKit.UdpBitStream bitstream, int axis, bool lowerBitsOnly = false)
        {
            uint compressedAxis = bitstream.ReadUInt(lowerBitsOnly ? AxisRanges(axis).lowerBits : AxisRanges(axis).bits);

            return(compressedAxis.DecompressAxis(axis));
        }