Пример #1
0
        /// <summary>
        /// モーフライブラリを読み込みます。
        /// </summary>
        /// <param name="source_path">フォルダ名</param>
        public void Load(string source_path)
        {
            foreach (string group_path in Directory.GetDirectories(source_path))
            {
                //Debug.WriteLine("group_path: " + group_path);
                string group_name = Path.GetFileName(group_path);
                Debug.WriteLine("group_name: " + group_name);

                NodesRange nodes_range = NodesRange.Load(Path.Combine(group_path, @"NodesRange.xml"));
                MorphGroup group       = new MorphGroup(group_name, nodes_range);
                groups.Add(group);

                foreach (string tmo_file in Directory.GetFiles(Path.Combine(source_path, group_path), @"*.tmo"))
                {
                    //Debug.WriteLine("tmo_file: " + tmo_file);
                    string morph_name = Path.GetFileNameWithoutExtension(tmo_file);
                    Debug.WriteLine("morph_name: " + morph_name);

                    TMOFile tmo = new TMOFile();
                    tmo.Load(tmo_file);
                    tmo.LoadTransformationMatrixFromFrame(0);

                    Morph morph = new Morph(morph_name, tmo);
                    group.Items.Add(morph);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// モーフ変形を実行します。
        /// </summary>
        /// <param name="tmo">対象tmo</param>
        public void Morph(TMOFile tmo)
        {
            tmo.LoadTransformationMatrixFromFrame(0);

            Dictionary <TMONode, Matrix> mmap = new Dictionary <TMONode, Matrix>();

            foreach (MorphGroup group in groups)
            {
                List <TMONode> select_nodes = group.SelectNodes(tmo);

                foreach (TMONode select_node in select_nodes)
                {
                    foreach (Morph morph in group.Items)
                    {
                        if (morph.Ratio == 0.0f)
                        {
                            continue;
                        }

                        TMONode node    = morph.Tmo.FindNodeByName(select_node.Name);
                        Matrix  min     = select_node.TransformationMatrix;
                        Matrix  max     = node.TransformationMatrix;
                        Matrix  inv_min = Matrix.Invert(min);
                        if (!mmap.ContainsKey(select_node))
                        {
                            mmap[select_node] = min;
                        }
                        mmap[select_node] = mmap[select_node] * inv_min *SliderMatrix.GetMatrixRatio(min, max, morph.Ratio);
                    }
                }
            }

            foreach (TMONode select_node in mmap.Keys)
            {
                select_node.TransformationMatrix = mmap[select_node];
            }
        }
Пример #3
0
        /// <summary>
        /// モーフ変形を実行します。
        /// </summary>
        /// <param name="tmo">対象tmo</param>
        public void Morph(TMOFile tmo)
        {
            tmo.LoadTransformationMatrixFromFrame(0);

            Dictionary<TMONode, Matrix> mmap = new Dictionary<TMONode, Matrix>();

            foreach (MorphGroup group in groups)
            {
            List<TMONode> select_nodes = group.SelectNodes(tmo);

            foreach (TMONode select_node in select_nodes)
            {
                foreach (Morph morph in group.Items)
                {
                    if (morph.Ratio == 0.0f)
                        continue;

                    TMONode node = morph.Tmo.FindNodeByName(select_node.Name);
                    Matrix min = select_node.TransformationMatrix;
                    Matrix max = node.TransformationMatrix;
                    Matrix inv_min = Matrix.Invert(min);
                    if (! mmap.ContainsKey(select_node))
                        mmap[select_node] = min;
                    mmap[select_node] = mmap[select_node] * inv_min * SliderMatrix.GetMatrixRatio(min, max, morph.Ratio);
                }
            }
            }

            foreach (TMONode select_node in mmap.Keys)
            {
            select_node.TransformationMatrix = mmap[select_node];
            }
        }
Пример #4
0
        /// <summary>
        /// モーフライブラリを読み込みます。
        /// </summary>
        /// <param name="source_path">フォルダ名</param>
        public void Load(string source_path)
        {
            foreach (string group_path in Directory.GetDirectories(source_path))
            {
            //Debug.WriteLine("group_path: " + group_path);
            string group_name = Path.GetFileName(group_path);
            Debug.WriteLine("group_name: " + group_name);

            NodesRange nodes_range = NodesRange.Load(Path.Combine(group_path, @"NodesRange.xml"));
            MorphGroup group = new MorphGroup(group_name, nodes_range);
            groups.Add(group);

            foreach (string tmo_file in Directory.GetFiles(Path.Combine(source_path, group_path), @"*.tmo"))
            {
                //Debug.WriteLine("tmo_file: " + tmo_file);
                string morph_name = Path.GetFileNameWithoutExtension(tmo_file);
                Debug.WriteLine("morph_name: " + morph_name);

                TMOFile tmo = new TMOFile();
                tmo.Load(tmo_file);
                tmo.LoadTransformationMatrixFromFrame(0);

                Morph morph = new Morph(morph_name, tmo);
                group.Items.Add(morph);
            }
            }
        }