public override IAnimationChannel Copy()
    {
        List <float>      copiedKeyframes    = new List <float>(this.keyframes.ToArray());
        IAnimationChannel copiedMorphChannel = new MorphChannel(this.channelName, copiedKeyframes, this.canLoop, this.canMirror, this.isStreamed, this.lipsyncChannel, this.framerate);

        return(copiedMorphChannel);
    }
Ejemplo n.º 2
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);
            }
        }
    }
Ejemplo n.º 3
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;
            }
        }
    }