Beispiel #1
0
        static async Task BatchExportItem(string path, IItemModel item, XivModelInfo secondaryModelInfo, Func <Task <List <XivRace> > > getRaces)
        {
            if (File.Exists(path))
            {
                return;
            }

            WriteLine($"Exporting {item.GetType().Name} {item.Name}: {Path.GetFileNameWithoutExtension(path)}");

            var metadata = new ExportMetadata();

            metadata.Name = item.Name;

            var mdl   = new Mdl(_gameDir, item.DataFile);
            var races = await getRaces();

            foreach (var race in races)
            {
                var mdlData = await mdl.GetMdlData(item, race, secondaryModelInfo);

                var textures = await TexTools.MaterialsHelper.GetMaterials(_gameDir, item, mdlData, race);

                var set = BatchExportSet(mdlData, textures);
                set.Name = TexTools.XivStringRaces.ToRaceGenderName(race);
                metadata.Sets.Add(set);
            }

            var metadataJson = JsonConvert.SerializeObject(metadata);

            File.WriteAllText(path, metadataJson);
        }
Beispiel #2
0
        static void BatchExportItem(string path, IItemModel item, XivModelInfo secondaryModelInfo, Func <IEnumerable <XivRace> > getRaces)
        {
            if (File.Exists(path))
            {
                return;
            }

            WriteLine($"Exporting {item.GetType().Name} {item.Name}: {Path.GetFileNameWithoutExtension(path)}");

            var items = new List <IItemModel>();

            var metadata = new ExportMetadata();

            metadata.Name = item.Name;

            var mdl   = new Mdl(_gameDir, item.DataFile);
            var races = getRaces();

            items.Add(item);

            if (item.ModelInfo is XivMonsterModelInfo)
            {
                var info = item.ModelInfo as XivMonsterModelInfo;
                if (info.ModelType.Equals(XivItemType.demihuman) && item is XivMount)
                {
                    items.Clear();
                    var met = item.Clone() as XivMount;
                    met.TertiaryCategory = "Head";
                    var top = item.Clone() as XivMount;
                    top.TertiaryCategory = "Body";
                    var glv = item.Clone() as XivMount;
                    glv.TertiaryCategory = "Hand";
                    var dwn = item.Clone() as XivMount;
                    dwn.TertiaryCategory = "Leg";
                    var sho = item.Clone() as XivMount;
                    sho.TertiaryCategory = "Feet";

                    items.Add(met);
                    items.Add(top);
                    items.Add(glv);
                    items.Add(dwn);
                    items.Add(sho);
                }
            }

            foreach (var race in races)
            {
                var mdlDatas    = new List <XivMdl>();
                var textureSets = new List <Dictionary <string, ModelTextureData> >();

                foreach (var iItem in items)
                {
                    try
                    {
                        var mdlData = mdl.GetRawMdlData(iItem, race).Result;
                        if (mdlData != null)
                        {
                            mdlDatas.Add(mdlData);

                            textureSets.Add(TexTools.MaterialsHelper.GetMaterials(_gameDir, item, mdlData, race).Result);

                            continue;
                        }
                    }
                    catch
                    { }
                    WriteLine($"Failed to get {iItem.Name}。 Got null.");
                    if (items.Count > 1)
                    {
                        WriteLine($"{iItem.Name} has no components like {iItem.TertiaryCategory}.");
                    }
                }

                try
                {
                    var set = BatchExportSets(mdlDatas, textureSets);
                    set.Name = TexTools.XivStringRaces.ToRaceGenderName(race);
                    metadata.Sets.Add(set);
                }
                catch (NotImplementedException e)
                { }
            }
            if (metadata.Sets[0].Models.Count == 0)
            {
                WriteLine($"Empty model {item.Name}.");
                return;
            }

            var metadataJson = JsonConvert.SerializeObject(metadata);

            File.WriteAllText(path, metadataJson);

            WriteLine($"Exported {item.GetType().Name} {item.Name}: {Path.GetFileNameWithoutExtension(path)}");
        }