没有合适的资源?快使用搜索试试~ 我知道了~
d3dx_skinnedmesh.pdf
5星 · 超过95%的资源 需积分: 10 14 下载量 106 浏览量
2012-03-23
10:06:54
上传
评论
收藏 894KB PDF 举报
温馨提示
试读
36页
D3D中一个非常好的学习骨骼动画的文档,这里面结合实际代码讲解十分详细。
资源推荐
资源详情
资源评论
Skinned Mesh Character Animation
with Direct3D 9.0c
Frank Luna
www.moon-labs.com
Copyright © 2004. All rights reserved.
Created on Monday, February 20, 2004
Update 1 on Friday, September 10, 2004
Real-Time character animation plays an important role in a wide variety of 3D
simulation programs, and particularly in 3D computer games. This paper describes the
data structures and algorithms used to drive a modern real-time character animation
system. In addition, it presents a thorough examination of the D3DX 9.0c Animation
API.
Section 1 describes the motion and data structural representation of a 3D
character. Section 2 focuses on the datasets needed to describe an animation sequence.
Section 3 examines an animation technique that works with rigid bodies and emphasizes
the problems associated with this approach. Section 4 explains a new animation
technique, vertex blending (also called skinned mesh animation), which does not suffer
the problems of rigid body animation. Section 5 shows how to implement a skinned
mesh character animation using the D3DX Animation API. Section 6 demonstrates how
to play multiple distinct animation sequences. Section 7 explores how to create new
animations from existing ones using the D3DX animation blending functionality. And
finally, Section 8 explains how to execute code in parallel with an animation sequence,
using the D3DX animation callback functionality.
1 An Overview of Character Mesh Hierarchies
Figure 1 shows a character mesh. The highlighted chain of bones in the figure is
called a skeleton. A skeleton provides a natural underlying structure for driving a
character animation system. The skeleton is surrounded by an exterior skin, which we
model as 3D geometry (vertices and polygons). Each bone in the skeleton influences the
shape and position of the skin, just like in real life; mathematically, bones are described
by transformation matrices which transform the skin geometry appropriately. Thus, as
we animate the skeleton, the attached skin is animated accordingly to reflect the current
pose of the skeleton.
2
Figure 1: A Character mesh. The highlighted bone chain represents the character's skeleton. The
dark colored polygons represent the character's skin.
1.1 Bones and Inherited Transforms
Initially, all bones start out in bone space with their joints coincident with the
origin. A bone B has two associated transforms: 1) A local transform L and 2) a
combined transform C. The local transform is responsible for rotating B in bone space
about its joint (Figure 2a), and also for offsetting (translating) B relative to its immediate
parent such that B’s joint will connect with its parent bone (Figure 2b). (The purpose of
this offset translation will be made clear in a moment.)
Figure 2: a) A bone rotates about its pivot joint in bone space. b) The bone is offset to make room for
its parent bone.
In contrast to the local transform, the combined transform is responsible for
actually posing the bone relative to the character in order to construct the character’s
skeleton, as Figure 3 shows. In other words, the combined transform transforms a bone
from bone space to the character space. Therefore, it follows that the combined
transform is the transform that is used to actually positions and shapes the skin in
character space.
3
Figure 3: The combine transformation transforms the bone from bone space to character space. In
this figure, the bone in bone space becomes the right upper-arm bone of the character.
So, how do we determine the combined transform? The process is not completely
straightforward since bones are not independent of each other, but rather affect the
position of each other. Ignoring rotations for the moment, consider the desired bone
layout of an arm, as depicted in Figure 4.
Figure 4: The skeleton of an arm. Observe how the combination of T(v0), T(v1) and T(v2) position
the hand. Likewise, the combination of T(v0) and T(v1) position the forearm. And notice how T(v0)
positions the upper-arm. (Actually T(v0) does nothing, since the upper-arm is the root bone it
doesn’t need to be translated, hence T(v0) = 0.)
Given an upper-arm, forearm, and hand bone in bone space, we need to find combined
transforms for each bone that will position the bones in the configuration shown in Figure
4. Because the local transform of a bone offsets a bone relative to its parent, we can
readily see from Figure 4 that a bone’s position, relative to the character mesh, is
determined by first applying its local translation transform, then by applying the local
translation transform of all of its parents, in the order of youngest parent to eldest parent.
Now, consider the skeleton arm depicted in Figure 5. Physically, if we rotate the
upper-arm about the shoulder joint, then the forearm and hand must necessarily rotate
with it. Likewise, if we rotate the forearm, then just the hand must necessarily rotate with
it. And of course, if we rotate the hand, then only the hand rotates. Thus we observe that
a bone’s position, relative to the character mesh, is determined by first applying its local
4
rotation transform, then by applying the local rotation transform of all of its parents, in
the order of youngest parent to eldest parent.
Figure 5: Hierarchy transforms. Observe that the parent transformation of a bone influences itself
and all of its children.
Now that we see that both translations and rotations are inherited from each
parent in a bone’s lineage, we have the following: A bones combined transform is
determined by first applying its local transform (rotation followed by translation), then by
applying the local transform of its parent P’, then by applying the local transform of its
grandparent P’, …, and finally by applying the local transform of its eldest parent P
(n)
(the root). Mathematically, the combined transformation matrix of the
th
i bone
i
C is
given by:
(1)
iii
PLC = ,
where
i
L is the local transformation matrix of the
th
i bone, and
i
P is the combined
transformation matrix of the
th
i bone’s parent. Note that we multiply by the matrix
i
L
first, so that its local transform is applied first, in bone space.
1.2 D3DXFRAME
We now introduce a D3DX hierarchical data structure called D3DXFRAME. We
will use this structure to represent the bones of the character. By assigning some pointers
we can connect these bones to form the skeleton. For example, Figure 6 shows the
pointer connection that form the bone hierarchy tree (skeleton) of the character showed in
Figure 1.
5
Figure 6: Tree hierarchy diagram of the skeleton of the character depicted in Figure 1. Down
vertical arrows represent “first child” relationships, and rightward horizontal arrows represent
“sibling” relationships.
Admittedly, in the context of character animation, the name BONE is preferred to
D3DXFRAME. However, we must remember that D3DXFRAME is a generic data structure
that can describe non-character mesh hierarchies as well. In any case, in the context of
character animation we can use “bone” and “frame” interchangeably.
typedef struct _D3DXFRAME {
LPSTR Name;
D3DXMATRIX TransformationMatrix;
LPD3DXMESHCONTAINER pMeshContainer;
struct _D3DXFRAME *pFrameSibling;
struct _D3DXFRAME *pFrameFirstChild;
} D3DXFRAME, *LPD3DXFRAME;
Table 1: D3DXFRAME data member descriptions.
Data Member Description
Name
The name of the node.
TransformationMatrix
The local transformation matrix.
pMeshContainer
Pointer to a D3DXMESHCONTIANER. This member is used in the
case that you want to associate a container of meshes with this
frame. If no mesh container is associated with this frame, set
this pointer to null. We will ignore this member for now and
come back to D3DXMESHCONTIANER in Section 5 of this
paper.
pFrameSibling
Pointer to this frame’s sibling frame; one of two pointers used to
connect this node to the mesh hierarchy—see Figure 6.
pFrameFirstChild
Pointer to this frame’s first child frame; one of two pointers used
to connect this node to the mesh hierarchy—see Figure 6.
剩余35页未读,继续阅读
资源评论
- wqazwqaz2013-06-23文档的原理讲述很清楚,有公式有图
雪人2015
- 粉丝: 279
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功