Exemplo n.º 1
0
        public override void WriteToBitstream(ref UdpKit.UdpBitStream bitstream, MsgType msgType, bool forceUpdate, bool isKeyframe)
        {
            // Compress the current element rotation using the selected compression method.
            CompressedElement newCPos = CompressElement();

            // For frames between forced updates, we need to first send a flag bit for if this element is being sent
            if (!forceUpdate)
            {
                bool hasChanged = !CompressedElement.Compare(newCPos, lastSentCompressed);
                bitstream.WriteBool(hasChanged);
                // if no changes have occured we are done.
                if (!hasChanged)
                {
                    return;
                }
            }

            //TODO insert haschanged tests here
            for (int axis = 0; axis < 3; axis++)
            {
                if (axisRanges[axis].useAxis)
                {
                    highestChangedBit[axis] = CompressedElement.HighestDifferentBit(newCPos[axis], lastSentCompressed[axis]);
                }
            }

            for (int axis = 0; axis < 3; axis++)
            {
                if (axisRanges[axis].useAxis)
                {
                    if (compression == Compression.HalfFloat)
                    {
                        bitstream.WriteUInt(newCPos[axis], 16);
                    }

                    //else if (compression == Compression.Global)
                    //{
                    //	newCPos[axis].WriteCompressedAxisToBitstream(axis, ref bitstream, (cullUpperBits && !isKeyframe));
                    //}

                    else if (compression == Compression.LocalRange)
                    {
                        bitstream.WriteUInt(newCPos[axis], axisRanges[axis].bits);
                    }

                    else
                    {
                        bitstream.WriteUInt(newCPos[axis], 32);
                    }
                }
            }

            lastSentCompressed = newCPos;
        }
Exemplo n.º 2
0
        public static uint WriteAxisToBitstream(this float val, int axis, ref UdpKit.UdpBitStream bitstream, bool lowerBitsOnly = false)
        {
            //TODO: use lowerbits from inside ranges
            uint compressedAxis = val.CompressAxis(axis);

            bitstream.WriteUInt(val.CompressAxis(axis), lowerBitsOnly ? AxisRanges(axis).lowerBits : AxisRanges(axis).bits);
            return(compressedAxis);
        }
Exemplo n.º 3
0
 public static void WriteCompPosToBitstream(this CompressedElement compressedpos, ref UdpKit.UdpBitStream bitstream, XYZBool _includeXYZ, bool lowerBitsOnly = false)
 {
     for (int axis = 0; axis < 3; axis++)
     {
         //TODO: use lowerbits from inside ranges
         if (_includeXYZ[axis])
         {
             bitstream.WriteUInt(compressedpos[axis], lowerBitsOnly ? AxisRanges(axis).lowerBits : AxisRanges(axis).bits);
         }
     }
 }
Exemplo n.º 4
0
 public static void WriteCompressedAxisToBitstream(this uint val, int axis, ref UdpKit.UdpBitStream bitstream, bool lowerBitsOnly = false)
 {
     //TODO: use lowerbits from inside ranges
     bitstream.WriteUInt(val, lowerBitsOnly ? AxisRanges(axis).lowerBits : AxisRanges(axis).bits);
 }