示例#1
0
        public void Generate(string tso_file, string out_path, bool mqx_enabled)
        {
            string tso_filename = Path.GetFileName(tso_file);
            string mqo_file     = Path.Combine(out_path, Path.ChangeExtension(tso_filename, ".mqo"));
            string xml_file     = Path.Combine(out_path, Path.ChangeExtension(tso_filename, ".xml"));

            // モデル、テクスチャの作成
            using (MqoWriter mqo = new MqoWriter(mqo_file))
            {
                TSOFile tso = LoadTSO(tso_file);
                tso.SwitchBoneIndicesOnMesh();

                mqo.MqxEnabled = mqx_enabled;

                mqo.Write(tso);
                mqo.Close();

                ImportInfo ii = new ImportInfo();

                // テクスチャ情報
                foreach (TSOTex tex in tso.textures)
                {
                    ii.textures.Add(new ImportTextureInfo(tex));
                }

                // エフェクトの作成
                foreach (TSOEffect effect in tso.effects)
                {
                    ii.effects.Add(new ImportEffectInfo(effect));
                    File.WriteAllText(Path.Combine(out_path, effect.Name), effect.code, Encoding.Default);
                }

                // マテリアルの作成
                foreach (TSOMaterial mat in tso.materials)
                {
                    ii.materials.Add(new ImportMaterialInfo(mat));
                    File.WriteAllText(Path.Combine(out_path, mat.Name), mat.code, Encoding.Default);
                }

                ImportInfo.Save(xml_file, ii);
            }
        }
示例#2
0
        private void OpenTSOFile(string file)
        {
            string dir = OutPath;

            if (cbMakeSub.Checked)
            {
                dir = Path.Combine(dir, Path.GetFileNameWithoutExtension(file));

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
            }

            string mqo_path        = Path.Combine(dir, Path.ChangeExtension(Path.GetFileName(file), ".mqo"));
            string importinfo_path = Path.Combine(dir, Path.ChangeExtension(Path.GetFileName(file), ".xml"));

            try
            {
                label2.BackColor = Color.Tomato;
                label2.ForeColor = Color.White;
                label2.Text      = "Processing";
                label2.Invalidate();
                label2.Update();

                // モデル、テクスチャの作成
                using (MqoWriter mqo = new MqoWriter(mqo_path))
                {
                    TSOFile tso = new TSOFile(file);
                    tso.ReadAll();

                    if (rbBoneRokDeBone.Checked)
                    {
                        mqo.BoneMode = MqoBoneMode.RokDeBone;
                    }

                    mqo.Write(tso);
                    mqo.Close();

                    ImportInfo ii = new ImportInfo();

                    // テクスチャ情報
                    foreach (TSOTex i in tso.textures)
                    {
                        ii.textures.Add(new ImportTextureInfo(i));
                    }

                    // エフェクトの作成
                    foreach (TSOEffect i in tso.effects)
                    {
                        ii.effects.Add(new ImportEffectInfo(i));
                        File.WriteAllText(Path.Combine(dir, i.Name), i.code, Encoding.Default);
                    }

                    // マテリアルの作成
                    foreach (TSOMaterial i in tso.materials)
                    {
                        ii.materials.Add(new ImportMaterialInfo(i));
                        File.WriteAllText(Path.Combine(dir, i.Name), i.code, Encoding.Default);
                    }

                    ImportInfo.Save(importinfo_path, ii);
                }

                if (cbCopyTSO.Checked)
                {
                    string tso_path = Path.Combine(dir, Path.GetFileName(file));

                    if (file != tso_path)
                    {
                        File.Copy(file, tso_path, true);
                    }
                }
            }
            finally
            {
                label2.BackColor = SystemColors.Control;
                label2.BackColor = label2.Parent.BackColor;
                label2.ForeColor = SystemColors.ControlText;
                label2.Text      = "Drop TSO File Here!";
            }
        }