@author: White Robe Trail
@ Source: Advanced Animation with DirectX, game engine architecture
(Shadow does not explain even recruit)
Introduction:
The basic principle of 3D model animation is that the position of each vertex in the model changes over time . The main species are morph animations , joint animations and skeletal skin animations (skinned Mesh). From the perspective of animation data, the three generally use key frame technology, that is, only the key frame of the data, the other frames of data using interpolation is worthwhile. But because of these three different technologies, the data of the keyframe is not the same.
1. Morph (gradient, morph) animation is the vertex position of each frame of the animation directly specified, and its animation key is the position of all mesh vertices at the corresponding moment of the keyframe.
2, the model of the joint animation is not a whole mesh, but into a lot of parts (mesh), through a parent-child hierarchy of these scattered mesh organized together, the parent mesh drives its next mesh movement, the vertex coordinates in each Mesh are defined in their own coordinate system, In this way, each mesh is involved in the movement as a whole. The animation frame sets the transformation of each sub-mesh relative to its parent mesh (mainly rotation, which can also include movement and scaling), through the sub-to-parent, first-level transformation accumulation (of course, technically, if the matrix operation is multiplicative) to get the mesh throughout the animation model The transformation in the coordinate space (from the perspective of this article is the world coordinate system, the same below), thus determining the position and direction of each mesh in the world coordinate system, and then rendering in mesh units. The problem with joint animation is that the vertices in each part of the mesh are fixed in their mesh coordinate system, so that cracks can occur at two mesh joints.
3, bone skin animation is skinned mesh, the appearance of bone skin animation to solve the problem of joint animation cracks, and the effect is very cool. The basic principles of skeletal animation can be summarized as follows: Under skeletal control, the vertices of the skin mesh are dynamically computed by vertex blending, while the movement of the bones is driven by the animation keyframe data to a skeletal animation that typically includes bone hierarchy data, mesh data, and mesh skinning data ( Skin info) and bone animation (keyframe) data. Detailed analysis is given below.
skeletal related knowledge points one, the skeletal system
1. Bones
A bone node can be understood as a coordinate space.
The joint can be understood as the origin of the bone coordinate space, which determines the position of the bone space and the center of rotation and scaling of the skeletal space.
(Mesh,skin,bone): Mesh is the use of skin attached to the Bone, or Bone through the skin to drive the mesh.
2. Bone level
The bone level is the nested coordinate space, why? Convenient and funny, easy conversion transfer
Root bone: The position of the entire skeletal system in the world coordinates in the Microsoft X file, there is usually a scene_root node, which is an additional skeleton, his transformation matrix is a unit array, indicating that he was initially located in the world origin, and the root of the real bone Bip01, as the scene_root of the child skeleton, Its transformation matrix represents the position relative to root.
3. Bone Change
The transformation of a bone (Transformmatrix) is changed, and is then calculated according to the new transformation, so this process is generally called Updatebonematrix. Because the transformation of the skeleton is relative to the parent, the transformation vertex must use the world transformation matrix, so this process calculates the world transformation matrix (also known as Combinedmatrix) of all bones based on the skeletal Transformation matrix (Transformmatrix) of some of the updated bones.
3. Skins and weights
Mesh in skinned mesh is used as skin and is covered with bones. In order for the normal mesh to have skin-skinning functionality, you must add skin information, the skin info. We know that the mesh is made up of vertices that are modeled when the vertices are defined in the model's own coordinate system, that is, relative to the mesh origin, and the skeletal animation determines the final world coordinate of the model vertex is the skeleton, so to let the bone to determine the vertex's world coordinates, this will be the vertex and bone connection, Skin Info just plays this role.
The effect of Skin info is to transform vertices using the transformation matrix of each bone and multiply the weights so that a bone can have only a partial effect on that vertex. The sum of the weights of each bone should be 1
4. Vertex translation Changes
Bone animation determines the final world coordinates of the model vertices, so let the bones determine the vertex's world coordinates
Mesh vertex (defined in mesh space)---<BoneOffsetMatrix>---Bone space---<BoneCombinedTransformMatrix>--- World
5. Vertex blending
After the vertex is mixed, the new world coordinates are obtained, and after all the vertices are executed vertex blending, the mesh is deform (deformed) from the mesh point of view, and it becomes the shape that the animation needs.
For multiple bones, this process is performed on each bone and the results are blended according to weights (i.e. vertex blending) to get the final world coordinates of the vertices
It is also worth saying (the essence of skeletal animation eliminates cracks in the joints).
second, skeletal animation
The basic principle of 3D model animation is that the position of each vertex in the model changes over time.
Drive: The position of the bone changes over time and the vertex position varies with the bone.
2.1 So the animation data must contain the movement information of the skeleton, which can contain the transform Matrix of the skeleton at some point in the animation frame.
2.2 When playing the animation, give the current playing time value, for each bone that needs animation, according to this value to find out the bone before and after two key frame information, according to the difference between the appropriate interpolation operation.
(There are keyframes, interpolation, and subsequent mixes, montages and other issues and requirements, etc.)
To be continued : Next is the animation segment, key frame, animation fusion (blend, layering, overlay, programmatic animation "Ik\ Physics") Section
(formerly) Skeletal with DirectX12