Exemplo n.º 1
0
        static ExportSetMetadata BatchExportSet(XivMdl mdlData, Dictionary <int, ModelTextureData> textures)
        {
            var set = new ExportSetMetadata();

            foreach (var meshData in mdlData.LoDList[0].MeshDataList)
            {
                var modelMetadata = new ExportModelMetadata();

                // Obj
                var objString = _ttObj.ExportObj(meshData);
                var objBytes  = System.Text.Encoding.ASCII.GetBytes(objString);
                modelMetadata.Obj = _repo.Write(".obj", objBytes);

                // Textures
                var textureData   = textures[meshData.MeshInfo.MaterialIndex];
                var pixelSettings = new PixelReadSettings(textureData.Width, textureData.Height, StorageType.Char, PixelMapping.RGBA);
                modelMetadata.Alpha    = _repo.Write(textureData.Alpha, pixelSettings, false);
                modelMetadata.Diffuse  = _repo.Write(textureData.Diffuse, pixelSettings, true);
                modelMetadata.Emissive = _repo.Write(textureData.Emissive, pixelSettings, false);
                modelMetadata.Normal   = _repo.Write(textureData.Normal, pixelSettings, true);
                modelMetadata.Specular = _repo.Write(textureData.Specular, pixelSettings, false);

                set.Models.Add(modelMetadata);
            }

            return(set);
        }
Exemplo n.º 2
0
        static void DoSingleExportSet(XivMdl mdlData, Dictionary <string, ModelTextureData> textures, ExportSetMetadata set)
        {
            TTModel model = TTModel.FromRaw(mdlData);

            foreach (var meshData in model.MeshGroups)
            {
                var modelMetadata = new ExportModelMetadata();

                // Obj
                var objString = _ttObj.ExportObj(meshData);
                var objBytes  = System.Text.Encoding.ASCII.GetBytes(objString);
                modelMetadata.Obj = _repo.Write(".obj", objBytes);

                // Textures
                try
                {
                    var textureData   = textures[meshData.Material];
                    var pixelSettings = new PixelReadSettings(textureData.Width, textureData.Height, StorageType.Char, PixelMapping.RGBA);
                    modelMetadata.Alpha    = _repo.Write(textureData.Alpha, pixelSettings, false);
                    modelMetadata.Diffuse  = _repo.Write(textureData.Diffuse, pixelSettings, true);
                    modelMetadata.Emissive = _repo.Write(textureData.Emissive, pixelSettings, false);
                    modelMetadata.Normal   = _repo.Write(textureData.Normal, pixelSettings, true);
                    modelMetadata.Specular = _repo.Write(textureData.Specular, pixelSettings, false);

                    set.Models.Add(modelMetadata);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    continue;
                }
            }
        }