青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

D3D Animation Basis(1)

The D3DXFRAME object helps form a hierarchy of reference frames. These reference frames are used to
connect a series of meshes together, with each frame having its own transformation to apply to the mesh
connected to it. In this way of using frames to point to meshes, you can minimize the number of meshes used
because you can reference meshes instead of having to reload them.

For example, imagine you have a car that consists of a body and four wheels. The body and wheel form two
meshes. These two meshes are used in conjunction with five frames (one for the body and four for the tires).
When rendering, each frame's transformation is used to position and render the mesh that the frame uses. That
means one frame transforms and renders the body once, while the other frames transform and render the tire
mesh four times.

here is D3DXFRAME's define:

Encapsulates a transform frame in a transformation frame hierarchy.

typedef struct D3DXFRAME {
LPSTR Name;
D3DXMATRIX TransformationMatrix;
LPD3DXMESHCONTAINER pMeshContainer;
D3DXFRAME * pFrameSibling;
D3DXFRAME * pFrameFirstChild;
} D3DXFRAME, *LPD3DXFRAME;

Members

Name
Name of the frame.
TransformationMatrix
Transformation matrix.
pMeshContainer
Pointer to the mesh container.
pFrameSibling
Pointer to a sibling frame.
pFrameFirstChild
Pointer to a child frame.

Remarks

An application can derive from this structure to add other data.

As for the D3DXMESHCONTAINER object, it is used to contain a mesh as well as to link to a series of other
meshes (using a linked list). Why not just use the ID3DXBaseMesh object instead, you ask? Well, there's
more to D3DXMESHCONTAINER than you might expect. First, you can store any type of mesh, whether it's
regular, skinned, or progressive. Second, the D3DXMESHCONTAINER object holds material and effect data.

here is D3DXMESHCONTAINER define:

Encapsulates a mesh object in a transformation frame hierarchy.

typedef struct D3DXMESHCONTAINER {
LPSTR Name;
D3DXMESHDATA MeshData;
LPD3DXMATERIAL pMaterials;
LPD3DXEFFECTINSTANCE pEffects;
DWORD NumMaterials;
DWORD * pAdjacency;
LPD3DXSKININFO pSkinInfo;
D3DXMESHCONTAINER * pNextMeshContainer;
} D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER;

Members

Name
Mesh name.
MeshData
Type of data in the mesh.
pMaterials
Array of mesh materials.
pEffects
Pointer to a set of default effect parameters.
NumMaterials
Number of materials in the mesh.
pAdjacency
Pointer to an array of three DWORDs per triangle of the mesh that contains adjacency information.
pSkinInfo
Pointer to the skin information interface.
pNextMeshContainer
Pointer to the next mesh container.

Remarks

An application can derive from this structure to add other data.

D3DXMESHDATA

Mesh data structure.

typedef struct D3DXMESHDATA {
D3DXMESHDATATYPE Type;
union {
LPD3DXMESH pMesh;
LPD3DXPMESH pPMesh;
LPD3DXPATCHMESH pPatchMesh;
};
} D3DXMESHDATA, *LPD3DXMESHDATA;

Members

Type
Defines the mesh data type.
pMesh
Pointer to a mesh.
pPMesh
Pointer to a progressive mesh.
pPatchMesh
Pointer to a patch mesh.

D3DXMESHDATATYPE

Defines the type of mesh data present in D3DXMESHDATA.

typedef enum D3DXMESHDATATYPE
{
D3DXMESHTYPE_MESH = 0x001,
D3DXMESHTYPE_PMESH = 0x002,
D3DXMESHTYPE_PATCHMESH = 0x003,
D3DXEDT_FORCE_DWORD = 0x7fffffff,
} D3DXMESHDATATYPE, *LPD3DXMESHDATATYPE;

Constants

D3DXMESHTYPE_MESH
The data type is a mesh.
D3DXMESHTYPE_PMESH
The data type is a progressive mesh.
D3DXMESHTYPE_PATCHMESH
The data type is a patch mesh.
D3DXEDT_FORCE_DWORD
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.
 

Extending D3DXFRAME

By itself, the D3DXFRAME object is very useful, but unfortunately it lacks a few very essential tidbits of
information, namely data for containing transformations when animating meshes, functions to handle the
animation data, and a default constructor and destructor.

To correct these omissions, I have created an extended version of D3DXFRAME, which I call
D3DXFRAME_EX. This new object adds a total of two D3DXMATRIX objects and six functions to the mix.
The two matrix objects contain the original transformation of the frame (before any animation transformations
are applied) and the combined transformation from all parent frames to which the frame is connected (in the
hierarchy).

Here's how I defined the D3DXFRAME_EX structure along with the two matrix objects:

//-------------------------------------------------------------------------------------------
// Declare an extended version of D3DXFRAME that contains a constructor and destructor
// as well as a combined transformation matrix.
//-------------------------------------------------------------------------------------------
struct D3DXFRAME_EX : D3DXFRAME
{
D3DXMATRIX mat_combined; // combined matrix
D3DXMATRIX mat_original; // original transformation from .X

For now, let's
just move on to the functions, starting with the constructor. The constructor has the job of clearing out the
structure's data (including the original data from the base D3DXFRAME object).

D3DXFRAME_EX()
{
Name = NULL;
pMeshContainer = NULL;
pFrameSibling = pFrameFirstChild = NULL;

D3DXMatrixIdentity(&matCombined);
D3DXMatrixIdentity(&matOriginal);
D3DXMatrixIdentity(&TransformationMatrix);
}

On the flip side, the destructor has the job of freeing the data used by the D3DXFRAME_EX object.

~D3DXFRAME_EX()
{
delete[] Name; Name = NULL;
delete pFrameSibling; pFrameSibling = NULL;
delete pFrameFirstChild; pFrameFirstChild = NULL;
}

As you can see, the constructor and destructor are pretty typical in the way those things normally go−initialize
the object's data and free the resources when done. What comes next are a handful of functions that help you
search for a specific frame in the hierarchy, reset the animation matrices to their original states, update the
hierarchy after modifying a transformation, and count the number of frames in the hierarchy.

The first function, find, is used to find a specific frame in the hierarchy and return a pointer to it. If you're
not aware of this, each D3DXFRAME object (and the derived D3DXFRAME_EX object) has a Name data
buffer, which you're free to fill in with whatever text you find appropriate. Typically, frames are named after
bones that define the hierarchy.

To find a specific frame (and retrieve a pointer to the frame's object), just call the find function, specifying
the name of the frame you wish to find as the one and only parameter.

// Function to scan hierarchy for matching frame name
D3DXFRAME_EX* find(const char* frame_name)
{
// return this frame instance if name matched
if(Name && frame_name && !strcmp(frame_name, Name))
  return this;

if(pFrameSibling) // scan siblings
  return ((D3DXFRAME_EX*) pFrameSibling)->find(frame_name);

if(pFrameFirstChild) // scan children
  return ((D3DXFRAME_EX*) pFrameSibling)->find(frame_name);

return NULL; // no found
}

The find function compares the name you passed to the current frame's name; if they match, the pointer to
the frame is returned. If no match is found, then the linked list is scanned for matches using a recursive call to
find.

Next in the line of added functions is reset, which scans through the entire frame hierarchy (which, by the
way, is a linked list of child and sibling objects). For each frame found, it copies the original transformation to
the current transformation. Here's the code:

// reset transformation matrices to originals
void reset()
{
TransformationMatrix = mat_original;

if(pFrameSibling)
  ((D3DXFRAME_EX*) pFrameSibling)->reset();

if(pFrameFirstChild)
  ((D3DXFRAME_EX*) pFrameFirstChild)->reset();
}

Typically, you call reset to restore the frame hierarchy's transformation back to what it was when you
created or loaded the frames. the next function in the list is update_hierarchy, which has the job of rebuilding
the entire frame hierarchy's list of transformations after any one of those transformations has been altered.

Rebuilding the hierarchy is essential to making sure the mesh is rebuilt or rendered correctly after you have
updated an animation. let's just check out the code, which takes an optional transformation matrix to apply
to the root frame of the hierarchy.

// function to combine matrices in frame hierarchy
void update_hierarchy(D3DXMATRIX* mat_trans)
{
// use an identity matrix if none passed
if(mat_trans == NULL)
{
  D3DXMATRIX mat_identity;
  D3DXMatrixIdentity(&mat_identity);

  mat_trans = &mat_identity;
}

// combine matrices with supplied transformation matrix
mat_combined = TransformationMatrix * (*mat_trans);

// combine with sibling frames
if(pFrameSibling)
  ((D3DXFRAME_EX*) pFrameSibling)->update_hierarchy(mat_trans);

// combine with child frames
if(pFrameFirstChild)
  ((D3DXFRAME_EX*) pFrameFirstChild)->update_hierarchy(mat_combined);
}

the update_hierarchy function transforms the frames by their own transformation matrix
(stored in matTransformation) by a matrix that is passed as the optional parameter of the function. This
way, a frame inherits the transformation of its parent frame in the hierarchy, meaning that each transformation
applied winds its way down the entire hierarchy.

Last, with the D3DXFRAME_EX object you have the count function, which helps you by counting the
number of frames contained within the hierarchy. This is accomplished using a recursive call of the count
function for each frame contained in the linked list. For each frame found in the list, a counter variable (that
you provide as the parameter) is incremented. Check out the Count code to see what I mean.

void count(DWORD* num)
{
if(num == NULL) // error checking
  return;

(*num) += 1; // increase count of frames

// process sibling frames
if(pFrameSibling)
  ((D3DXFRAME_EX*) pFrameSibling)->count(num);

// process child frames
if(pFrameFirstChild)
  ((D3DXFRAME_EX*) pFrameFirstChild)->count(num);
}

And that pretty much wraps up the D3DXFRAME_EX object. If you're used to using the D3DXFRAME object
(and you should be if you're a DX9 user), then everything I've just shown you should be pretty easy to
understand.


posted on 2008-04-13 17:37 lovedday 閱讀(634) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美日韩国产一区精品一区 | 亚洲国产精品激情在线观看| 亚洲免费久久| 久久综合精品一区| 欧美日韩和欧美的一区二区| 亚洲国产欧美一区| 理论片一区二区在线| 一本色道久久| 国产精品久久久久久久久借妻| 一区二区三区四区五区视频| 亚洲激情校园春色| 欧美伦理91i| 一区二区三区免费观看| 99视频热这里只有精品免费| 欧美日韩精品福利| 亚洲欧美另类综合偷拍| 亚洲专区免费| 国产在线视频不卡二| 久久精品网址| 久久一区中文字幕| 亚洲精品久久久一区二区三区| 亚洲国产精品第一区二区| 欧美激情导航| 亚洲在线免费| 欧美一区国产一区| 樱桃国产成人精品视频| 亚洲大片在线| 欧美成人午夜影院| 亚洲最黄网站| 亚洲综合社区| 尤物视频一区二区| 亚洲免费观看| 国产午夜精品理论片a级大结局| 久久精品国语| 欧美99在线视频观看| 亚洲一区二区三区四区中文 | 欧美日韩一区二区视频在线| 一区二区三区视频观看| 午夜视黄欧洲亚洲| 国内外成人免费视频| 久久综合影音| 欧美午夜精品久久久久久人妖| 久久经典综合| 欧美激情1区2区| 久久激情五月婷婷| 欧美日韩日韩| 巨乳诱惑日韩免费av| 欧美日韩一区成人| 美女国产一区| 国产精品视频精品视频| 午夜精品偷拍| 欧美xx视频| 性久久久久久久久| 欧美精品xxxxbbbb| 看欧美日韩国产| 国产精品一二三| 亚洲欧洲日韩在线| 亚洲电影激情视频网站| 亚洲在线一区二区| 在线视频你懂得一区| 久久综合久久久| 亚洲欧美在线磁力| 欧美韩日亚洲| 免费成人毛片| 国产性色一区二区| 亚洲一区在线观看视频 | 欧美日韩一级大片网址| 欧美高清在线一区| 国产主播一区二区| 亚洲欧美电影在线观看| 亚洲一区二区三区在线视频| 欧美高潮视频| 亚洲丶国产丶欧美一区二区三区| 国产色爱av资源综合区| 99国产精品自拍| 99国产精品久久久久久久成人热| 久久久久国产一区二区三区| 久久精品1区| 国产婷婷色一区二区三区在线| 一区二区三区四区精品| 中国日韩欧美久久久久久久久| 裸体一区二区三区| 欧美国产综合视频| 亚洲精品一区二区在线| 你懂的成人av| 亚洲精品国产系列| 99在线精品免费视频九九视| 欧美国产在线电影| 99re热这里只有精品视频| 亚洲国产精品久久久久秋霞影院| 久久久久久久久伊人| 欧美jizzhd精品欧美巨大免费| 精品不卡在线| 麻豆精品91| 亚洲夫妻自拍| 在线亚洲电影| 国产精品久久久久影院亚瑟| 亚洲综合国产| 久久久www成人免费无遮挡大片| 国产精品一区在线观看| 亚洲欧美国产制服动漫| 亚洲精品乱码久久久久久蜜桃91| 欧美chengren| 亚洲色诱最新| 久久免费精品视频| 亚洲人成人一区二区在线观看| 免费成人黄色片| 99精品欧美一区二区蜜桃免费| 欧美在线视频免费观看| 韩国成人精品a∨在线观看| 久久中文久久字幕| 亚洲精选中文字幕| 欧美中文在线观看国产| 亚洲国产成人精品久久| 欧美先锋影音| 久久久国产一区二区三区| 亚洲国产欧美一区| 欧美一区二区三区婷婷月色 | 亚洲国产精品激情在线观看| 亚洲欧美在线磁力| 91久久精品国产| 国产精品日韩欧美一区二区三区| 久久精品免费观看| 美女国产一区| 午夜精品国产精品大乳美女| 国产精品久久久久久久久久ktv | 亚洲国产精品久久久久婷婷老年| 国产精品成人一区二区三区吃奶| 久久久久久久久久码影片| 99亚洲一区二区| 免费观看亚洲视频大全| 99国产精品| 亚洲国产美女| 国产亚洲一区二区在线观看| 欧美视频免费在线| 免费久久99精品国产| 午夜久久资源| 一本不卡影院| 亚洲激情亚洲| 欧美丰满高潮xxxx喷水动漫| 久久久久国产精品人| 亚洲一本大道在线| 亚洲福利一区| 国内外成人免费激情在线视频| 欧美午夜精品久久久久久孕妇| 蜜桃av噜噜一区二区三区| 亚洲人久久久| 亚洲国产婷婷| 久久综合婷婷| 久久人人爽人人爽爽久久| 欧美一区二区三区视频| 亚洲欧美日本另类| 亚洲图片欧洲图片日韩av| 激情亚洲网站| 韩日视频一区| 国产一区清纯| 国产午夜精品视频| 国产色爱av资源综合区| 国产日韩欧美一区在线| 欧美黄色免费网站| 欧美精品色网| 欧美日韩国产精品专区| 久久久久久国产精品一区| 欧美一区二区视频网站| 亚洲区一区二| 一本色道久久综合亚洲精品高清 | 欧美亚洲色图校园春色| 午夜精品视频一区| 亚洲在线成人精品| 一本一本久久a久久精品综合麻豆| 亚洲午夜精品一区二区| 亚洲一区二区免费在线| 亚洲自拍三区| 欧美一区二区在线免费观看| 中文一区二区| 久久人人97超碰人人澡爱香蕉| 久久综合色88| 欧美黄色aa电影| 亚洲美女福利视频网站| 一本色道综合亚洲| 久久精品视频免费| 欧美成人精品三级在线观看| 欧美精彩视频一区二区三区| 欧美日韩一区二区三区在线看| 国产精品视频导航| 狠狠入ady亚洲精品经典电影| 在线精品一区| 亚洲性视频h| 久久久国产精品一区二区三区| 久久综合久久久久88| 一区二区三区|亚洲午夜| 亚洲综合色网站| 葵司免费一区二区三区四区五区| 欧美精品乱码久久久久久按摩| 国产精品久久久亚洲一区| 亚洲国产91| 午夜宅男久久久| 免费日韩精品中文字幕视频在线| 亚洲人成网站在线观看播放| 亚洲欧美日韩网|