Exemplo n.º 1
0
        /// <summary>
        /// モーフ変形の対象となるノードを選択します。
        /// </summary>
        /// <param name="tmo">対象tmo</param>
        /// <returns>ノードリスト</returns>
        public List <TMONode> SelectNodes(TMOFile tmo)
        {
            List <TMONode> select_nodes = new List <TMONode>();

            foreach (string root_name in nodes_range.root_names)
            {
                TMONode root_node = tmo.FindNodeByName(root_name);
                if (root_node != null)
                {
                    AddTreeNodes(select_nodes, root_node);
                }
            }
            return(select_nodes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 指定tmoにある指定名称(短い形式)のnodeを同じ名称のnodeに複写します。
        /// </summary>
        /// <param name="motion">tmo</param>
        /// <param name="name">node名称(短い形式)</param>
        public void CopyNodeFrom(TMOFile motion, string name)
        {
            TMONode node = this.FindNodeByName(name);

            if (node == null)
            {
                return;
            }
            TMONode motion_node = motion.FindNodeByName(name);

            if (motion_node == null)
            {
                return;
            }
            node.CopyMatFrom(motion_node);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 指定tmoにある指定名称(短い形式)のnodeを同じ名称のnodeに複写します。
        /// ただし複写の対象は子node以降です。指定nodeは複写しません。
        /// また、除外node以降のnodeは複写しません。
        /// </summary>
        /// <param name="motion">tmo</param>
        /// <param name="name">node名称(短い形式)</param>
        /// <param name="except_names">除外node名称(短い形式)リスト</param>
        public void CopyChildrenNodeFrom(TMOFile motion, string name, List <string> except_names)
        {
            TMONode node = this.FindNodeByName(name);

            if (node == null)
            {
                return;
            }
            TMONode motion_node = motion.FindNodeByName(name);

            if (motion_node == null)
            {
                return;
            }
            node.CopyChildrenMatFrom(motion_node, except_names);
        }
Exemplo n.º 4
0
 /// <summary>
 /// モーフ変形の対象となるノードを選択します。
 /// </summary>
 /// <param name="tmo">対象tmo</param>
 /// <returns>ノードリスト</returns>
 public List<TMONode> SelectNodes(TMOFile tmo)
 {
     List<TMONode> select_nodes = new List<TMONode>();
     foreach (string root_name in nodes_range.root_names)
     {
     TMONode root_node = tmo.FindNodeByName(root_name);
     if (root_node != null)
         AddTreeNodes(select_nodes, root_node);
     }
     return select_nodes;
 }
Exemplo n.º 5
0
        private void OpenNiSolve()
        {
            Figure fig;

            if (TryGetFigure(out fig))
            {
                IntPtr ptr = NiSimpleTracker.GetJointPos();
                for (int i = 0; i < 15; i++)
                {
                    ni_joint_ary[i] = (XnSkeletonJointPosition)Marshal.PtrToStructure(ptr, typeof(XnSkeletonJointPosition));
                    ptr             = (IntPtr)(ptr.ToInt32() + Marshal.SizeOf(typeof(XnSkeletonJointPosition)));
                }

                if (ni_joint_ary[0].confidence < 0.5f)
                {
                    return;
                }

                for (int i = 0; i < 15; i++)
                {
                    ni_joint_map[ni_joint_names[i]] = ni_joint_ary[i];
                }

                TMOFile tmo = fig.Tmo;
                {
                    Vector3 p0 = tmo.FindNodeByName("W_Hips").Translation;
                    Vector3 p1 = ToWorldPosition(Mean(ni_joint_map["LeftHip"].position, ni_joint_map["RightHip"].position));
                    if (ni_model_translation == Vector3.Empty)
                    {
                        ni_model_translation = p1 - p0;
                    }
                    tmo.FindNodeByName("W_Hips").Translation = p1 - ni_model_translation;
                }

                tmo.nodemap["|W_Hips"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3"].Rotation        = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_Neck"].Rotation = Quaternion.Identity;
                //tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_Neck|Head"].Rotation = Quaternion.Identity;

                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm|W_RightArmRoll|W_RightForeArm"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm|W_RightArmRoll|W_RightForeArm|W_RightForeArmRoll|W_RightHand"].Rotation = Quaternion.Identity;

                tmo.nodemap["|W_Hips|W_RightHips_Dummy|W_RightUpLeg"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg|W_RightLegRoll|W_RightFoot"].Rotation = Quaternion.Identity;

                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm|W_LeftArmRoll|W_LeftForeArm"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm|W_LeftArmRoll|W_LeftForeArm|W_LeftForeArmRoll|W_LeftHand"].Rotation = Quaternion.Identity;

                tmo.nodemap["|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg"].Rotation = Quaternion.Identity;
                tmo.nodemap["|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg|W_LeftLegRoll|W_LeftFoot"].Rotation = Quaternion.Identity;

                Quaternion q;
                if (TryNiRotationDirX(out q, ni_joint_map["LeftHip"], ni_joint_map["RightHip"]))
                {
                    tmo.FindNodeByName("W_Hips").Rotation = q;
                }

                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3", "Torso");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_Neck", "Neck");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_Neck|Head", "Head");

                //Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm", "LeftShoulder");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm|W_RightArmRoll|W_RightForeArm", "LeftElbow");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm|W_RightArmRoll|W_RightForeArm|W_RightForeArmRoll|W_RightHand", "LeftHand");

                Solve(tmo, "|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg", "LeftKnee");
                Solve(tmo, "|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg|W_RightLegRoll|W_RightFoot", "LeftFoot");

                //Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm", "RightShoulder");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm|W_LeftArmRoll|W_LeftForeArm", "RightElbow");
                Solve(tmo, "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm|W_LeftArmRoll|W_LeftForeArm|W_LeftForeArmRoll|W_LeftHand", "RightHand");

                Solve(tmo, "|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg", "RightKnee");
                Solve(tmo, "|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg|W_LeftLegRoll|W_LeftFoot", "RightFoot");

                fig.UpdateBoneMatricesWithoutTMOFrame();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 指定tmoにある指定名称(短い形式)のnodeを同じ名称のnodeに複写します。
 /// </summary>
 /// <param name="motion">tmo</param>
 /// <param name="name">node名称(短い形式)</param>
 public void CopyNodeFrom(TMOFile motion, string name)
 {
     TMONode node = this.FindNodeByName(name);
     if (node == null)
         return;
     TMONode motion_node = motion.FindNodeByName(name);
     if (motion_node == null)
         return;
     node.CopyMatFrom(motion_node);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 指定tmoにある指定名称(短い形式)のnodeを同じ名称のnodeに複写します。
 /// ただし複写の対象は子node以降です。指定nodeは複写しません。
 /// また、除外node以降のnodeは複写しません。
 /// </summary>
 /// <param name="motion">tmo</param>
 /// <param name="name">node名称(短い形式)</param>
 /// <param name="except_names">除外node名称(短い形式)リスト</param>
 public void CopyChildrenNodeFrom(TMOFile motion, string name, List<string> except_names)
 {
     TMONode node = this.FindNodeByName(name);
     if (node == null)
         return;
     TMONode motion_node = motion.FindNodeByName(name);
     if (motion_node == null)
         return;
     node.CopyChildrenMatFrom(motion_node, except_names);
 }