コード例 #1
0
        private void gvTPONodes_SelectionChanged(object sender, EventArgs e)
        {
            int     tpofile_row = tpoFileBindingSource.Position;
            TPOFile tpo         = TPOList[tpofile_row];

            int     tponode_row = tpoNodeBindingSource.Position;
            TPONode tponode     = tpo.nodes[tponode_row];

            tpoCommandBindingSource.DataSource = tponode.commands;

            gvCommands.Rows.Clear();
            bool    inv_scale_on_children;
            Vector3 scaling = tponode.GetScaling(out inv_scale_on_children);

            gvCommands.Rows.Add(new string[] { "Scale", scaling.X.ToString(), scaling.Y.ToString(), scaling.Z.ToString() });
            cbInverseScaleOnChildren.Checked = inv_scale_on_children;

            Vector3 angle = tponode.GetAngle();

            gvCommands.Rows.Add(new string[] { "Rotate", angle.X.ToString(), angle.Y.ToString(), angle.Z.ToString() });

            Vector3 translation = tponode.GetTranslation();

            gvCommands.Rows.Add(new string[] { "Move", translation.X.ToString(), translation.Y.ToString(), translation.Z.ToString() });
        }
コード例 #2
0
        void SaveTpoScript(TPOFile tpo)
        {
            string script_file = Path.Combine(ProportionList.GetProportionPath(), GetProportionClassName(tpo) + ".cs");

            using (StreamWriter sw = File.CreateText(script_file))
            {
                DumpTpoScript(tpo, sw);
            }
        }
コード例 #3
0
        private void gvPortions_SelectionChanged(object sender, EventArgs e)
        {
            int     tpofile_row = tpoFileBindingSource.Position;
            TPOFile tpo         = TPOList[tpofile_row];

            TPOList.ClearRatios();
            tpo.Ratio = 1.0f;
            Transform();

            tpoNodeBindingSource.DataSource = tpo.nodes;
        }
コード例 #4
0
        private void gvCommands_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int     tpofile_row = tpoFileBindingSource.Position;
            TPOFile tpo         = TPOList[tpofile_row];

            int     tponode_row = tpoNodeBindingSource.Position;
            TPONode tponode     = tpo.nodes[tponode_row];

            UpdateTpoNodeFactor(e.RowIndex, tponode);
            tpoCommandBindingSource.ResetBindings(false);

            Transform();
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        private void slider_ValueChanged(object sender, EventArgs e)
        {
            ProportionSlider slider = sender as ProportionSlider;

            {
                TPOFile tpo = slider.Tag as TPOFile;
                if (tpo != null)
                {
                    tpo.Ratio = slider.Ratio;
                }
            }

            Transform();
        }
コード例 #6
0
        void DumpTpoScript(TPOFile tpo, StreamWriter sw)
        {
            sw.WriteLine("using System;");
            sw.WriteLine("using System.Collections.Generic;");
            sw.WriteLine("using System.IO;");
            sw.WriteLine("using Microsoft.DirectX;");
            sw.WriteLine("using Microsoft.DirectX.Direct3D;");
            sw.WriteLine("using TDCG;");
            sw.WriteLine("//css_reference Microsoft.DirectX.dll;");
            sw.WriteLine("//css_reference Microsoft.DirectX.Direct3D.dll;");
            sw.WriteLine("//css_reference Microsoft.DirectX.Direct3DX.dll;");
            sw.WriteLine("");
            sw.WriteLine("namespace {0}", name_space);
            sw.WriteLine("{");
            sw.WriteLine("    public class {0} : IProportion", GetProportionClassName(tpo));
            sw.WriteLine("    {");
            sw.WriteLine("        Dictionary<string, TPONode> nodes;");
            sw.WriteLine("        public Dictionary<string, TPONode> Nodes { set { nodes = value; }}");
            sw.WriteLine("");
            sw.WriteLine("        public void Execute()");
            sw.WriteLine("        {");

            sw.Write(indent); sw.WriteLine("TPONode node;");
            foreach (TPONode tponode in tpo.nodes)
            {
                bool command_exist = false;
                foreach (TPOCommand command in tponode.commands)
                {
                    if (command.Type != TPOCommandType.Scale0)
                    {
                        command_exist = true;
                        break;
                    }
                }
                if (command_exist)
                {
                    sw.WriteLine("");
                    sw.Write(indent); sw.WriteLine("node = nodes[\"{0}\"];", tponode.Name);
                }
                foreach (TPOCommand command in tponode.commands)
                {
                    WriteTpoCommandLine(command, sw);
                }
            }
            sw.WriteLine("        }");
            sw.WriteLine("    }");
            sw.WriteLine("}");
        }
コード例 #7
0
        private void cbInverseScaleOnChildren_CheckedChanged(object sender, EventArgs e)
        {
            int     tpofile_row = tpoFileBindingSource.Position;
            TPOFile tpo         = TPOList[tpofile_row];

            int     tponode_row = tpoNodeBindingSource.Position;
            TPONode tponode     = tpo.nodes[tponode_row];

            bool inv_scale_on_children;

            tponode.SetScaling(tponode.GetScaling(out inv_scale_on_children), cbInverseScaleOnChildren.Checked);

            tpoCommandBindingSource.ResetBindings(false);

            Transform();
        }
コード例 #8
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();
        }
コード例 #9
0
        private void gvCommands_MouseWheel(object sender, MouseEventArgs e)
        {
            DataGridView.HitTestInfo hit = gvCommands.HitTest(e.X, e.Y);
            if (hit.Type == DataGridViewHitTestType.Cell)
            {
                IncrementGridViewCell(hit.RowIndex, hit.ColumnIndex, e.Delta);

                int     tpofile_row = tpoFileBindingSource.Position;
                TPOFile tpo         = TPOList[tpofile_row];

                int     tponode_row = tpoNodeBindingSource.Position;
                TPONode tponode     = tpo.nodes[tponode_row];

                UpdateTpoNodeFactor(hit.RowIndex, tponode);
                tpoCommandBindingSource.ResetBindings(false);

                Transform();
            }
        }
コード例 #10
0
        // TPOConfig.xmlを書き出す
        public void SaveTPOConfig(string path)
        {
            TPOConfig config = new TPOConfig();

            Figure fig;

            if (viewer.TryGetFigure(out fig))
            {
                config.Proportions = new Proportion[fig.TPOList.Count];
                for (int i = 0; i < fig.TPOList.Count; i++)
                {
                    config.Proportions[i] = new Proportion();
                }

                for (int i = 0; i < fig.TPOList.Count; i++)
                {
                    TPOFile    tpo     = fig.TPOList[i];
                    Proportion portion = config.Proportions[i];
                    portion.ClassName = tpo.ProportionName;
                    portion.Ratio     = tpo.Ratio;
                }
            }
            config.Save(Path.Combine(path, @"TPOConfig.xml"));
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        private void SaveTPOConfig()
        {
            TPOConfig config = new TPOConfig();

            Figure fig;

            if (viewer.TryGetFigure(out fig))
            {
                config.Proportions = new Proportion[fig.TPOList.Count];
                for (int i = 0; i < fig.TPOList.Count; i++)
                {
                    config.Proportions[i] = new Proportion();
                }

                for (int i = 0; i < fig.TPOList.Count; i++)
                {
                    TPOFile    tpo     = fig.TPOList[i];
                    Proportion portion = config.Proportions[i];
                    portion.ClassName = tpo.ProportionName;
                    portion.Ratio     = tpo.Ratio;
                }
            }
            config.Save(Figure.GetTPOConfigPath());
        }
コード例 #12
0
 string GetProportionClassName(TPOFile tpo)
 {
     return(tpo.ProportionName.Substring(name_space.Length + 1));
 }