Exemple #1
0
        public static void LoadMaterial(ulong guid, out teMaterial material, out teMaterialData materialData)
        {
            using (Stream matStream = OpenFile(guid)) {
                material = new teMaterial(matStream);

                using (Stream matDataStream = OpenFile(material.Header.MaterialData)) {
                    materialData = new teMaterialData(matDataStream);
                }
            }
        }
Exemple #2
0
        public static void SaveMaterial(string basePath, ulong materialGUID, string name)
        {
            string path    = Path.Combine(basePath, name, IO.GetFileName(materialGUID));
            string rawPath = Path.Combine(path, "raw");
            string imgPath = Path.Combine(path, "img");

            // IO.CreateDirectorySafe(path);
            IO.CreateDirectorySafe(rawPath);

            teMaterial material = new teMaterial(IO.OpenFile(materialGUID));

            IO.WriteFile(materialGUID, rawPath);
            IO.WriteFile(material.Header.ShaderSource, rawPath);
            IO.WriteFile(material.Header.ShaderGroup, rawPath);
            IO.WriteFile(material.Header.GUIDx03A, rawPath);
            IO.WriteFile(material.Header.MaterialData, rawPath);

            using (Stream stream = IO.OpenFile(material.Header.MaterialData)) {
                if (stream != null)
                {
                    teMaterialData materialData = new teMaterialData(stream);
                    if (materialData.Textures != null)
                    {
                        FindLogic.Combo.ComboInfo comboInfo = new FindLogic.Combo.ComboInfo();
                        foreach (var texture in materialData.Textures)
                        {
                            FindLogic.Combo.Find(comboInfo, texture.TextureGUID);
                            comboInfo.SetTextureName(texture.TextureGUID, texture.NameHash.ToString("X8"));
                        }

                        var context = new Combo.SaveContext(comboInfo);
                        Combo.SaveLooseTextures(null, imgPath, context);
                        context.Wait();
                    }
                }
            }

            teShaderGroup shaderGroup = new teShaderGroup(IO.OpenFile(material.Header.ShaderGroup));

            SaveShaderGroup(shaderGroup, path);
        }