public static void RotateM2(float[] m, int mOffset, float a, float x, float y, float z)
 {
     float[] temp = new float[32];
     SetRotateM(temp, 0, a, x, y, z);
     MultiplyMM(temp, 16, m, mOffset, temp, 0);
     JSArrayEx.Copy(temp, 16, m, mOffset, 16);
 }
Esempio n. 2
0
        // Calculates a crc checksum-sequence over an array.
        public static byte BlockSequenceCRCByte(byte[] b, int offset, int length, int sequence)
        {
            if (sequence < 0)
            {
                throw new Exception("InvalidOperationException: sequence < 0, this shouldn't happen\n");
            }
            //p_ndx = (sequence % (sizeof(chktbl) - 4));
            int p_ndx = (sequence % (1024 - 4));

            //memcpy(chkb, base, length);
            length = Math.Min(60, length);
            JSArrayEx.Copy(b, offset, chkb, 0, length);
            chkb[length]     = chktbl[p_ndx + 0];
            chkb[length + 1] = chktbl[p_ndx + 1];
            chkb[length + 2] = chktbl[p_ndx + 2];
            chkb[length + 3] = chktbl[p_ndx + 3];
            length          += 4;
            // unsigned short
            int crc = CRC_Block(chkb, length);
            int x   = 0;

            for (int n = 0; n < length; n++)
            {
                x += chkb[n] & 0xFF;
            }
            crc ^= x;
            return((byte)(crc & 0xFF));
        }
Esempio n. 3
0
        // MD4 block update operation.
        // Continues an MD4 message digest operation, by filling the buffer, transform(ing) data in 512-bit message block(s), updating the variables
        // application and count, and leaving (buffering) the remaining bytes in buffer for the next update or finish.
        //
        // @param    input    input block
        // @param    offset    start of meaningful bytes in input
        // @param    len        count of bytes in input block to consider
        public void Update(byte[] input, int offset, int len)
        {
            // make sure we don't exceed input's allocated size/length
            if (offset < 0 || len < 0 || (long)offset + len > input.Length)
            {
                throw new Exception("IndexOutOfRangeException:");
            }
            // compute number of bytes still unhashed; ie. present in buffer
            int bufferNdx = (int)(count % BLOCK_LENGTH);

            count += len; // update number of bytes
            int partLen = BLOCK_LENGTH - bufferNdx;
            int i       = 0;

            if (len >= partLen)
            {
                JSArrayEx.Copy(input, offset, buffer, bufferNdx, partLen);
                Transform(buffer, 0);
                for (i = partLen; i + BLOCK_LENGTH - 1 < len; i += BLOCK_LENGTH)
                {
                    Transform(input, offset + i);
                }
                bufferNdx = 0;
            }
            // buffer remaining input
            if (i < len)
            {
                JSArrayEx.Copy(input, offset + i, buffer, bufferNdx, len - i);
            }
        }
Esempio n. 4
0
        // Materialf (GLenum face, GLenum pname, GLfloat param);
        // Materialfv (GLenum face, GLenum pname, const GLfloat *params);
        public virtual void MultMatrixf(float[] m) //, int ofs)
        {
            int ofs = 0;

            MathMatrix.MultiplyMM(_tmpMatrix, 0, _currentMatrix, 0, m, ofs);
            JSArrayEx.Copy(_tmpMatrix, 0, _currentMatrix, 0, 16);
            _mvpDirty = true;
        }
 public void Clear()
 {
     if (Data != null)
     {
         JSArrayEx.Clear(Data, 0, Data.Length);
     }
     Length        = 0;
     HasOverflowed = false;
 }
 public override void WriteByte(int b)
 {
     if (_buffer.Length == _length)
     {
         byte[] newBuf = new byte[_buffer.Length * 3 / 2];
         JSArrayEx.Copy(_buffer, 0, newBuf, 0, (int)_length);
         _buffer = newBuf;
     }
     _buffer[_length++] = (byte)b;
 }
Esempio n. 7
0
        // Returns a copy of this MD object.
        public object Clone()
        {
            Md4Slim md4 = new Md4Slim();

            //    This constructor is here to implement cloneability of this class.
            application = new uint[md4.application.Length];
            JSArrayEx.Copy(md4.application, 0, application, 0, application.Length);
            buffer = new byte[md4.buffer.Length];
            JSArrayEx.Copy(md4.buffer, 0, buffer, 0, buffer.Length);
            count = md4.count;
            return(md4);
        }
 public override void SetLength(long value)
 {
     if (_buffer.Length != value)
     {
         byte[] newBuf = new byte[value * 3 / 2];
         JSArrayEx.Copy(_buffer, 0, newBuf, 0, (int)_length);
         _buffer = newBuf;
         while (_length < value)
         {
             _buffer[_length++] = 0;
         }
     }
     _length = value;
 }
        public void Print(string data2)
        {
            //Com.dprintln("SZ.print():<" + data2 + ">");
            int length = data2.Length;

            byte[] str = JSConvert.StringToBytes(data2);
            if (Length != 0)
            {
                if (Data[Length - 1] != 0)
                {
                    JSArrayEx.Copy(str, 0, Data, GetSpace(length + 1), length);
                }
                else
                {
                    JSArrayEx.Copy(str, 0, Data, GetSpace(length) - 1, length);
                }
            }
            else
            {
                // first print.
                JSArrayEx.Copy(str, 0, Data, GetSpace(length), length);
            }
            Data[Length - 1] = 0;
        }
 public void Append3(byte[] data, int offset, int length)
 {
     JSArrayEx.Copy(data, offset, data, GetSpace(length), length);
 }
 public void Append2(byte[] data, int length)
 {
     JSArrayEx.Copy(data, 0, data, GetSpace(length), length);
 }
        public void Append(byte[] data)
        {
            int length = data.Length;

            JSArrayEx.Copy(data, 0, data, GetSpace(length), length);
        }
 public byte[] ToArray()
 {
     byte[] result = new byte[_length];
     JSArrayEx.Copy(_buffer, 0, result, 0, (int)_length);
     return(result);
 }
Esempio n. 14
0
 public virtual void PushMatrix()
 {
     float[] copy = new float[16];
     JSArrayEx.Copy(_currentMatrix, 0, copy, 0, 16);
     _currentMatrixStack.Push(copy);
 }
Esempio n. 15
0
 // PolygonOffsetx (GLfixed factor, GLfixed units);
 public virtual void PopMatrix()
 {
     float[] top = (float[])_currentMatrixStack.Pop();
     JSArrayEx.Copy(top, 0, _currentMatrix, 0, 16);
     _mvpDirty = true;
 }