예제 #1
0
        /// <summary>
        /// フィギュアを生成します。
        /// </summary>
        public Figure()
        {
            if (SliderMatrixEnabled)
            {
                slider_matrix = new SliderMatrix();
            }
            tmo         = new TMOFile();
            nodemap     = new Dictionary <TSONode, TMONode>();
            matrixStack = new MatrixStack();

            LightDirection = new Vector3(0.0f, 0.0f, -1.0f);
        }
예제 #2
0
        /// <summary>
        /// フィギュアを生成します。
        /// </summary>
        public Figure()
        {
            if (SliderMatrixEnabled)
            {
                slider_matrix = new SliderMatrix();
            }
            tmo         = new TMOFile();
            nodemap     = new Dictionary <TSONode, TMONode>();
            matrixStack = new MatrixStack();

            tpo_list.Load();

            string config_file = GetTPOConfigPath();

            if (File.Exists(config_file))
            {
                TPOConfig config = TPOConfig.Load(config_file);
                tpo_list.SetRatiosFromConfig(config);
            }
            LightDirection = new Vector3(0.0f, 0.0f, -1.0f);
        }
예제 #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];
            }
        }