public void Write(Stream output, FindLogic.Combo.ComboInfo info, FindLogic.Combo.MaterialInfo materialInfo) { using (BinaryWriter writer = new BinaryWriter(output)) { FindLogic.Combo.MaterialDataInfo materialDataInfo = info.MaterialDatas[materialInfo.MaterialData]; writer.Write(VersionMajor); writer.Write(VersionMinor); writer.Write(materialDataInfo.Textures.LongCount()); writer.Write((uint)OWMatType.Material); writer.Write(GUID.Index(materialInfo.Shader)); writer.Write(materialInfo.IDs.Count); foreach (ulong id in materialInfo.IDs) { writer.Write(id); } foreach (KeyValuePair <ulong, ImageDefinition.ImageType> texture in materialDataInfo.Textures) { if (info.Textures.ContainsKey(texture.Key)) { FindLogic.Combo.TextureInfoNew textureInfo = info.Textures[texture.Key]; writer.Write($"..\\Textures\\{textureInfo.GetNameIndex()}.dds"); } else { writer.Write(""); } writer.Write((uint)texture.Value); } } }
public static void SaveMaterial(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong material) { FindLogic.Combo.MaterialInfo materialInfo = info.Materials[material]; FindLogic.Combo.MaterialDataInfo materialDataInfo = info.MaterialDatas[materialInfo.MaterialData]; Model.OWMatWriter14 materialWriter = new Model.OWMatWriter14(); string textureDirectory = Path.Combine(path, "Textures"); if (info.SaveRuntimeData.Threads) { info.SaveRuntimeData.Tasks.Add(Task.Run(() => { SaveOWMaterialFile(path, materialInfo, materialWriter, info); })); } else { SaveOWMaterialFile(path, materialInfo, materialWriter, info); } foreach (KeyValuePair <ulong, ImageDefinition.ImageType> texture in materialDataInfo.Textures) { SaveTexture(flags, textureDirectory, info, texture.Key); } }
public static void SaveMaterial(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong material) { FindLogic.Combo.MaterialInfo materialInfo = info.Materials[material]; FindLogic.Combo.MaterialDataInfo materialDataInfo = info.MaterialDatas[materialInfo.MaterialData]; string textureDirectory = Path.Combine(path, "Textures"); SaveOWMaterialFile(path, materialInfo, info); if (materialDataInfo.Textures != null) { foreach (KeyValuePair <ulong, uint> texture in materialDataInfo.Textures) { SaveTexture(flags, textureDirectory, info, texture.Key); } } }
public void Write(Stream stream) { using (BinaryWriter writer = new BinaryWriter(stream)) { FindLogic.Combo.MaterialDataInfo materialDataInfo = Info.MaterialDatas[MaterialInfo.MaterialData]; writer.Write(VersionMajor); writer.Write(VersionMinor); if (materialDataInfo.Textures != null) { writer.Write(materialDataInfo.Textures.LongCount()); } else { writer.Write(0L); } writer.Write((uint)OWMatType.Material); writer.Write(teResourceGUID.Index(MaterialInfo.ShaderSource)); writer.Write(MaterialInfo.MaterialIDs.Count); foreach (ulong id in MaterialInfo.MaterialIDs) { writer.Write(id); } if (materialDataInfo.Textures != null) { foreach (KeyValuePair <ulong, uint> texture in materialDataInfo.Textures) { FindLogic.Combo.TextureInfoNew textureInfo = Info.Textures[texture.Key]; if (stream is FileStream fs) { writer.Write(Combo.GetScratchRelative(textureInfo.GUID, Path.GetDirectoryName(fs.Name), $@"..\Textures\{textureInfo.GetNameIndex()}.dds")); } else { writer.Write($@"..\Textures\{textureInfo.GetNameIndex()}.dds"); } writer.Write(texture.Value); } } } }