public static int GetBoneByID(SBonesArray bones, int ID)
 {
     int i = bones.count;
     while (--i > -1) {
         if (bones.instanceIDs[i] == ID)
             return i;
     }
     return -1;
 }
        public override void Dispose()
        {
            base.Dispose();

            if (header != null) header.Dispose();
            if (subMeshes != null) subMeshes.Dispose();
            if (vertices != null) vertices.Dispose();
            if (uv != null) uv.Dispose();
            if (uv1 != null) uv1.Dispose();
            if (uv2 != null) uv2.Dispose();
            if (uv3 != null) uv3.Dispose();
            if (uv4 != null) uv4.Dispose();
            if (bindPoses != null) bindPoses.Dispose();
            if (bones != null) bones.Dispose();
            if (boneWeights != null) boneWeights.Dispose();

            header = null;
            subMeshes = null;
            triangles = null;
            vertices = null;
            uv = null;
            uv1 = null;
            uv2 = null;
            uv3 = null;
            uv4 = null;
            bindPoses = null;
            bones = null;
            boneWeights = null;
        }
 //--------------- Serialzie / Deserialize --------------------
 public static byte[] Serialize(SBonesArray input)
 {
     ComposedByteStream stream = ComposedByteStream.FetchStream();
     if (input != null) {
         stream.AddStream(input.instanceIDs);
         stream.AddStream(input.parentIDs);
         stream.AddStream(input.matrices.matrixData);
     } else {
         stream.AddEmptyStreams(3);
     }
     return stream.Compose();
 }
        public static SBonesArray Deserialize(byte[] input)
        {
            SBonesArray result = new SBonesArray();
            ComposedByteStream stream = ComposedByteStream.FromByteArray(input);
            if (stream == null)
                return null;

            result.instanceIDs = stream.ReadNextStream<int>();
            result.parentIDs = stream.ReadNextStream<int>();
            result.matrices = new SMatrix4x4Array(stream.ReadNextStream<float>());
            result.count = result.matrices.count;
            stream.Dispose();
            return result;
        }