AchillesGames

Recreation Creation with XNA/Arithmetic Physics/Character Animation

Game Creation with XNA/Mathematics Physics/Character Animation

Character Animation[edit]

Right here now we have to differentiate between skeletal and keyframed animation. The primary level is to indicate find out how to get each sorts of animation working with XNA. Particular consideration must be locations on contraints given by the XNA framework (e.g. the shader 2.Zero mannequin doesn’t permit greater than 59 joints).

Introduction[edit]

Animation is simply an illusion- it’s created by a sequence of pictures. Every is a bit totally different from the final. We simply really feel such a bunch of pictures as a altering scene.
The most typical technique of presenting animation is as a movement image or video program, though there are different strategies. [1]
In Laptop based mostly animation there are two types of it: The little extra “classical”, from flip-books identified keyframe animation and the skeletal animation, which is by default identified from 3d-animation.

Keyframed Animation[edit]

Keyframe animation is an animation method, that originially was utilized in classical cartoons.
A Keyframe defines the start- and endpoint of an animation. they’re full of so known as interframes or inbetweens.

Historical past, Tradional Keyframe Animation[edit]

Within the traditioal keyframe animation, which e.g. was used for hand-drawn trickfilms, the senior artist (or key artist) would draw the keyframes. (Simply the vital photos of an animation)
After testing of the tough animation, he offers this to his assistand, and the assistand does the required “inbetweens and the clear up.

Computergraphics[edit]

In Computergraphics it’s the identical idea like in cartoon: The keyframes are created by the consumer and the interframes are supplemented by the pc.
The “Keyframe” saves parameters similar to place, rotation and scale of an object
The next inbetweens are interpolated by the pc.

Instance[edit]

An Object will transfer from one nook to an different.
The primary keyframe reveals the item within the high left nook and the second keyframe reveals it within the backside proper nook. Every part in between is interpolated.

Interpolation strategies[edit]

The previous sections talked about that some key-frame animations assist a number of interpolation strategies. An animation’s interpolation describes how an animation transitions between values over its period. By deciding on which key body sort you employ along with your animation, you may outline the interpolation technique for that key body section. There are three several types of interpolation strategies: linear, discrete, and splined.

[2]

linear[edit]

The person segments are go with fixed pace.

Discrete[edit]

With discrete interpolation, the animation perform jumps from one worth to the subsequent with out interpolation.

Spline Interpolation[edit]

http://msdn.microsoft.com/uk-en/library/ms742524.aspx

Figure 1: Interpolation with cubic splines between eight points. Making traditional hand-drawn technical drawings for ship-building etc flexible rulers were bent to follow pre-defined points (the

Keyframe Animation in XNA[edit]

to be edited
die einzelnen Parameter werden in einer Liste gespeichert.
Wenn man nun die Länge der Timeline und die anzahl der elemente hat, kann man hier draus schließen, auf welchen Keyframe man zu welcher Zeit zugreifen kann. (in dem der Timeline- Zähler hochgezählt wird und dann der entsprechende keyframe aufgerufen wird, ist es, als ob man z.b. bei einem daumenkino, bei dem 1 seite 1 keyframe ist, auf die enstsprechende Seite blättern würde).

Folgend ist eine klasse dargestellt, mit welcher dies umgesetzt werden kann. Die Quelle ist hier drunter zu finden.

Just a little keyframe animation class

utilizing System.Collections.Generic;
utilizing Microsoft.Xna.Framework;

namespace PuzzleGame
{
    /// 
    /// Keyframe animation helper class.
    /// 
    public class Animation
    {
        /// 
        /// Listing of keyframes within the animation.
        /// 
        Listing<Keyframe> keyframes = new Listing<Keyframe>();

        /// 
        /// Present place within the animation.
        /// 
        int timeline;

        /// 
        /// The final body of the animation (set when keyframes are added).
        /// 
        int lastFrame = 0;

        /// 
        /// Marks the animation as able to run/working.
        /// 
        bool run = false;

        /// 
        /// Present keyframe index.
        /// 
        int currentIndex;

        /// 
        /// Assemble new animation helper.
        /// 
        public Animation()
        {
        }

        /// 
        /// Add a keyframe to the animation.
        /// 
        /// Time for keyframe to occur.
        /// Worth at keyframe.
        public void AddKeyframe(int time, float worth)
        {
            Keyframe ok = new Keyframe();
            ok.time = time;
            ok.worth = worth;
            keyframes.Add(ok);
            keyframes.Kind(delegate(Keyframe a, Keyframe b) { return a.time.CompareTo(b.time); });
            lastFrame = (time > lastFrame) ? time : lastFrame;
        }

        /// 
        /// Reset the animation and flag it as able to run.
        /// 
        public void Begin()
        {
            timeline = 0;
            currentIndex = 0;
            run = true;
        }

        /// 
        /// Replace the animation timeline.
        /// 
        /// Present recreation time.
        /// Reference to worth to alter.
        public void Replace(GameTime gameTime, ref float worth)
        {
            if (run)
            {
                timeline += gameTime.ElapsedGameTime.Milliseconds;
                worth = MathHelper.SmoothStep(keyframes[currentIndex].worth, keyframes[currentIndex + 1].worth
                (float)timeline / (float)keyframes[currentIndex + 1].time);
                if (timeline >= keyframes[currentIndex + 1].time && currentIndex != keyframes.Depend) { currentIndex++; }
                if (timeline >= lastFrame) { run = false; }
            }
        }

        /// 
        /// Represents a keyframe on the timeline.
        /// 
        public struct Keyframe
        {
            public int time;
            public float worth;
        }
    }
}

useful resource: http://tcsavage.org/2011/04/keyframe-animation-in-xna/

References[edit]

http://xnanimation.codeplex.com/
http://msdn.microsoft.com/uk-en/library/ms742524.aspx
http://en.wikipedia.org/wiki/Animation
http://msdn.microsoft.com/uk-en/library/ms752312.aspx
http://tcsavage.org/2011/04/keyframe-animation-in-xna/
http://de.wikipedia.org/wiki/Spline-Interpolation
http://en.wikipedia.org/wiki/Spline_interpolation

Creator[edit]

ARei

Skeletal Animation[edit]

Skeletal animation is the method in pc animation which is represented in two components, the pores and skin half (known as mesh) and the skeleton half (known as rig). The pores and skin is represented as a mixture of surfaces and the skeleton is a mixture of bones. These bones are linked to one another like actual bones and a part of a hierarchical set. The result’s, you progress one bone and the bones which ought to work together transfer too. The bones animate the mesh (the surfaces) in the identical approach. Whereas this system is usually used to animate people or extra typically for natural modeling, it solely serves to make the animation course of extra intuitive and the identical method can be utilized to manage the deformation of any object, a constructing, a automobile, and so forth.

This method is kind of helpful for the animators as a result of in all animation techniques is this easy method a port of. So they do not want any complicated algorithms to animate the fashions. With out this system it’s just about unattainable to animate the mesh together with the bones.
http://en.wikipedia.org/wiki/Skeletal_animation


Rigging[edit]

Rigging is the method to create a skeleton to animate a mannequin. This skeleton consists of bones(rigs) and joins that are the connetion between the bones. Commonly you associates this bones and joins with the property of an actual skeleton. For instance you create first the higher leg as a bone and afterwards you construct the knee as a be part of.
http://de.wikipedia.org/wiki/Rigging_%28Animation%29


Skinning[edit]

Skinning is the method to create a pores and skin which is assigned to a wired body (the bones) and the motion of the pores and skin is just like the motion of the bones.The skinning comes intuitive after the rigging. The variations between skinning and rigging is,skinning is the visible deformation of the physique(your mannequin).
Helpful is the truth that it’s potential to setup each single sufaces, that is very useful in conditions just like the movement of an arm. Even you progress your arm (or the arm of the mannequin), your pores and skin (the surfaces of the mannequin) work together with the movement in another way, decided by the place like on the inside your elbow or on the outdoors of your elbow.
It is usually potential to simulate muscular motion on this context. http://de.wikipedia.org/wiki/Skinning


The bones and polygons of your mannequin have a restrict in XNA:[edit]

  1. Bones: 59 as much as 79 in 4.0
  2. Polygons: relies on the {hardware}
Typical applications are:[edit]

Animations in XNA[edit]

The only method to get animations out of your mannequin in XNA is to create animations in your 3d improvement device. These animations are robotically part of your exported .x flile or .fbx file.

A easy method to present the dealing with with animations in XNA is a pleasant demo from http://create.msdn.com/en-US/training/catalog/pattern/skinned_model.

First we want a mannequin and a animation:

Mannequin currentModel;
        AnimationPlayer animationPlayer;

The subsequent step is to replace the LoadContent() technique:

protected override void LoadContent()
        {
            // Load the mannequin.
            currentModel = Content material.Load<Mannequin>("dude");

            // Search for our customized skinning info.
            SkinningData skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
                throw new InvalidOperationException
                    ("This mannequin doesn't include a SkinningData tag.");

            // Create an animation participant, and begin decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);
        }

If you happen to setup your clib variable as an array it can save you a variety of totally different animations:

AnimationClip clips= new AnimationClip[skinningData.AnimationClips.Keys.Count];
clips[0] = skinningData.AnimationClips["moveleft"];
clips[1] = skinningData.AnimationClips["moveright"];
clips[2] = skinningData.AnimationClips["jump"];

After that’s is straightforward to name the totally different animations, for instance by dragging the leap key.

animationPlayer.StartClip(clip[2]);

The identical applies to all of the others animations.


References[edit]

http://de.wikipedia.org/wiki/Skinning
http://create.msdn.com/en-US/training/catalog/pattern/skinned_model
http://de.wikipedia.org/wiki/Rigging_%28Animation%29
http://www.mit.edu/~ibaran/autorig/
http://www.mixamo.com/c/auto-rigger
http://www.der-softwareentwickler-blog.de/2011/05/30/video-tutorials-rigging-und-animation/
http://www.digitalproducer.com/2004/01_jan/tutorials/01_26/maya_rigging.htm

Creator[edit]

FixSpix

Abstract[edit]

What we learnt on this chapter[edit]

On this chapter we discovered, find out how to animate our character in two other ways. First the keyframe-animation and than the skeleton-animation. These two strategies are an important in xna.

However which one is best?[edit]

Higher on this context is the improper phrase, lets substitute the phrase “higher” with the phrases “higher through which state of affairs”.
Its easy… use the skeleton-animation in 3D and the keyframe-animation within the 2D space.

Creator[edit]

fixspix

Authors[edit]

A.Rei and FixSpix


Related posts

Leave a Comment