Example #1
0
        public static float ReadFloat(this ICsBitStream bitstream)
        {
            float[] floatTarget = new float[1];

            var bitData = bitstream.ReadBits(32).ToArray();

            var byteData = new byte[4];

            for (int i = 0; i < 4; i++)
            {
                int byteValue = 0;
                for (int b = 0; b < 8; b++)
                {
                    byteValue = (byteValue << 1) + (bitData[i * 8 + b]?1:0);
                }
                byteData[i] = (byte)byteValue;
            }

            Buffer.BlockCopy(byteData, 0, floatTarget, 0, 4);

            return(floatTarget[0]);
        }
Example #2
0
        private void GenerateOutgoingPriorities(ICsBitStream significant, ICsBitStream insignificant,
                                                CsViewComponent component, ref SortedList <float, Transform> potentialSites,
                                                float componentImpactMultiplier = 1f)
        {
            var criticalData = significant.ReadBits(16).ToList();

            var bitSums = new int[3];

            bitSums[0] = SumNthBits(criticalData, 2, 1);
            bitSums[1] = SumNthBits(criticalData, 2, 0);
            bitSums[2] = SumNthBits(criticalData, 3, 1);

            var cosums = new float[3];

            cosums[0] = (bitSums[0] * .76f + 2.1f) * componentImpactMultiplier;
            cosums[1] = (bitSums[1] * .35f + .1f) * componentImpactMultiplier;
            cosums[2] = (bitSums[2] * .24f + .1f) * componentImpactMultiplier;

            for (int i = 0; i < 3; i++)
            {
                potentialSites.Add(cosums[i], component.ConnectionBones[i]);
            }
        }
Example #3
0
 public static int ReadInt(this ICsBitStream bitstream, int bitsToRead = 32)
 {
     return(BoolListToInt(bitstream.ReadBits(bitsToRead)));
 }