Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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}");
                }
            }
        }