예제 #1
0
        /// <summary>
        /// Restores all the bones used by poses in the set to default (post DNA) position.
        /// </summary>
        /// <param name="umaSkeleton">Skeleton to be reset.</param>
        /// <param name="logErrors"></param>
        public void RestoreBones(UMASkeleton umaSkeleton, bool logErrors = false)
        {
            if (umaSkeleton == null)
            {
                return;
            }

            ValidateBoneHashes();

            foreach (int hash in boneHashes)
            {
                if (!umaSkeleton.Restore(hash))
                {
                    if (logErrors)
                    {
                        //Since this generally logs like crazy which screws everything anyway, it might be nice to provide some useful information?
                        var    umaname  = umaSkeleton.GetBoneGameObject(umaSkeleton.rootBoneHash).GetComponentInParent <UMAAvatarBase>().gameObject.name;
                        string boneName = "";
                        foreach (PosePair pair in posePairs)
                        {
                            if (pair.primary != null)
                            {
                                foreach (UMABonePose.PoseBone bone in pair.primary.poses)
                                {
                                    if (bone.hash == hash)
                                    {
                                        boneName = bone.bone;
                                    }
                                }
                            }
                            if (pair.inverse != null)
                            {
                                foreach (UMABonePose.PoseBone bone in pair.inverse.poses)
                                {
                                    if (bone.hash == hash)
                                    {
                                        boneName = bone.bone;
                                    }
                                }
                            }
                        }
                        if (Debug.isDebugBuild)
                        {
                            Debug.LogWarning("Couldn't reset bone! " + boneName + " on " + umaname);
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Resets all the bones used by poses in the set to default position.
        /// </summary>
        /// <param name="umaSkeleton">Skeleton to be reset.</param>
        public void ResetBones(UMASkeleton umaSkeleton)
        {
            if (umaSkeleton == null)
            {
                return;
            }

            ValidateBoneHashes();

            foreach (int hash in boneHashes)
            {
                if (!umaSkeleton.Restore(hash))
                {
                    //Since this generally logs like crazy which screws everything anyway, it might be nice to provide some useful information?
                    string boneName = "";
                    foreach (PosePair pair in posePairs)
                    {
                        if (pair.primary != null)
                        {
                            foreach (UMABonePose.PoseBone bone in pair.primary.poses)
                            {
                                if (bone.hash == hash)
                                {
                                    boneName = bone.bone;
                                }
                            }
                        }
                        if (pair.inverse != null)
                        {
                            foreach (UMABonePose.PoseBone bone in pair.inverse.poses)
                            {
                                if (bone.hash == hash)
                                {
                                    boneName = bone.bone;
                                }
                            }
                        }
                    }
                    Debug.LogWarning("Couldn't reset bone! " + boneName);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Resets all the bones used by poses in the set to default position.
        /// </summary>
        /// <param name="umaSkeleton">Skeleton to be reset.</param>
        public void ResetBones(UMASkeleton umaSkeleton)
        {
            if (umaSkeleton == null) return;

            ValidateBoneHashes();

            foreach (int hash in boneHashes)
            {
                if (!umaSkeleton.Restore(hash))
                {
                    //Since this generally logs like crazy which screws everything anyway, it might be nice to provide some useful information?
                    string boneName = "";
                    foreach (PosePair pair in posePairs)
                    {
                        if (pair.primary != null)
                        {
                            foreach (UMABonePose.PoseBone bone in pair.primary.poses)
                            {
                                if (bone.hash == hash)
                                {
                                    boneName = bone.bone;
                                }
                            }
                        }
                        if (pair.inverse != null)
                        {
                            foreach (UMABonePose.PoseBone bone in pair.inverse.poses)
                            {
                                if (bone.hash == hash)
                                {
                                    boneName = bone.bone;
                                }
                            }
                        }
                    }
                    Debug.LogWarning("Couldn't reset bone! " + boneName);
                }
            }
        }
    public void SetValues()
    {
        if (expressionSet == null)
        {
            return;
        }
        if (skeleton == null)
        {
            return;
        }
        if (!initialized)
        {
            return;
        }

        float[] values = Values;


        MecanimJoint mecanimMask = MecanimJoint.None;

        if (!overrideMecanimNeck)
        {
            mecanimMask |= MecanimJoint.Neck;
        }
        if (!overrideMecanimHead)
        {
            mecanimMask |= MecanimJoint.Head;
        }
        if (!overrideMecanimJaw)
        {
            mecanimMask |= MecanimJoint.Jaw;
        }
        if (!overrideMecanimEyes)
        {
            mecanimMask |= MecanimJoint.Eye;
        }
        if (overrideMecanimJaw)
        {
            skeleton.Restore(jawHash);
        }

        for (int i = 0; i < values.Length; i++)
        {
            if ((MecanimAlternate[i] & mecanimMask) != MecanimJoint.None)
            {
                continue;
            }

            float weight = values[i];

            UMABonePose pose = null;
            if (weight > 0)
            {
                pose = expressionSet.posePairs[i].primary;
            }
            else
            {
                weight = -weight;
                pose   = expressionSet.posePairs[i].inverse;
            }
            if (pose == null)
            {
                continue;
            }

            //Debug.Log("SETTING VALUES: "+pose.name);
            pose.ApplyPose(skeleton, weight);
        }
    }