コード例 #1
0
        public void SavePoseToFile()
        {
            foreach (TMOAnimItem item in items)
            {
                TMOFile tmo = GetTmo(item);

                if (tmo.frames != null)
                {
                    /*
                     * string tmo_file = item.GetTmoPath();
                     * Console.WriteLine("Save File: " + tmo_file);
                     * Directory.CreateDirectory(Path.GetDirectoryName(tmo_file));
                     * tmo.Save(tmo_file);
                     */

                    string png_file = item.GetPngPath();
                    Console.WriteLine("Save File: " + png_file);
                    PNGFile png = CreatePNGFile(item);
                    png.WriteTaOb += delegate(BinaryWriter bw)
                    {
                        PNGWriter pw = new PNGWriter(bw);
                        WritePose(pw, tmo);
                    };
                    png.Save(png_file);
                }
            }
        }
コード例 #2
0
        public void TranslateToBone(string origin, string bone)
        {
            Vector3 position_origin = new Vector3(0, 0, 0);
            Vector3 position_bone   = new Vector3(0, 0, 0);

            TMONode tmo_node;
            Matrix  m;

            TMOFile tmo = viewer.FigureList[0].Tmo;

            Dictionary <string, TMONode> nodemap = new Dictionary <string, TMONode>();

            foreach (TMONode node in tmo.nodes)
            {
                if (nodemap.ContainsKey(node.Name) == false)
                {
                    nodemap.Add(node.Name, node);
                }
            }

            if (nodemap.TryGetValue(origin, out tmo_node))
            {
                m = tmo_node.combined_matrix;
                position_origin = new Vector3(m.M41, m.M42, m.M43);
                if (nodemap.TryGetValue(bone, out tmo_node))
                {
                    Vector3 pan_out = new Vector3(0, 0, 10);

                    m             = tmo_node.combined_matrix;
                    position_bone = new Vector3(m.M41, m.M42, m.M43);

                    viewer.Camera.SetTranslation(position_bone - position_origin + pan_out);
                }
            }
        }
コード例 #3
0
        public void SetCenter(string bone)
        {
            Vector3 position;

            TMOFile tmo = viewer.FigureList[0].Tmo;

            Dictionary <string, TMONode> nodemap = new Dictionary <string, TMONode>();

            foreach (TMONode node in tmo.nodes)
            {
                if (nodemap.ContainsKey(node.Name) == false)
                {
                    nodemap.Add(node.Name, node);
                }
            }

            TMONode tmo_node;

            if (nodemap.TryGetValue(bone, out tmo_node))
            {
                Matrix m = tmo_node.combined_matrix;
                position = new Vector3(m.M41, m.M42, m.M43);
                viewer.Camera.SetCenter(position);
            }
        }
コード例 #4
0
        private void btnFlip_Click(object sender, EventArgs e)
        {
            int pngsave_row = pngSaveItemBindingSource.Position;
            int tmoanim_row = tmoAnimItemBindingSource.Position;

            if (pngsave_row == -1)
            {
                return;
            }

            if (pngsave_row >= viewer.FigureList.Count)
            {
                return;
            }

            TMOAnim tmoanim = pngsave.items[pngsave_row].tmoanim;

            if (tmoanim_row == -1)
            {
                return;
            }

            TMOAnimItem item = tmoanim.items[tmoanim_row];

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

            Figure fig = viewer.FigureList[pngsave_row];
            {
                TMOFile tmo = tmoanim.GetTmo(item);
                viewer.Solver.Solved = true;
                processor.Process(fig.Tmo);
                fig.UpdateNodeMapAndBoneMatrices();
            }
        }
コード例 #5
0
        private void gvTMOAnimItems_SelectionChanged(object sender, EventArgs e)
        {
            int pngsave_row = pngSaveItemBindingSource.Position;
            int tmoanim_row = tmoAnimItemBindingSource.Position;

            if (pngsave_row == -1)
            {
                return;
            }

            if (pngsave_row >= viewer.FigureList.Count)
            {
                return;
            }

            TMOAnim tmoanim = pngsave.items[pngsave_row].tmoanim;

            if (tmoanim_row == -1)
            {
                return;
            }

            TMOAnimItem item = tmoanim.items[tmoanim_row];

            viewer.MotionEnabled = false;

            Figure fig = viewer.FigureList[pngsave_row];
            {
                TMOFile tmo = tmoanim.GetTmo(item);
                viewer.Solver.Solved = true;
                fig.Tmo = tmo;
                fig.UpdateNodeMapAndBoneMatrices();
            }
        }
コード例 #6
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);
                    }
                }
            }
        }
コード例 #7
0
        public TMOFile CreateTmo(TMOAnimItem item)
        {
            TMOFile tmo = new TMOFile();

            if (item == null)
            {
                return(tmo);
            }

            string png_file = item.GetPngPath();
            string tmo_file = item.GetTmoPath();

            if (File.Exists(png_file))
            {
                Console.WriteLine("Load File: " + png_file);
                tmo = LoadPNGFile(png_file);
            }
            else if (File.Exists(tmo_file))
            {
                Console.WriteLine("Load File: " + tmo_file);
                tmo.Load(tmo_file);
            }
            tmo.TruncateFrame(0); // forced pose

            return(tmo);
        }
コード例 #8
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);
                    }
                }
            }
        }
コード例 #9
0
        public void Process(TMOFile tmo)
        {
            Dictionary <string, TMONode> nodemap;

            nodemap = new Dictionary <string, TMONode>();

            foreach (TMONode node in tmo.nodes)
            {
                nodemap.Add(node.Name, node);
            }

            char[] delim = { ' ' };
            using (StreamReader source = new StreamReader(File.OpenRead(GetFlipNodesPath())))
            {
                string line;
                while ((line = source.ReadLine()) != null)
                {
                    string[] tokens = line.Split(delim);
                    string   op     = tokens[0];
                    if (op == "flip")
                    {
                        Debug.Assert(tokens.Length == 2, "tokens length should be 2");
                        string cnode_name = tokens[1];
                        int    cnode_id   = nodemap[cnode_name].Id;

                        foreach (TMOFrame frame in tmo.frames)
                        {
                            TMOMat cmat = frame.matrices[cnode_id];
                            cmat.Flip();
                        }
                    }
                    else
                    if (op == "swap")
                    {
                        Debug.Assert(tokens.Length == 3, "tokens length should be 3");
                        string lnode_name = tokens[1];
                        string rnode_name = tokens[2];
                        int    lnode_id   = nodemap[lnode_name].Id;
                        int    rnode_id   = nodemap[rnode_name].Id;

                        foreach (TMOFrame frame in tmo.frames)
                        {
                            TMOMat lmat = frame.matrices[lnode_id];
                            TMOMat rmat = frame.matrices[rnode_id];
                            lmat.Flip();
                            rmat.Flip();
                            frame.matrices[lnode_id] = rmat;
                            frame.matrices[rnode_id] = lmat;
                        }
                    }
                }
            }

            foreach (TMONode node in tmo.nodes)
            {
                node.LinkMatrices(tmo.frames);
            }
        }
コード例 #10
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");
    }
コード例 #11
0
 private Matrix[] ClipBoneMatrices(TSOSubMesh sub_mesh, TMOFile tmo)
 {
     Matrix[] clipped_boneMatrices = new Matrix[sub_mesh.maxPalettes];
     for (int numPalettes = 0; numPalettes < sub_mesh.maxPalettes; numPalettes++)
     {
         TSONode tso_node = sub_mesh.GetBone(numPalettes);
         TMONode tmo_node = tmo.FindNodeByName(tso_node.Name);
         clipped_boneMatrices[numPalettes] = tso_node.OffsetMatrix * tmo_node.combined_matrix;
     }
     return(clipped_boneMatrices);
 }
コード例 #12
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        void WritePose(PNGWriter pw, TMOFile tmo)
        {
            byte[] cami = ReadFloats(GetCameraPath());
            byte[] lgta = ReadFloats(GetLightAPath());

            pw.WriteTDCG();
            pw.WritePOSE();
            pw.WriteCAMI(cami);
            pw.WriteLGTA(lgta);
            pw.WriteFTMO(tmo);
        }
コード例 #13
0
        private TMOFile InvertTmo(TMOFile tmo)
        {
            TMOFile output = tmo.Dup();

            foreach (TMONode node in tmo.nodes)
            {
                output.FindNodeByName(node.Name).Rotation
                    = Quaternion.Invert(node.Rotation);
            }

            return(output);
        }
コード例 #14
0
        private TMOFile DiffWorldTmo(TMOFile tmo1, TMOFile tmo2)
        {
            TMOFile output = tmo1.Dup();

            foreach (TMONode node in tmo1.nodes)
            {
                output.FindNodeByName(node.Name).Rotation
                    = Quaternion.Invert(tmo2.FindNodeByName(node.Name).GetWorldRotation()) *
                      node.GetWorldRotation();
            }

            return(output);
        }
コード例 #15
0
        private TMOFile MultiTmo(TMOFile tmo1, TMOFile tmo2)
        {
            TMOFile output = tmo1.Dup();

            foreach (TMONode node in tmo1.nodes)
            {
                output.FindNodeByName(node.Name).Rotation
                    = node.Rotation *
                      tmo2.FindNodeByName(node.Name).Rotation;
            }

            return(output);
        }
コード例 #16
0
        public Program(string defo_file, string prop_file)
        {
            tmo_defo = new TMOFile();
            tmo_defo.Load(defo_file);

            tmo_prop = new TMOFile();
            tmo_prop.Load(prop_file);

            nodes_length = tmo_defo.nodes.Length;
            Debug.Assert(nodes_length == tmo_prop.nodes.Length, "nodes length mismatch between base_a and base_b.");

            tmo_defo.LoadTransformationMatrixFromFrame(0);
            tmo_prop.LoadTransformationMatrixFromFrame(0);
        }
コード例 #17
0
        private void Slerp()
        {
            foreach (TMOAnimItem item in items)
            {
                TMOFile tmo = GetTmo(item);

                if (tmo.frames == null)
                {
                    continue;
                }

                source.SlerpFrameEndTo(tmo, item.Length, item.Accel);
            }
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
 public void SavePoseToFile(TMOFile tmo, string dest_file)
 {
     if (tmo.frames != null)
     {
         PNGFile png = CreatePNGFile();
         png.WriteTaOb += delegate(BinaryWriter bw)
         {
             PNGWriter pw = new PNGWriter(bw);
             WritePose(pw, tmo);
         };
         Debug.WriteLine("Save File: " + dest_file);
         png.Save(dest_file);
     }
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        void tmo_Transform(TMOFile tmo)
        {
            tpo_list.Tmo = tmo;

            foreach (TPOFile tpo in tpo_list.files)
            {
                Debug.Assert(tpo.Proportion != null, "tpo.Proportion should not be null");
                Proportion portion;
                if (portion_map.TryGetValue(tpo.ProportionName, out portion))
                {
                    tpo.Ratio = portion.Ratio;
                }
            }

            tpo_list.Transform();
        }
コード例 #20
0
        void tmo_Transform(TMOFile tmo)
        {
            Debug.Assert(nodes_length == tmo.nodes.Length, "nodes length mismatch between base and source.");

            int[] id_pair = tmo_defo.CreateNodeIdPair(tmo);

            int len = tmo.frames.Length;

            for (int i = 0; i < len; i++)
            {
                tmo.LoadTransformationMatrixFromFrame(i);

                for (int x = 0; x < nodes_length; x++)
                {
                    int y = id_pair[x];

                    Vector3 S0 = tmo_prop.nodes[x].Scaling;
                    Vector3 S1 = tmo_defo.nodes[x].Scaling;
                    Vector3 S2 = tmo.nodes[y].Scaling;

                    Quaternion R0 = tmo_prop.nodes[x].Rotation;
                    Quaternion R1 = tmo_defo.nodes[x].Rotation;
                    Quaternion R2 = tmo.nodes[y].Rotation;

                    Vector3 T0 = tmo_prop.nodes[x].Translation;
                    Vector3 T1 = tmo_defo.nodes[x].Translation;
                    Vector3 T2 = tmo.nodes[y].Translation;

                    // dS = S2 / S1
                    // S. = S0 * dS
                    tmo.nodes[y].Scaling = new Vector3(S0.X * S2.X / S1.X, S0.Y * S2.Y / S1.Y, S0.Z * S2.Z / S1.Z);

                    // dR = inv(R1) * R2
                    // R. = R0 * dR
                    tmo.nodes[y].Rotation = R0 * Quaternion.Invert(R1) * R2;

                    // dT = T2 - T1
                    // T. = T0 + dT
                    tmo.nodes[y].Translation = T0 + T2 - T1;
                }

                tmo.SaveTransformationMatrixToFrame(i);
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: xvok16/TDCGExplorer
        void tmo_Transform(TMOFile tmo)
        {
            tpo_list.Tmo = tmo;

            for (int i = 0; i < tpo_list.Count; i++)
            {
                TPOFile tpo = tpo_list[i];
                {
                    Debug.Assert(tpo.Proportion != null, "tpo.Proportion should not be null");
                    Proportion portion;
                    if (portion_map.TryGetValue(tpo.Proportion.ToString(), out portion))
                    {
                        tpo.Ratio = portion.Ratio;
                    }
                }
            }

            tpo_list.Transform();
        }
コード例 #22
0
        // 表情に関連するboneに影響を受ける頂点を数え上げる
        private int CalcNumFaceVertices(TMOFile tmo)
        {
            int n_vertex = 0;  // 表情の頂点の番号(通し番号)
            int n_inList = -1; // list中のvertexの番号(処理の前に++するために、初期値は0でなく-1としている)

            foreach (TSOSubMesh sub_mesh in mesh_list)
            {
                int n_inMesh = -1; // mesh中のvertexの番号(処理の前に++するために、初期値は0でなく-1としている)
                foreach (Vertex vertex in sub_mesh.vertices)
                {
                    n_inList++; // list中のvertexの番号を一つ増やす
                    n_inMesh++; // mesh中のvertexの番号を一つ増やす
                    int idx = inList_indices[n_inList];

                    if (idx == -1)
                    {
                        continue;
                    }

                    PMD_Vertex pmd_v = pmd.pmd_vertex[idx];

                    // -----------------------------------------------------
                    // 表情情報

                    // 表情に関連するboneに影響を受ける頂点であれば、情報を記憶する
                    foreach (SkinWeight skin_w in vertex.skin_weights)
                    {
                        // 表情に関連するboneに影響を受ける頂点であれば、表情用の頂点とする
                        if (FACE_BONE_MIN <= sub_mesh.bone_indices[skin_w.bone_index] &&
                            sub_mesh.bone_indices[skin_w.bone_index] <= FACE_BONE_MAX)
                        {
                            n_vertex++;
                            break;
                        }
                    }
                }
            }
            return(n_vertex);
        }
コード例 #23
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);
        }
コード例 #24
0
        public void CopyFaceFile(string face_file)
        {
            if (Tmo.frames == null)
            {
                return;
            }

            List <string> except_snames = new List <string>();

            except_snames.Add("Kami_Oya");

            if (!string.IsNullOrEmpty(face_file))
            {
                Console.WriteLine("Load File: " + face_file);
                TMOFile face_tmo = TMOAnim.LoadPNGFile(Path.Combine(FaceRoot, face_file));
                if (face_tmo.frames != null)
                {
                    Tmo.SaveTransformationMatrixToFrame(0);
                    Tmo.CopyChildrenNodeFrom(face_tmo, "face_oya", except_snames);
                    Tmo.LoadTransformationMatrixFromFrame(0);
                }
            }
        }
コード例 #25
0
        public static TMOFile LoadPNGFile(string source_file)
        {
            TMOFile tmo = new TMOFile();

            if (File.Exists(source_file))
            {
                try
                {
                    PNGFile png = new PNGFile();

                    png.Ftmo += delegate(Stream dest, int extract_length)
                    {
                        tmo.Load(dest);
                    };
                    png.Load(source_file);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                }
            }
            return(tmo);
        }
コード例 #26
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);
        }
コード例 #27
0
        private void gvTMOAnimItems_DoubleClick(object sender, EventArgs e)
        {
            int pngsave_row = pngSaveItemBindingSource.Position;
            int tmoanim_row = tmoAnimItemBindingSource.Position;

            if (pngsave_row == -1)
            {
                return;
            }

            if (pngsave_row >= viewer.FigureList.Count)
            {
                return;
            }

            TMOAnim tmoanim = pngsave.items[pngsave_row].tmoanim;

            if (tmoanim_row == -1)
            {
                return;
            }

            TMOAnimItem item = tmoanim.items[tmoanim_row];

            tmoAnimItemForm.SetTmoAnimItem(item);

            Figure fig = viewer.FigureList[pngsave_row];

            if (tmoAnimItemForm.ShowDialog(this) == DialogResult.OK)
            {
                tmoAnimItemBindingSource.ResetBindings(false);
                TMOFile tmo = tmoanim.GetTmo(item);
                viewer.Solver.Solved = true;
                fig.Tmo = tmo;
                fig.UpdateNodeMapAndBoneMatrices();
            }
        }
コード例 #28
0
        public void SetInitPose(Figure fig)
        {
            fig.UpdateBoneMatrices(true);

            // カス子の初期ポーズを記憶
            initPose = fig.Tmo.Dup();
            initPose.LoadTransformationMatrixFromFrame(0);

            // MMDの初期ポーズを記憶
            fig.TPOList["TDCG.Proportion.AAA_PMDInitPose"].Ratio = 1.0f;
            fig.TransformTpo();
            fig.UpdateBoneMatrices(true);

            TMOFile pmd_initPose = fig.Tmo.Dup();

            pmd_initPose.LoadTransformationMatrixFromFrame(0);
            pmd_initPose_diff   = DiffTmo(pmd_initPose, initPose);
            pmd_initPose_diff_w = DiffWorldTmo(pmd_initPose, initPose);

            // カス子の初期ポーズに戻しておく
            fig.TPOList["TDCG.Proportion.AAA_PMDInitPose"].Ratio = 0.0f;
            fig.TransformTpo();
            fig.UpdateBoneMatrices(true);
        }
コード例 #29
0
        public bool Process(string source_file)
        {
            List <TSOFigure> fig_list = new List <TSOFigure>();

            Console.WriteLine("Load File: " + source_file);
            PNGFile source      = new PNGFile();
            string  source_type = "";

            try
            {
                TSOFigure fig = null;
                TMOFile   tmo = null;

                source.Hsav += delegate(string type)
                {
                    source_type = type;

                    fig = new TSOFigure();
                    fig_list.Add(fig);
                };
                source.Pose += delegate(string type)
                {
                    source_type = type;
                };
                source.Scne += delegate(string type)
                {
                    source_type = type;
                };
                source.Cami += delegate(Stream dest, int extract_length)
                {
                    cami = new byte[extract_length];
                    dest.Read(cami, 0, extract_length);
                };
                source.Lgta += delegate(Stream dest, int extract_length)
                {
                    byte[] lgta = new byte[extract_length];
                    dest.Read(lgta, 0, extract_length);

                    fig      = new TSOFigure();
                    fig.lgta = lgta;
                    fig_list.Add(fig);
                };
                source.Ftmo += delegate(Stream dest, int extract_length)
                {
                    tmo = new TMOFile();
                    tmo.Load(dest);
                    fig.tmo = tmo;
                };
                source.Figu += delegate(Stream dest, int extract_length)
                {
                    byte[] figu = new byte[extract_length];
                    dest.Read(figu, 0, extract_length);

                    fig.figu = figu;
                };
                source.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                {
                    byte[] ftso = new byte[extract_length];
                    dest.Read(ftso, 0, extract_length);

                    TSOData tso = new TSOData();
                    tso.opt1 = BitConverter.ToUInt32(opt1, 0);
                    tso.ftso = ftso;
                    fig.TSOList.Add(tso);
                };

                source.Load(source_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            foreach (TSOFigure fig in fig_list)
            {
                TSOFigureList.Add(fig);
            }

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

            foreach (TSOFigure fig in TSOFigureList)
            {
                if (fig.tmo != null)
                {
                    if (fig.tmo.nodes[0].Path == "|W_Hips")
                    {
                        processor.Process(fig.tmo);
                    }
                }
            }

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

            Console.WriteLine("Save File: " + dest_file);
            source.WriteTaOb += delegate(BinaryWriter bw)
            {
                PNGWriter pw = new PNGWriter(bw);
                switch (source_type)
                {
                case "HSAV":
                    WriteHsav(pw);
                    break;

                case "POSE":
                    WritePose(pw);
                    break;

                case "SCNE":
                    WriteScne(pw);
                    break;
                }
            };
            source.Save(dest_file);

            return(true);
        }
コード例 #30
0
 private TMOFile UnitaryTmo(TMOFile tmo1, TMOFile tmo2)
 {
     return(MultiTmo(MultiTmo(InvertTmo(tmo2), tmo1), tmo2));
 }