コード例 #1
0
        private void SaveFigure()
        {
            if (lvTSOFiles.SelectedIndices.Count == 0)
            {
                return;
            }

            Figure fig;

            if (viewer.TryGetFigure(out fig))
            {
                SaveFileDialog dialog = new SaveFileDialog();
                int            index  = lvTSOFiles.SelectedIndices[0];
                TSOFile        tso    = fig.TSOList[index];
                dialog.FileName    = tso.FileName;
                dialog.Filter      = "tso files|*.tso|tmo files|*.tmo";
                dialog.FilterIndex = 0;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string dest_file = dialog.FileName;
                    string extension = Path.GetExtension(dest_file);
                    if (extension == ".tso")
                    {
                        tso.Save(dest_file);
                    }
                    if (extension == ".tmo")
                    {
                        TMOFile tmo = fig.Tmo;
                        tmo.SaveTransformationMatrixToFrame(0);
                        tmo.Save(dest_file);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        private void btnSave_Click(object sender, EventArgs e)
        {
            Figure fig;

            if (viewer.TryGetFigure(out fig))
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter      = "png files|*.png|tmo files|*.tmo";
                dialog.FilterIndex = 0;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string dest_file = dialog.FileName;
                    string extension = Path.GetExtension(dest_file);
                    if (extension == ".png")
                    {
                        TMOFile tmo = fig.Tmo.GenerateTMOFromTransformationMatrix();
                        SavePoseToFile(tmo, dest_file);
                    }
                    else
                    if (extension == ".tmo")
                    {
                        TMOFile tmo = fig.Tmo.GenerateTMOFromTransformationMatrix();
                        tmo.Save(dest_file);
                    }
                }
            }
        }
コード例 #3
0
 public void SaveSourceToFile()
 {
     if (source.frames != null)
     {
         string tmo_path = GetTmoPath();
         Console.WriteLine("Save File: " + tmo_path);
         source.Save(tmo_path);
     }
 }
コード例 #4
0
    public static void Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("TMOVise.exe <tmo file>");
            return;
        }
        string source_file = args[0];

        TMOFile tmo = new TMOFile();

        tmo.Load(source_file);
        TMOConstraint constraint = TMOConstraint.Load(@"angle-GRABIA-xyz.xml");

        foreach (TMONode node in tmo.nodes)
        {
            TMOMat mat = node.matrices[0];

            string  name = node.Name;
            Vector3 scaling;
            Vector3 translation = TMOMat.DecomposeMatrix(ref mat.m, out scaling);
            Vector3 angle       = TMOMat.ToAngleXYZ(mat.m);

            TMOConstraintItem item = constraint.GetItem(name);

            if (angle.X < item.Min.X)
            {
                angle.X = item.Min.X;
            }
            if (angle.X > item.Max.X)
            {
                angle.X = item.Max.X;
            }

            if (angle.Y < item.Min.Y)
            {
                angle.Y = item.Min.Y;
            }
            if (angle.Y > item.Max.Y)
            {
                angle.Y = item.Max.Y;
            }

            if (angle.Z < item.Min.Z)
            {
                angle.Z = item.Min.Z;
            }
            if (angle.Z > item.Max.Z)
            {
                angle.Z = item.Max.Z;
            }

            Quaternion q = TMOMat.ToQuaternionXYZ(angle);
            mat.m = Matrix.Scaling(scaling) * Matrix.RotationQuaternion(q) * Matrix.Translation(translation);
        }
        tmo.Save(@"out.tmo");
    }
コード例 #5
0
        public bool Process(string source_file)
        {
            TMOFile tmo = new TMOFile();

            tmo.Load(source_file);

            if (tmo.nodes[0].Path == "|W_Hips")
            {
                tmo_Transform(tmo);
            }

            string dest_file = source_file + ".tmp";

            Console.WriteLine("Save File: " + dest_file);
            tmo.Save(dest_file);

            File.Delete(source_file);
            File.Move(dest_file, source_file);
            Console.WriteLine("updated " + source_file);

            return(true);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: xvok16/TDCGExplorer
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("TMOFlip.exe <tmo file>");
                return;
            }
            string source_file = args[0];

            TMOFile tmo = new TMOFile();

            tmo.Load(source_file);

            TDCG.TMOFlip.TMOFlipProcessor processor = new TDCG.TMOFlip.TMOFlipProcessor();
            processor.Process(tmo);

            string dest_path = Path.GetDirectoryName(source_file);
            string dest_file = Path.GetFileNameWithoutExtension(source_file) + @".new.tmo";

            dest_path = Path.Combine(dest_path, dest_file);
            Console.WriteLine("Save File: " + dest_path);
            tmo.Save(dest_path);
        }
コード例 #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            // お待ちくださいダイアログを表示
            ProgressDialog pd = new ProgressDialog();

            pd.Show();
            pd.Message = "ファイルを変換しています。";

            try
            {
                // MMDPlayerを設定する
                v2t.initialize(referFileName2.FileName, referFileName3.FileName);

                // ヘビーセーブファイルを開く
                viewer.ClearFigureList();             // 前回読み込んだフィギュアを消去
                List <Figure> fig_list = viewer.LoadPNGFile(Path.Combine(Application.StartupPath, @"default.tdcgsav.png"));
                Figure        fig      = fig_list[0]; // 名前が長いので省略
                fig.UpdateNodeMapAndBoneMatrices();

                // 初期ポーズのTMOを得ておく
                v2t.SetInitPose(fig);

                // offsetをセット
                TMOFile tmo = fig.Tmo; // 名前が長いので省略
                v2t.Offset_position = tmo.nodes[0].Translation;

                // 初期フレームのポーズを得る
                v2t.GetRotation(ref tmo);
                tmo.SaveTransformationMatrixToFrameAdd();

                // 全フレームをtmoにコピー
                float fDiffTime = 30.0f / 60.0f;
                for (float iTime = 0.0f; iTime < v2t.Vmd.getMaxFrame(); iTime += fDiffTime)
                {
                    v2t.FrameMove(fDiffTime);
                    v2t.GetRotation(ref tmo);
                    tmo.SaveTransformationMatrixToFrameAdd(); // FrameにボーンのMatrixを保存

                    if ((int)(iTime / fDiffTime) % 10 == 0)
                    {
                        pd.Value = (int)((iTime / v2t.Vmd.getMaxFrame()) * (pd.Maximum - pd.Minimum));
                        this.Update();
                        System.Threading.Thread.Sleep(10);
                    }
                }

                // nodeのmatricesを、frameのmatricesにそっくりコピー
                tmo.NodeMatrices2FrameMatrices(2);

                // お待ちくださいダイアログを閉じる
                pd.Value = pd.Maximum;
                System.Threading.Thread.Sleep(1000);
                pd.Dispose();

                // 変換し、保存する
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    //タイトルを設定する
                    sfd.Title = "保存先のファイルを選択してください";
                    //はじめのファイル名を指定する
                    sfd.FileName = "新しいファイル.tmo";
                    //[ファイルの種類]に表示される選択肢を指定
                    sfd.Filter = "*.tmo|*.tmo|すべてのファイル|*.*";
                    //[ファイルの種類]ではじめに選択される選択肢
                    sfd.FilterIndex = 1;
                    //ダイアログボックスを閉じる前に現在のディレクトリを復元するようにする
                    sfd.RestoreDirectory = true;

                    if (sfd.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    tmo.Save(sfd.FileName);
                }

                // メッセージボックスを表示する
                MessageBox.Show("変換を完了しました。");
            }
            catch
            {
                // お待ちくださいダイアログを閉じる
                pd.Dispose();

                MessageBox.Show("エラーにより、変換できませんでした。");
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        private void bwCompress_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            Encrypter encrypter = new Encrypter();

            encrypter.SourcePath = @".";

            Dictionary <string, TAHEntry> entries = new Dictionary <string, TAHEntry>();

            foreach (TAHEntry entry in decrypter.Entries)
            {
                string file_name = entry.file_name;

                if (entry.flag % 2 == 1)
                {
                    file_name += TAHFileUtils.GetExtensionFromMagic(decrypter.ExtractResource(entry));
                }

                string ext = Path.GetExtension(file_name).ToLower();
                if (ext == ".tmo")
                {
                    string true_file_name = Path.Combine(encrypter.SourcePath, file_name.Replace("/", @"\"));
                    entries[true_file_name] = entry;
                    encrypter.Add(true_file_name);
                }
                else
                if (ext == ".png")
                {
                    string true_file_name = Path.Combine(encrypter.SourcePath, file_name.Replace("/", @"\"));
                    entries[true_file_name] = entry;
                    encrypter.Add(true_file_name);
                }
            }

            int entries_count = encrypter.Count;
            int current_index = 0;

            encrypter.GetFileEntryStream = delegate(string true_file_name)
            {
                Console.WriteLine("compressing {0}", true_file_name);
                TAHEntry entry = entries[true_file_name];
                string   ext   = Path.GetExtension(true_file_name).ToLower();

                Stream ret_stream = null;
                if (ext == ".tmo")
                {
                    TMOFile      tmo        = new TMOFile();
                    MemoryStream tmo_stream = new MemoryStream(decrypter.ExtractResource(entry));
                    tmo.Load(tmo_stream);

                    if (tmo.nodes[0].Path == "|W_Hips")
                    {
                        tmo_Transform(tmo);

                        tmo_stream.Seek(0, SeekOrigin.Begin);
                        tmo.Save(tmo_stream);
                    }
                    tmo_stream.Seek(0, SeekOrigin.Begin);
                    ret_stream = tmo_stream;
                }
                else
                if (ext == ".png")
                {
                    MemoryStream png_stream = new MemoryStream(decrypter.ExtractResource(entry));
                    ret_stream = new MemoryStream();
                    Process(png_stream, ret_stream);
                    ret_stream.Seek(0, SeekOrigin.Begin);
                }
                current_index++;
                int percent = current_index * 100 / entries_count;
                worker.ReportProgress(percent);
                return(ret_stream);
            };

            encrypter.Save(@"tmo-" + Path.GetFileName(source_file));
        }