CreateAttachmentPoint() public method

TODO: should this replace an existing attachment point with the same name?
public CreateAttachmentPoint ( string name, ushort parentHandle, Axiom.MathLib.Quaternion rotation, Vector3 translation ) : AttachmentPoint
name string
parentHandle ushort
rotation Axiom.MathLib.Quaternion
translation Vector3
return AttachmentPoint
Example #1
0
 /// <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 );
 }
        /// <summary>
        ///   Set up the attachment point in the skeleton or mesh based on the 
        ///   information in the attachPoint.
        /// </summary>
        /// <param name="transform">the world transform to apply to this object</param>
        /// <param name="attachPoint">the AttachmentPointNode with information about parent bone, and the relative transform</param>
        /// <param name="skeleton">the skeleton for whcih we may create the attachment (if there is a parent bone)</param>
        /// <param name="mesh">the mesh for which we may create the attachment point (if there is no parent bone)</param>
        protected void ProcessAttachmentPointNode( Matrix4 transform,
                                                  AttachmentPointNode attachPoint,
                                                  Skeleton skeleton, Mesh mesh )
        {
            string parentName = attachPoint.ParentBone;
            Bone parentBone = null;
            if( parentName != null )
                parentBone = skeleton.GetBone( parentName );

            Matrix4 attachPointTransform = attachPoint.Transform;
            if( parentBone == null )
            {
                // The parent bone will already have the transform in the hierarchy
                attachPointTransform = transform * attachPointTransform;
            }
            Quaternion orientation = MathHelpers.GetRotation( attachPointTransform );
            Vector3 position = m_UnitConversion * attachPointTransform.Translation;
            if( parentBone != null )
                skeleton.CreateAttachmentPoint( attachPoint.Name, parentBone.Handle, orientation, position );
            else
                mesh.CreateAttachmentPoint( attachPoint.Name, orientation, position );
            m_Log.InfoFormat( "Created attachment point: {0}", attachPoint.Name );
            m_Log.InfoFormat( "Parent Bone: {0}", parentName );
            m_Log.InfoFormat( "Orientation: {0}", orientation );
            m_Log.InfoFormat( "Position: {0}", position );
        }