/// <summary>
/// Utility method to add attachment points to an existing skeleton
/// </summary>
/// <param name="dstDir">the directory to which the modified skeleton will be saved</param>
/// <param name="skelFile">the name of the file to which the modified skeleton will be written</param>
/// <param name="skeleton">the original skeleton</param>
/// <param name="attachPoints">the list of attachment points</param>
private static void AddAttachments( string dstDir,
string skelFile,
Skeleton skeleton,
List<AttachmentPointNode> attachPoints )
{
if( skeleton.AttachmentPoints.Count > 0 &&
attachPoints.Count != skeleton.AttachmentPoints.Count )
log.WarnFormat( "Skeleton attachment points count ({0}) does not match new count ({1})",
skeleton.AttachmentPoints.Count, attachPoints.Count );
foreach( AttachmentPointNode attachPoint in attachPoints )
{
Quaternion rotate;
Vector3 translate, scale;
Matrix4 transform = attachPoint.Transform;
Matrix4.DecomposeMatrix( ref transform, out translate, out rotate, out scale );
Bone parentBone = skeleton.GetBone( attachPoint.ParentBone );
bool isDup = false;
foreach( AttachmentPoint tmp in skeleton.AttachmentPoints )
if( tmp.Name == attachPoint.Name )
isDup = true;
if( isDup )
continue;
skeleton.CreateAttachmentPoint( attachPoint.Name, parentBone.Handle, rotate, translate );
}
OgreSkeletonSerializer skelWriter = new OgreSkeletonSerializer();
skelWriter.ExportSkeleton( skeleton, dstDir + skelFile );
}