Example #1
0
        /// <summary>
        /// Finds the rigging in the model and matches it to the MoCap bone system.
        /// </summary>
        /// <param name="bones">bone data from the MoCap system</param>
        ///
        private void MatchBones(Bone[] bones)
        {
            boneList = new Dictionary <Bone, BoneObject>();
            string unmatchedBones = "";

            // create copies of the marker template
            foreach (Bone bone in bones)
            {
                BoneNameTranslationEntry entry = null;
                string boneName = boneNamePrefix + TranslateBoneName(bone.name, ref entry);
                // find the child in the model with the given bone name
                Transform boneNode = Utilities.FindInHierarchy(boneName, transform);
                if (boneNode != null)
                {
                    boneList[bone] = new BoneObject()
                    {
                        node = boneNode.gameObject, entry = entry
                    };
                    bone.buffer.EnsureCapacityForModifiers(modifiers);
                }
                else
                {
                    if (unmatchedBones.Length > 0)
                    {
                        unmatchedBones += ", ";
                    }
                    unmatchedBones += bone.name;
                }
            }

            if (unmatchedBones.Length > 0)
            {
                Debug.LogWarning("Could not find the following bones in Model '" + this.name + "': " + unmatchedBones);
            }
        }
Example #2
0
        /// <summary>
        /// Translates a bone name form the MoCap name into the Model name
        /// if defined in the table.
        /// </summary>
        /// <param name="name">the name in the MoCap scene</param>
        /// <returns>the translated name for the model</returns>
        ///
        private string TranslateBoneName(string name, ref BoneNameTranslationEntry actualEntry)
        {
            string translatedName = "undefined";

            foreach (BoneNameTranslationEntry entry in boneNameTranslationTable)
            {
                if (name == entry.nameMocap)
                {
                    if (entry.nameModel.Length > 0)
                    {
                        translatedName = entry.nameModel;
                    }
                    else
                    {
                        translatedName = name;
                    }
                    actualEntry = entry;
                    break;
                }
            }
            return(translatedName);
        }
		/// <summary>
		/// Translates a bone name form the MoCap name into the Model name
		/// if defined in the table.
		/// </summary>
		/// <param name="name">the name in the MoCap scene</param>
		/// <returns>the translated name for the model</returns>
		/// 
		private string TranslateBoneName(string name, ref BoneNameTranslationEntry actualEntry)
		{
			string translatedName = "undefined";
			foreach (BoneNameTranslationEntry entry in boneNameTranslationTable)
			{
				if (name == entry.nameMocap)
				{
					if (entry.nameModel.Length > 0)
					{
						translatedName = entry.nameModel;
					}
					else
					{
						translatedName = name;
					}
					actualEntry = entry;
					break;
				}
			}
			return translatedName;
		}