Esempio n. 1
0
        public void applyChainState(FKChainState chain)
        {
            Vector3    startTranslation = parent.Translation;
            Quaternion startRotation    = parent.Rotation;

            FKLinkState linkState = chain[Owner.Name];

            //Figure out the new position using the parent's position.
            Vector3    newTrans = startTranslation + Quaternion.quatRotate(startRotation, linkState.LocalTranslation);
            Quaternion newRot   = startRotation * linkState.LocalRotation;

            //Transform to the real center point from the center of rotation
            newTrans -= Quaternion.quatRotate(ref newRot, ref centerOfRotationOffset);

            this.updatePosition(ref newTrans, ref newRot);

            if (ChainStateApplied != null)
            {
                ChainStateApplied.Invoke(this, chain);
            }

            foreach (var child in children)
            {
                child.applyChainState(chain);
            }
        }
Esempio n. 2
0
        public void applyChainState(FKChainState chain)
        {
            updateAction = () =>
            {
                FKLinkState linkState = chain[Owner.Name];

                Vector3    trans = linkState.LocalTranslation;
                Quaternion rot   = linkState.LocalRotation;

                this.updatePosition(ref trans, ref rot);

                if (ChainStateApplied != null)
                {
                    ChainStateApplied.Invoke(this, chain);
                }

                foreach (var child in children)
                {
                    child.applyChainState(chain);
                }
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Set this chain state to the blended version of the passed start and end states.
        /// </summary>
        /// <param name="start">The start state.</param>
        /// <param name="end">The end state.</param>
        /// <param name="blendAmount">The amount to blend.</param>
        public void setToBlendOf(FKChainState start, FKChainState end, float blendAmount)
        {
            if (blendAmount < 0.0f)
            {
                blendAmount = 0.0f;
            }
            else if (blendAmount > 1.0f)
            {
                blendAmount = 1.0f;
            }

            foreach (var stateName in start.ChainStateNames)
            {
                FKLinkState startState = start[stateName];
                FKLinkState endState   = end[stateName];

                Vector3    trans = startState.getBlendedLocalTranslation(endState, blendAmount);
                Quaternion rot   = startState.getBlendedLocalRotation(endState, blendAmount);

                setLinkState(stateName, trans, rot);
            }
        }
Esempio n. 4
0
 public Quaternion getBlendedLocalRotation(FKLinkState endState, float blendFactor)
 {
     return(localRotation.nlerp(ref endState.localRotation, ref blendFactor));
 }
Esempio n. 5
0
 public Vector3 getBlendedLocalTranslation(FKLinkState endState, float blendFactor)
 {
     return(localTranslation.lerp(ref endState.localTranslation, ref blendFactor));
 }