Exemple #1
0
    void CreateBaseChannels()
    {
        this.baseChannels = new List <IAnimationChannel>();

        for (int i = 0; i < this.transformLookup.Count; i++)
        {
            TransformBase transform = this.transformLookup[i];

            if (transform is MorphTransform)
            {
                //A small list of keyframes, used to sample values.
                List <float> keys = new List <float>(5)
                {
                    0.0f, 0.0f, 0.0f, 0.0f, 0.0f
                };
                MorphChannel morphChannel = new MorphChannel(transform.GetName(), keys, false, false, false, false, FRAMERATE);

                this.baseChannels.Add(morphChannel);
            }
            else if (transform is BoneTransform)
            {
                BoneTransform boneTransform = transform as BoneTransform;

                //Sample initial rotation value.
                Vector3        angle = boneTransform.GetInitialRotation().eulerAngles;
                List <Vector3> keys  = new List <Vector3>(5)
                {
                    angle, angle, angle, angle, angle
                };
                RotationChannel rotationChannel = new RotationChannel(boneTransform.GetName(), keys, false, false, false, false, FRAMERATE);

                this.baseChannels.Add(rotationChannel);
            }
        }
    }
Exemple #2
0
    public Quaternion GetLastRotationForChannel(string channelName)
    {
        Quaternion previousRotation = Quaternion.identity;

        if (this.previousClip != null)
        {
            IAnimationChannel previousChannel = this.previousClip.GetAnimationChannel(channelName);

            if (previousChannel != null && previousChannel is RotationChannel)
            {
                RotationChannel previousRotationChannel = previousChannel as RotationChannel;
                previousRotation = previousRotationChannel.GetPreviousRotation();
            }
        }
        else
        {
            //If we dont have a previous clip to extract a rotation from we use the initial transform for this channel.
            if (this.animationTransforms.ContainsKey(channelName))
            {
                BoneTransform boneTransform = this.animationTransforms[channelName] as BoneTransform;
                previousRotation = boneTransform.GetInitialRotation();
            }
        }

        return(previousRotation);
    }
    public override IAnimationChannel Copy()
    {
        List <Vector3>    copiedKeyframes       = new List <Vector3>(this.keyframes.ToArray());
        IAnimationChannel copiedRotationChannel = new RotationChannel(this.channelName, copiedKeyframes, this.canLoop, this.canMirror, this.isStreamed, this.lipsyncChannel, this.framerate);

        return(copiedRotationChannel);
    }
Exemple #4
0
    //Fill clip with animation channels from animation data from the database.
    FacialAnimationClip FillAnimationClip(FacialAnimationData data)
    {
        //Create animation clip to fill.
        FacialAnimationClip clip = new FacialAnimationClip(data.ID, this.baseChannels, FRAMERATE);

        for (int i = 0; i < data.RotationChannels.Count; i++)
        {
            RotationFacialAnimationChannel channelData = data.RotationChannels[i];

            RotationChannel rotationChannel = new RotationChannel(channelData.ChannelName, channelData.Keys, channelData.CanLoop, channelData.CanMirror, false, false, FRAMERATE);
            clip.AddAnimationChannel(rotationChannel);
        }

        for (int i = 0; i < data.MorphChannels.Count; i++)
        {
            MorphFacialAnimationChannel channelData = data.MorphChannels[i];
            MorphChannel morphChannel = new MorphChannel(channelData.ChannelName, channelData.Keys, channelData.CanLoop, channelData.CanMirror, false, false, FRAMERATE);
            clip.AddAnimationChannel(morphChannel);
        }

        return(clip);
    }
    public void SetLipSyncChannels(List <IAnimationChannel> animationChannels)
    {
        for (int i = 0; i < animationChannels.Count; i++)
        {
            IAnimationChannel channel     = animationChannels[i];
            string            channelName = channel.GetChannelName();

            switch (channelName)
            {
            case "Mid_Head_Jnt_03":
                jawChannel = channel as RotationChannel;
                break;

            case "Corner_In":
                cornerinChannel = channel as MorphChannel;
                break;

            case "I":
                iChannel = channel as MorphChannel;
                break;

            case "Lip_LowerUp":
                lowerUpChannel = channel as MorphChannel;
                break;

            case "Lip_LowerDown":
                lowerDownChannel = channel as MorphChannel;
                break;

            case "Lip_UpperUp":
                upperUpChannel = channel as MorphChannel;
                break;

            case "Lip_UpperDown":
                upperDownChannel = channel as MorphChannel;
                break;
            }
        }
    }