Skinning and How It Works
Skeletal animation is a technique in computer animation in which a character is represented in two parts: a surface representation used to draw the character (called skin or mesh) and a hierarchical set of interconnected bones (called the skeleton or rig) used to animate (pose and keyframe) the mesh.
I got that from Wikipedia, so if that's wrong, tell them not me.
Anyways, skinning is accomplished by giving each vertex an extra set of attributes, specifically "which bones it should move with", and "how much it should move".
The first one, "which bones it should move with", is known as the IDs. These are stored as an array of integers, in our case and in most cases in computer graphics 4 will suffice. These are the IDs of the bones this vertex should deform with. Each bone stores its own ID, but we'll cover that in a later tutorial, don't worry about that just yet.
The second one, "how much it should move", is known as the Weights. These are stored as an array of floats. In our case 4 will once again suffice. These Weights control just how much the vertex should deform with the bones specified by the IDs, and each Weight corresponds to its ID.
In terms of code, we will need to go into our base Vertex class and add two new variables to it:
float weight[4];
unsigned int id[4];
These should go after the Position, Texture Coordinate, or whatever variables you already have in your Vertex class.
Inside your Mesh class you need to add two more Vertex Buffer Objects, one for the IDs and one for the Weights.
Hey , I want to apply some animation using assimp in visual studio C++ . Can u help me with some code
ReplyDeleteGMail Id :ashishk.it18@nsut.ac.in