Exemplo n.º 1
0
        /// <summary>
        /// Assigns recursively a joint struct to a transform of the skeleton in the scene based on a mapping defined in a JointDesc instance.
        /// </summary>
        /// <param name="jointDesc">Contains name of the joint in the source and target skeleton</param>
        /// <param name="skeletonDesc">Has joint sequence property that is needed to look up the JointDesc structures of the child joints.</param>
        /// <param name="parent">"Root transform of the skeleton in the scene"</param>
        public void assignJointTransformFromDesc(JointDesc jointDesc, SkeletonDesc skeletonDesc, Transform parent)
        {
            name = jointDesc.name;
            if (jointDesc.targetName != "none")
            {
                transform = targetSearchDF(parent, jointDesc.targetName, 0, false);
                if (transform != null)
                {
                    Debug.Log("Assigned " + name + " to " + transform.name);
                }
                else
                {
                    Debug.Log("Could not assign " + name);
                }
            }
            else // skip joints without target
            {
                Debug.Log("Ignore " + name);
            }


            foreach (string name in jointDesc.children)
            {
                JointDesc childDesc = findJointDesc(skeletonDesc.jointDescs, name);
                if (childDesc == null)
                {
                    continue;
                }

                MGJoint childJoint = new MGJoint();
                childJoint.assignJointTransformFromDesc(childDesc, skeletonDesc, parent);
                children.Add(childJoint);
            }
        }
 public void initSkeletonFromExistingCharacter(Transform rootTransform, SkeletonDesc skeletonDesc)
 {
     if (rootTransform != null)
     {
         JointDesc jointDesc = skeletonDesc.jointDescs[0];
         root = new MGJoint();
         root.assignJointTransformFromDesc(jointDesc, skeletonDesc, rootTransform);
     }
     else
     {
         Debug.Log("no root transform defined");
     }
 }