public static void ExportModelData(string filename, Dictionary<string, object> tagData)
        {
            using (var modelExporter = new MyModelExporter(filename))
            {
                Dictionary<string, int> exportDictionary = new Dictionary<string, int>();

                var debugArray = (string[])tagData[MyImporterConstants.TAG_DEBUG];
                var debug = new List<string>(debugArray);
                debug.RemoveAll(x => x.Contains("Version:"));
                debug.Add("Version:01097001");

                // Debug info
                modelExporter.ExportData(MyImporterConstants.TAG_DEBUG, (string[])debug.ToArray());

                modelExporter.StartCacheWrite();

                // Dummy helper data
                exportDictionary.Add(MyImporterConstants.TAG_DUMMIES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_DUMMIES, (Dictionary<string, MyModelDummy>)tagData[MyImporterConstants.TAG_DUMMIES]);

                exportDictionary.Add(MyImporterConstants.TAG_VERTICES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_VERTICES, (HalfVector4[])tagData[MyImporterConstants.TAG_VERTICES]);

                exportDictionary.Add(MyImporterConstants.TAG_NORMALS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_NORMALS, (Byte4[])tagData[MyImporterConstants.TAG_NORMALS]);

                //  Depends on whether model contain texture channel 0
                exportDictionary.Add(MyImporterConstants.TAG_TEXCOORDS0, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TEXCOORDS0, (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS0]);

                exportDictionary.Add(MyImporterConstants.TAG_BINORMALS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BINORMALS, (Byte4[])tagData[MyImporterConstants.TAG_BINORMALS]);
                exportDictionary.Add(MyImporterConstants.TAG_TANGENTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TANGENTS, (Byte4[])tagData[MyImporterConstants.TAG_TANGENTS]);

                //  Depends on whether model contain texture channel 1
                exportDictionary.Add(MyImporterConstants.TAG_TEXCOORDS1, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TEXCOORDS1, (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS1]);

                //  Properties
                exportDictionary.Add(MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS, (bool)tagData[MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS]);
                exportDictionary.Add(MyImporterConstants.TAG_LENGTH_IN_METERS, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_LENGTH_IN_METERS, (float)tagData[MyImporterConstants.TAG_LENGTH_IN_METERS]);
                exportDictionary.Add(MyImporterConstants.TAG_RESCALE_FACTOR, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_RESCALE_FACTOR, (float)tagData[MyImporterConstants.TAG_RESCALE_FACTOR]);
                exportDictionary.Add(MyImporterConstants.TAG_CENTERED, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_CENTERED, (bool)tagData[MyImporterConstants.TAG_CENTERED]);
                exportDictionary.Add(MyImporterConstants.TAG_USE_CHANNEL_TEXTURES, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_USE_CHANNEL_TEXTURES, (bool)tagData[MyImporterConstants.TAG_USE_CHANNEL_TEXTURES]);
                exportDictionary.Add(MyImporterConstants.TAG_SPECULAR_SHININESS, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_SPECULAR_SHININESS, (float)tagData[MyImporterConstants.TAG_SPECULAR_SHININESS]);
                exportDictionary.Add(MyImporterConstants.TAG_SPECULAR_POWER, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_SPECULAR_POWER, (float)tagData[MyImporterConstants.TAG_SPECULAR_POWER]);
                exportDictionary.Add(MyImporterConstants.TAG_BOUNDING_BOX, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BOUNDING_BOX, (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX]);
                exportDictionary.Add(MyImporterConstants.TAG_BOUNDING_SPHERE, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BOUNDING_SPHERE, (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE]);
                exportDictionary.Add(MyImporterConstants.TAG_SWAP_WINDING_ORDER, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_SWAP_WINDING_ORDER, (bool)tagData[MyImporterConstants.TAG_SWAP_WINDING_ORDER]);

                exportDictionary.Add(MyImporterConstants.TAG_MESH_PARTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MESH_PARTS, (List<MyMeshPartInfo>)tagData[MyImporterConstants.TAG_MESH_PARTS]);

                exportDictionary.Add(MyImporterConstants.TAG_MODEL_BVH, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MODEL_BVH, ((BulletXNA.BulletCollision.GImpactQuantizedBvh)tagData[MyImporterConstants.TAG_MODEL_BVH]).Save());

                exportDictionary.Add(MyImporterConstants.TAG_MODEL_INFO, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MODEL_INFO, (MyModelInfo)tagData[MyImporterConstants.TAG_MODEL_INFO]);

                exportDictionary.Add(MyImporterConstants.TAG_BLENDINDICES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BLENDINDICES, (Vector4I[])tagData[MyImporterConstants.TAG_BLENDINDICES]);
                exportDictionary.Add(MyImporterConstants.TAG_BLENDWEIGHTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BLENDWEIGHTS, (Vector4[])tagData[MyImporterConstants.TAG_BLENDWEIGHTS]);

                exportDictionary.Add(MyImporterConstants.TAG_ANIMATIONS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_ANIMATIONS, (ModelAnimations)tagData[MyImporterConstants.TAG_ANIMATIONS]);
                exportDictionary.Add(MyImporterConstants.TAG_BONES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BONES, (MyModelBone[])tagData[MyImporterConstants.TAG_BONES]);
                exportDictionary.Add(MyImporterConstants.TAG_BONE_MAPPING, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BONE_MAPPING, (Vector3I[])tagData[MyImporterConstants.TAG_BONE_MAPPING]);

                exportDictionary.Add(MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY, (byte[])tagData[MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY]);

                exportDictionary.Add(MyImporterConstants.TAG_PATTERN_SCALE, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_PATTERN_SCALE, (float)tagData[MyImporterConstants.TAG_PATTERN_SCALE]);

                exportDictionary.Add(MyImporterConstants.TAG_LODS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_LODS, (MyLODDescriptor[])tagData[MyImporterConstants.TAG_LODS]);

                // AutoRebuild Tags Hashes
                if (tagData.ContainsKey(MyImporterConstants.TAG_FBXHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_FBXHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_FBXHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_FBXHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_HKTHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_HKTHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_HKTHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_HKTHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_XMLHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_XMLHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_XMLHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_XMLHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_MODEL_FRACTURES))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_MODEL_FRACTURES, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_MODEL_FRACTURES, (MyModelFractures)tagData[MyImporterConstants.TAG_MODEL_FRACTURES]);
                }


                modelExporter.StopCacheWrite();

                modelExporter.WriteIndexDictionary(exportDictionary);

                modelExporter.FlushCache();
            }
        }
        public static void ExportModelData(string filename, Dictionary <string, object> tagData)
        {
            using (var modelExporter = new MyModelExporter(filename))
            {
                Dictionary <string, int> exportDictionary = new Dictionary <string, int>();

                var debugArray = (string[])tagData[MyImporterConstants.TAG_DEBUG];
                var debug      = new List <string>(debugArray);
                debug.RemoveAll(x => x.Contains("Version:"));
                debug.Add("Version:01097001");

                // Debug info
                modelExporter.ExportData(MyImporterConstants.TAG_DEBUG, (string[])debug.ToArray());

                modelExporter.StartCacheWrite();

                // Dummy helper data
                exportDictionary.Add(MyImporterConstants.TAG_DUMMIES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_DUMMIES, (Dictionary <string, MyModelDummy>)tagData[MyImporterConstants.TAG_DUMMIES]);

                exportDictionary.Add(MyImporterConstants.TAG_VERTICES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_VERTICES, (HalfVector4[])tagData[MyImporterConstants.TAG_VERTICES]);

                exportDictionary.Add(MyImporterConstants.TAG_NORMALS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_NORMALS, (Byte4[])tagData[MyImporterConstants.TAG_NORMALS]);

                //  Depends on whether model contain texture channel 0
                exportDictionary.Add(MyImporterConstants.TAG_TEXCOORDS0, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TEXCOORDS0, (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS0]);

                exportDictionary.Add(MyImporterConstants.TAG_BINORMALS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BINORMALS, (Byte4[])tagData[MyImporterConstants.TAG_BINORMALS]);
                exportDictionary.Add(MyImporterConstants.TAG_TANGENTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TANGENTS, (Byte4[])tagData[MyImporterConstants.TAG_TANGENTS]);

                //  Depends on whether model contain texture channel 1
                exportDictionary.Add(MyImporterConstants.TAG_TEXCOORDS1, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_TEXCOORDS1, (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS1]);

                //  Properties
                exportDictionary.Add(MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS, (bool)tagData[MyImporterConstants.TAG_RESCALE_TO_LENGTH_IN_METERS]);
                exportDictionary.Add(MyImporterConstants.TAG_LENGTH_IN_METERS, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_LENGTH_IN_METERS, (float)tagData[MyImporterConstants.TAG_LENGTH_IN_METERS]);
                exportDictionary.Add(MyImporterConstants.TAG_RESCALE_FACTOR, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_RESCALE_FACTOR, (float)tagData[MyImporterConstants.TAG_RESCALE_FACTOR]);
                exportDictionary.Add(MyImporterConstants.TAG_CENTERED, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_CENTERED, (bool)tagData[MyImporterConstants.TAG_CENTERED]);
                exportDictionary.Add(MyImporterConstants.TAG_USE_CHANNEL_TEXTURES, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_USE_CHANNEL_TEXTURES, (bool)tagData[MyImporterConstants.TAG_USE_CHANNEL_TEXTURES]);
                exportDictionary.Add(MyImporterConstants.TAG_SPECULAR_SHININESS, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_SPECULAR_SHININESS, (float)tagData[MyImporterConstants.TAG_SPECULAR_SHININESS]);
                exportDictionary.Add(MyImporterConstants.TAG_SPECULAR_POWER, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_SPECULAR_POWER, (float)tagData[MyImporterConstants.TAG_SPECULAR_POWER]);
                exportDictionary.Add(MyImporterConstants.TAG_BOUNDING_BOX, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BOUNDING_BOX, (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX]);
                exportDictionary.Add(MyImporterConstants.TAG_BOUNDING_SPHERE, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BOUNDING_SPHERE, (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE]);
                exportDictionary.Add(MyImporterConstants.TAG_SWAP_WINDING_ORDER, modelExporter.GetCachePosition());
                modelExporter.ExportBool(MyImporterConstants.TAG_SWAP_WINDING_ORDER, (bool)tagData[MyImporterConstants.TAG_SWAP_WINDING_ORDER]);

                exportDictionary.Add(MyImporterConstants.TAG_MESH_PARTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MESH_PARTS, (List <MyMeshPartInfo>)tagData[MyImporterConstants.TAG_MESH_PARTS]);

                exportDictionary.Add(MyImporterConstants.TAG_MESH_SECTIONS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MESH_SECTIONS, (List <MyMeshSectionInfo>)tagData[MyImporterConstants.TAG_MESH_SECTIONS]);

                exportDictionary.Add(MyImporterConstants.TAG_MODEL_BVH, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MODEL_BVH, ((BulletXNA.BulletCollision.GImpactQuantizedBvh)tagData[MyImporterConstants.TAG_MODEL_BVH]).Save());

                exportDictionary.Add(MyImporterConstants.TAG_MODEL_INFO, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_MODEL_INFO, (MyModelInfo)tagData[MyImporterConstants.TAG_MODEL_INFO]);

                exportDictionary.Add(MyImporterConstants.TAG_BLENDINDICES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BLENDINDICES, (Vector4I[])tagData[MyImporterConstants.TAG_BLENDINDICES]);
                exportDictionary.Add(MyImporterConstants.TAG_BLENDWEIGHTS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BLENDWEIGHTS, (Vector4[])tagData[MyImporterConstants.TAG_BLENDWEIGHTS]);

                exportDictionary.Add(MyImporterConstants.TAG_ANIMATIONS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_ANIMATIONS, (ModelAnimations)tagData[MyImporterConstants.TAG_ANIMATIONS]);
                exportDictionary.Add(MyImporterConstants.TAG_BONES, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BONES, (MyModelBone[])tagData[MyImporterConstants.TAG_BONES]);
                exportDictionary.Add(MyImporterConstants.TAG_BONE_MAPPING, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_BONE_MAPPING, (Vector3I[])tagData[MyImporterConstants.TAG_BONE_MAPPING]);

                exportDictionary.Add(MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY, (byte[])tagData[MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY]);

                exportDictionary.Add(MyImporterConstants.TAG_PATTERN_SCALE, modelExporter.GetCachePosition());
                modelExporter.ExportFloat(MyImporterConstants.TAG_PATTERN_SCALE, (float)tagData[MyImporterConstants.TAG_PATTERN_SCALE]);

                exportDictionary.Add(MyImporterConstants.TAG_LODS, modelExporter.GetCachePosition());
                modelExporter.ExportData(MyImporterConstants.TAG_LODS, (MyLODDescriptor[])tagData[MyImporterConstants.TAG_LODS]);

                // AutoRebuild Tags Hashes
                if (tagData.ContainsKey(MyImporterConstants.TAG_FBXHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_FBXHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_FBXHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_FBXHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_HKTHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_HKTHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_HKTHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_HKTHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_XMLHASHSTRING))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_XMLHASHSTRING, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_XMLHASHSTRING, (VRage.Security.Md5.Hash)tagData[MyImporterConstants.TAG_XMLHASHSTRING]);
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_MODEL_FRACTURES))
                {
                    exportDictionary.Add(MyImporterConstants.TAG_MODEL_FRACTURES, modelExporter.GetCachePosition());
                    modelExporter.ExportData(MyImporterConstants.TAG_MODEL_FRACTURES, (MyModelFractures)tagData[MyImporterConstants.TAG_MODEL_FRACTURES]);
                }


                modelExporter.StopCacheWrite();

                modelExporter.WriteIndexDictionary(exportDictionary);

                modelExporter.FlushCache();
            }
        }