Example #1
0
        /// <summary>
        /// Initialize the IK Chain.
        /// </summary>
        public void Initialize()
        {
            if (effector == null || transformCount == 0 || IKUtility.GetAncestorCount(effector) < transformCount - 1)
            {
                return;
            }

            m_Transforms            = new Transform[transformCount];
            m_DefaultLocalRotations = new Quaternion[transformCount];
            m_StoredLocalRotations  = new Quaternion[transformCount];

            var currentTransform = effector;
            int index            = transformCount - 1;

            while (currentTransform && index >= 0)
            {
                m_Transforms[index]            = currentTransform;
                m_DefaultLocalRotations[index] = currentTransform.localRotation;

                currentTransform = currentTransform.parent;
                --index;
            }
        }
Example #2
0
 private bool Validate()
 {
     if (effector == null)
     {
         return(false);
     }
     if (transformCount == 0)
     {
         return(false);
     }
     if (m_Transforms == null || m_Transforms.Length != transformCount)
     {
         return(false);
     }
     if (m_DefaultLocalRotations == null || m_DefaultLocalRotations.Length != transformCount)
     {
         return(false);
     }
     if (m_StoredLocalRotations == null || m_StoredLocalRotations.Length != transformCount)
     {
         return(false);
     }
     if (rootTransform == null)
     {
         return(false);
     }
     if (lastTransform != effector)
     {
         return(false);
     }
     if (target && IKUtility.IsDescendentOf(target, rootTransform))
     {
         return(false);
     }
     return(true);
 }
Example #3
0
 /// <summary>
 /// Override base class DoInitialize.
 /// </summary>
 protected override void DoInitialize()
 {
     m_Chain.transformCount = m_Chain.effector == null || IKUtility.GetAncestorCount(m_Chain.effector) < 2 ? 0 : 3;
     base.DoInitialize();
 }