Beispiel #1
0
        /// <summary>
        /// Construct the transform from a binary source
        /// </summary>
        /// <param name="readBuffer"></param>
        /// <param name="index"></param>
        public Transform(byte[] readBuffer, ref int index)
        {
#if XBOX360
            this = new Transform();
#endif

            BitCast cast = new BitCast();

            cast.Byte0      = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Rotation.X = cast.Single;
            cast.Byte0      = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Rotation.Y = cast.Single;
            cast.Byte0      = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Rotation.Z = cast.Single;
            cast.Byte0      = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Rotation.W = cast.Single;

            cast.Byte0         = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Translation.X = cast.Single;
            cast.Byte0         = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Translation.Y = cast.Single;
            cast.Byte0         = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Translation.Z = cast.Single;
            cast.Byte0         = readBuffer[index++]; cast.Byte1 = readBuffer[index++]; cast.Byte2 = readBuffer[index++]; cast.Byte3 = readBuffer[index++];
            this.Scale         = cast.Single;
        }
Beispiel #2
0
        /// <summary>
        /// Write the transform as bytes (32 bytes)
        /// </summary>
        /// <param name="index"></param>
        /// <param name="writeTarget"></param>
        internal void Write(byte[] writeTarget, ref int index)
        {
            BitCast cast = new BitCast();

            cast.Single          = this.Rotation.X;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Rotation.Y;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Rotation.Z;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Rotation.W;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;

            cast.Single          = this.Translation.X;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Translation.Y;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Translation.Z;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
            cast.Single          = this.Scale;
            writeTarget[index++] = cast.Byte0; writeTarget[index++] = cast.Byte1; writeTarget[index++] = cast.Byte2; writeTarget[index++] = cast.Byte3;
        }