public static void ExportModelData(BinaryWriter result, Dictionary <string, object> tagData) { var stream = new ModelExporterStream(result); var list = new List <string>((string[])tagData["Debug"]); list.RemoveAll((string x) => x.Contains("Version:")); list.Add(string.Format("Version:{0}", 1157002)); stream.ExportData("Debug", list.ToArray()); using (var cacheStream = new Equinox76561198048419394.Core.Util.Memory.MemoryStream(1024 * 1024)) using (var cacheWriter = new BinaryWriter(cacheStream)) { stream.WriteIndexDictionary(ExportTags(cacheWriter, tagData)); result.BaseStream.Write(cacheStream.GetBuffer(), 0, (int)cacheStream.Length); } }
/// <summary> /// Export /// </summary> /// <param name="result"></param> /// <param name="tagData"></param> /// <returns>tag index</returns> public static Dictionary <string, int> ExportTags(BinaryWriter result, Dictionary <string, object> tagData) { int GetCachePosition() { return((int)result.BaseStream.Position); } var stream = new ModelExporterStream(result); var index = new Dictionary <string, int>(); index.Add(MyImporterConstants.TAG_DUMMIES, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_DUMMIES, (Dictionary <string, MyModelDummy>)tagData[MyImporterConstants.TAG_DUMMIES]); index.Add(MyImporterConstants.TAG_VERTICES, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_VERTICES, (Vector3[])tagData[MyImporterConstants.TAG_VERTICES]); index.Add(MyImporterConstants.TAG_NORMALS, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_NORMALS, (Byte4[])tagData[MyImporterConstants.TAG_NORMALS]); index.Add(MyImporterConstants.TAG_TEXCOORDS0, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_TEXCOORDS0, (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS0]); index.Add(MyImporterConstants.TAG_BINORMALS, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_BINORMALS, (Byte4[])tagData[MyImporterConstants.TAG_BINORMALS]); index.Add(MyImporterConstants.TAG_TANGENTS, GetCachePosition()); stream.ExportData(MyImporterConstants.TAG_TANGENTS, (Byte4[])tagData[MyImporterConstants.TAG_TANGENTS]); index.Add("TexCoords1", GetCachePosition()); stream.ExportData("TexCoords1", (HalfVector2[])tagData["TexCoords1"]); index.Add("RescaleFactor", GetCachePosition()); stream.ExportFloat("RescaleFactor", (float)tagData["RescaleFactor"]); index.Add("UseChannelTextures", GetCachePosition()); stream.ExportBool("UseChannelTextures", (bool)tagData["UseChannelTextures"]); index.Add("BoundingBox", GetCachePosition()); stream.ExportData("BoundingBox", (BoundingBox)tagData["BoundingBox"]); index.Add("BoundingSphere", GetCachePosition()); stream.ExportData("BoundingSphere", (BoundingSphere)tagData["BoundingSphere"]); index.Add("SwapWindingOrder", GetCachePosition()); stream.ExportBool("SwapWindingOrder", (bool)tagData["SwapWindingOrder"]); index.Add("MeshParts", GetCachePosition()); stream.ExportData("MeshParts", (List <MyMeshPartInfo>)tagData["MeshParts"]); index.Add("Sections", GetCachePosition()); stream.ExportData("Sections", (List <MyMeshSectionInfo>)tagData["Sections"]); index.Add("ModelBvh", GetCachePosition()); stream.ExportData("ModelBvh", (byte[])tagData["ModelBvh"]); // GImpactQuantizedBVH as byte[] index.Add("ModelInfo", GetCachePosition()); stream.ExportData("ModelInfo", (MyModelInfo)tagData["ModelInfo"]); index.Add("BlendIndices", GetCachePosition()); stream.ExportData("BlendIndices", (Vector4I[])tagData["BlendIndices"]); index.Add("BlendWeights", GetCachePosition()); stream.ExportData("BlendWeights", (Vector4[])tagData["BlendWeights"]); index.Add("Animations", GetCachePosition()); stream.ExportData("Animations", (ModelAnimations)tagData["Animations"]); index.Add("Bones", GetCachePosition()); stream.ExportData("Bones", (MyModelBone[])tagData["Bones"]); index.Add("BoneMapping", GetCachePosition()); stream.ExportData("BoneMapping", (Vector3I[])tagData["BoneMapping"]); index.Add("HavokCollisionGeometry", GetCachePosition()); stream.ExportData("HavokCollisionGeometry", (byte[])tagData["HavokCollisionGeometry"]); index.Add("PatternScale", GetCachePosition()); stream.ExportFloat("PatternScale", (float)tagData["PatternScale"]); index.Add("LODs", GetCachePosition()); stream.ExportData("LODs", (MyLODDescriptor[])tagData["LODs"]); if (tagData.ContainsKey("FBXHash")) { index.Add("FBXHash", GetCachePosition()); stream.ExportData("FBXHash", (Hashing.Hash128)tagData["FBXHash"]); } if (tagData.ContainsKey("HKTHash")) { index.Add("HKTHash", GetCachePosition()); stream.ExportData("HKTHash", (Hashing.Hash128)tagData["HKTHash"]); } if (tagData.ContainsKey("XMLHash")) { index.Add("XMLHash", GetCachePosition()); stream.ExportData("XMLHash", (Hashing.Hash128)tagData["XMLHash"]); } return(index); }