Engines/FlatRedBallXNA/FlatRedBall.Content/ModelAnimation/AnimationProcessor.cs
/// <summary>
/// Checks the bones to make sure the skeleton is valid.
/// </summary>
/// <param name="modelBone">The model bone to check.</param>
/// <param name="skeletonBone">The skeleton bone to check</param>
Checks the bones to make sure the skeleton is valid.
Checks the bones to make sure the skeleton is valid .
protected virtual void CheckBones(BoneContent modelBone, BoneContent skeletonBone)
        {
            if (modelBone.Name != skeletonBone.Name)
            {
                context.Logger.LogWarning("", inputSkeleton.Identity,
                "model bone " + modelBone.Name
                    + " does not match skeletone bone " + skeletonBone.Name);
            }
            if (modelBone.Children.Count != skeletonBone.Children.Count)
            {
                context.Logger.LogWarning("", inputSkeleton.Identity,
                    "model bone " + modelBone.Name + " has " + modelBone.Children.Count
                    + " children but corresponding skeletone bone has " + skeletonBone.Children.Count + " children");
            }
            float diff = modelBone.Transform.Translation.Length() - skeletonBone.Transform.Translation.Length();
            if (diff * diff > 0.0001f)
            {
                context.Logger.LogWarning("", inputSkeleton.Identity,
                    "model bone " + modelBone.Name + " translation "
                    + "(Lenght=" + modelBone.Transform.Translation.Length() + ")"
                    + " does not match translation of skeletone bone "
                    + skeletonBone.Name
                    + " (Lenght=" + skeletonBone.Transform.Translation.Length() + ")"
                    );
            }
            Dictionary<string, BoneContent> modelBoneDict = new Dictionary<string, BoneContent>();
            foreach (BoneContent mb in modelBone.Children)
            {
                modelBoneDict.Add(mb.Name, mb);
            }
            foreach (BoneContent sb in skeletonBone.Children)
            {
                if (modelBoneDict.ContainsKey(sb.Name))
                {
                    BoneContent mb = modelBoneDict[sb.Name];
                    CheckBones(mb, sb);
                }
                else
                {
                    context.Logger.LogWarning("", inputSkeleton.Identity,
                        "skeleton bone " + sb.Name + " was not found in model");
                }
            }
        }
protected virtual void CheckBones ( BoneContent modelBone , BoneContent skeletonBone ) { if ( modelBone . Name != skeletonBone . Name ) { context . Logger . LogWarning ( " " , inputSkeleton . Identity , " " + modelBone . Name + " " + skeletonBone . Name ) ; } if ( modelBone . Children . Count != skeletonBone . Children . Count ) { context . Logger . LogWarning ( " " , inputSkeleton . Identity , " " + modelBone . Name + " " + modelBone . Children . Count + " " + skeletonBone . Children . Count + " " ) ; } float diff = modelBone . Transform . Translation . Length ( ) - skeletonBone . Transform . Translation . Length ( ) ; if ( diff * diff > 0.0001f ) { context . Logger . LogWarning ( " " , inputSkeleton . Identity , " " + modelBone . Name + " " + " " + modelBone . Transform . Translation . Length ( ) + " " + " " + skeletonBone . Name + " " + skeletonBone . Transform . Translation . Length ( ) + " " ) ; } Dictionary < string , BoneContent > modelBoneDict = new Dictionary < string , BoneContent > ( ) ; foreach ( BoneContent mb in modelBone . Children ) { modelBoneDict . Add ( mb . Name , mb ) ; } foreach ( BoneContent sb in skeletonBone . Children ) { if ( modelBoneDict . ContainsKey ( sb . Name ) ) { BoneContent mb = modelBoneDict [ sb . Name ] ; CheckBones ( mb , sb ) ; } else { context . Logger . LogWarning ( " " , inputSkeleton . Identity , " " + sb . Name + " " ) ; } } }
Checks the bones to make sure the skeleton is valid.
Checks the bones to make sure the skeleton is valid .
modelBone
BoneContent
The model bone to check.
The model bone to check .
skeletonBone
BoneContent
The skeleton bone to check
The skeleton bone to check