DirectX 9.0 SDK Update (August 2005)-C++-DirectX Graphics-Tutorials and Samples-
Samples-SkinnedMesh Sample
DirectX9.0 软件开发包 2005年八月更新-C++-DirectX图形库-教程与示例-示例-蒙皮网格示例
Skinning is an animation technique that takes data organized in a skeletal-mesh
hierarchy and applies geometry blending to transform mesh vertices.
蒙皮是采用骨骼-网格层次中组织好的数据应用几何融合来变换网格顶点的一种动画技术。
This sample demonstrates five skinning techniques: fixed-function non-indexed,
fixed-function indexed, software, assembly shader, and HLSL shader.
这个示例演示了五种蒙皮技术:固定管线非索引方式,固定管线索引方式,软件方式,汇编着色器方式,
高级着色语言着色器方式。
Transforming vertices with multiple matrices are done with geometry blending.
Each matrix has a blending weight ranging from 0 to 1, with the sum of all blending
weights equal to 1. The blending operation is carried out by first transforming
the vertex with each matrix, yielding several transformed vertex coordinates. Then,
these coordinates are interpolated based on the corresponding blending weights.
Vertices can have different blending weights even if they are influenced by the same
bones. This geometry blending allows surfaces to stay smooth when animated.
用多个矩阵变换顶点是由几何融合完成的。每个矩阵有一个范围为0-1的融合权值,全部融合权值
的和为1。融合操作在第一次使用每个矩阵变换顶点时执行,yielding几个已变换的顶点坐标。随
后,这些坐标基于相应的融合权值被插值处理。顶点就算被同一个骨骼影响,也可以有不同的权值。
几何融合允许表面在动画时保持平滑。
Furthermore, any movement by an ancestor bone may affect the skin position.This
explains why the child bones are modeled in a hierarchy to generate this dependency.
而且,祖先骨骼的任何运动也可能影响皮肤的位置。这解释了为什么子骨骼被建模在层次中
以生成它的依赖。
The first step in loading a mesh is to call D3DXLoadMeshHierarchyFromXInMemory.
This call is similar to D3DXLoadMeshHierarchyFromX, in that they both load a mesh
from an X file into memory. However, D3DXLoadMeshHierarchyFromXInMemory returns the
mesh in the form of a hierarchy tree composed of bones (or frames). This form matches
how the mesh is structured in the X file. In D3DX, an animatable mesh is composed
from a frame hierarchy. At the very top, there is a root frame. The root frame has
one or more child frames, each child frame has its own child frames, and so forth.
加载一个网格的第一步是调用D3DXLoadMeshHierarchyFromXInMemory。该调用与
D3DLoadMeshHierarchyFromX类似,因为他们都把一个网格从X文件加载到内存。但是,
D3DXLoadMeshHierarchyFromXInMemory以由骨骼(或帧)组成的层次树的形式返回网格。
这种形式与网格在X文件中的组织方式相匹配。在最顶处,是一个根帧。根帧有一个或
多个子帧,每一个子帧又有它自己的若干个子帧,以此类推。
A frame in the hierarchy is represented by a structure derived from a D3DXFRAME.
An application may store private information with each frame by deriving the format
of each hierarchy node from D3DXFrame. D3DXFrame, as shown in figure 3, provides the
bare minimum data required by the hierarchy. Each frame has a name, a transformation
matrix, and a mesh container for the geometry data. Each frame also contains a link to
a sibling and a child frame.
层次中的一帧是用继承自D3DXFRAME的一个结构来表示的。通过从D3DXFrame继承每个层次结点,
应用程序可以存储每帧私有的信息。如图3所示,D3DXFrame提供了层次需要的最少的数据。每一帧
有一个名字,一个变换矩阵和一个几何数据的网格容器。每一帧含有一个到下一帧的链接和一个到
子帧的链接。