private Tuple <ModelDefinition, ImcVariant> GetMonsterModelDefinition() { const string ImcPathFormat = "chara/monster/m{0:D4}/obj/body/b{1:D4}/b{1:D4}.imc"; const string ModelPathFormat = "chara/monster/m{0:D4}/obj/body/b{1:D4}/model/m{0:D4}b{1:D4}.mdl"; string imcPath = string.Format(ImcPathFormat, ModelKey, BaseKey); string mdlPath = string.Format(ModelPathFormat, ModelKey, BaseKey); IO.PackCollection packs = this.Sheet.Collection.PackCollection; if (!packs.TryGetFile(imcPath, out IO.File imcFileBase) || !packs.TryGetFile(mdlPath, out IO.File mdlFileBase) || !(mdlFileBase is ModelFile)) { throw new InvalidOperationException($"Unable to find files for {this}."); } try { ModelDefinition model = ((ModelFile)mdlFileBase).GetModelDefinition(); ImcFile imcFile = new ImcFile(imcFileBase); ImcVariant variant = imcFile.GetVariant(Variant); return(Tuple.Create(model, variant)); } catch (Exception ex) { throw new InvalidOperationException($"Unable to load model for {this}.", ex); } }
public SgbGroup1CEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); this.Name = buffer.ReadString(offset + Header.NameOffset + 9); string mdlFilePath = buffer.ReadString(offset + Header.ModelFileOffset + 9); if (!string.IsNullOrWhiteSpace(mdlFilePath)) { SaintCoinach.IO.File file; if (mdlFilePath.Contains(".mdl")) { if (packs.TryGetFile(mdlFilePath, out file)) { this.Model = ((Graphics.ModelFile)file).GetModelDefinition().GetModel(ModelQuality.High); } } else if (mdlFilePath.Contains(".sgb")) { if (packs.TryGetFile(mdlFilePath, out file)) { this.Gimmick = new Sgb.SgbFile(file); } } } }
private Image BuildImage(string size) { const string MapFileFormat = "ui/map/{0}/{1}{2}_{3}.tex"; if (string.IsNullOrEmpty(Id)) { return(null); } string fileName = Id.ToString().Replace("/", ""); IO.PackCollection pack = Sheet.Collection.PackCollection; string filePath = string.Format(MapFileFormat, Id, fileName, string.Empty, size); if (!pack.TryGetFile(filePath, out IO.File file)) { return(null); } ImageFile imageFile = new ImageFile(file.Pack, file.CommonHeader); string maskPath = string.Format(MapFileFormat, Id, fileName, "m", size); if (pack.TryGetFile(maskPath, out IO.File mask)) { // Multiply the mask against the file. ImageFile maskFile = new ImageFile(mask.Pack, mask.CommonHeader); return(MultiplyBlend(imageFile, maskFile)); } return(imageFile.GetImage()); }
public SgbModelEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); this.Name = buffer.ReadString(offset + Header.NameOffset); ModelFilePath = buffer.ReadString(offset + Header.ModelFileOffset); CollisionFilePath = buffer.ReadString(offset + Header.CollisionFileOffset); if (!string.IsNullOrWhiteSpace(ModelFilePath)) { SaintCoinach.IO.File mdlFile; if (packs.TryGetFile(ModelFilePath, out mdlFile)) { this.Model = new TransformedModel(((Graphics.ModelFile)mdlFile).GetModelDefinition(), Header.Translation, Header.Rotation, Header.Scale); } } if (!string.IsNullOrWhiteSpace(CollisionFilePath)) { SaintCoinach.IO.File pcbFile; if (packs.TryGetFile(CollisionFilePath, out pcbFile)) { this.CollisionFile = new Pcb.PcbFile(pcbFile); } } }
public LgbModelEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); this.Name = buffer.ReadString(offset + Header.NameOffset); ModelFilePath = buffer.ReadString(offset + Header.ModelFileOffset); CollisionFilePath = buffer.ReadString(offset + Header.CollisionFileOffset); if (!string.IsNullOrWhiteSpace(ModelFilePath)) { SaintCoinach.IO.File mdlFile; if (packs.TryGetFile(ModelFilePath, out mdlFile)) { this.Model = new TransformedModel(((Graphics.ModelFile)mdlFile).GetModelDefinition(), Header.Translation, Header.Rotation, Header.Scale); } } if (!string.IsNullOrWhiteSpace(CollisionFilePath)) { try { SaintCoinach.IO.File pcbFile; if (packs.TryGetFile(CollisionFilePath, out pcbFile)) { this.CollisionFile = new Pcb.PcbFile(pcbFile); } } catch (Exception ex) { Debug.WriteLine($"{Name} at 0x{offset:X} PcbFile failure: {ex.Message}"); } } }
public LgbEventObjectEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); this.Name = buffer.ReadString(offset + Header.NameOffset); if (Collection == null) { LoadSheets(packs); } foreach (Ex.IDataRow row in EventObjectSheet) { if (row.Key == this.Header.EventObjectId) { var sg = row.GetRaw(11); foreach (Ex.IDataRow row2 in ExportedSgSheet) { if (row2.Key == (ushort)sg) { var path = ((SaintCoinach.Text.XivString)row2.GetRaw(0)).ToString(); if (!string.IsNullOrEmpty(path)) { SaintCoinach.IO.File file; if (packs.TryGetFile(path, out file)) { this.Gimmick = new Sgb.SgbFile(file); } } break; } } break; } } }
public LgbGimmickEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); byte[] Unknown = new byte[100]; System.Buffer.BlockCopy(buffer, offset + System.Runtime.InteropServices.Marshal.SizeOf <HeaderData>(), Unknown, 0, 100); foreach (var c in Unknown) { if (c == 101) { System.Diagnostics.Debugger.Break(); } } this.Name = buffer.ReadString(offset + Header.NameOffset); var gimmickFilePath = buffer.ReadString(offset + Header.GimmickFileOffset); if (!string.IsNullOrWhiteSpace(gimmickFilePath)) { SaintCoinach.IO.File file; if (packs.TryGetFile(gimmickFilePath, out file)) { this.Gimmick = new Sgb.SgbFile(file); } } }
public SgbGimmickEntry(IO.PackCollection packs, byte[] buffer, int offset) { this.Header = buffer.ToStructure <HeaderData>(offset); this.Name = buffer.ReadString(offset + Header.NameOffset); var sgbFileName = buffer.ReadString(offset + Header.GimmickFileOffset); if (!string.IsNullOrWhiteSpace(sgbFileName)) { SaintCoinach.IO.File file; if (packs.TryGetFile(sgbFileName, out file)) { this.Gimmick = new SgbFile(file); } } }