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

天行健 君子當(dāng)自強(qiáng)而不息

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) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲专区在线视频| 欧美大片在线看免费观看| 亚洲欧美日韩综合| 欧美亚洲视频| 国产精品日韩在线| 久久精品国产视频| 欧美激情 亚洲a∨综合| 亚洲一区二区三区涩| 亚洲第一福利在线观看| 免费亚洲一区二区| 一本一本大道香蕉久在线精品| 欧美一级片久久久久久久| 老司机精品导航| 亚洲欧美三级在线| 制服丝袜激情欧洲亚洲| 91久久综合亚洲鲁鲁五月天| 亚洲一区自拍| 欧美a级在线| 久久午夜精品一区二区| 99视频精品全部免费在线| 亚洲第一精品在线| 性欧美超级视频| 亚洲美女毛片| 亚洲精品一区中文| 亚洲精品日韩综合观看成人91| 欧美尤物一区| 欧美在线地址| 中文网丁香综合网| 亚洲另类视频| 国产日韩欧美在线播放不卡| 国产欧美日韩精品在线| 国产精品久久久久久久午夜| 欧美极品一区二区三区| 欧美激情一区三区| 国产精品高清一区二区三区| 国产女主播一区| 好吊视频一区二区三区四区| 影音先锋国产精品| 亚洲美洲欧洲综合国产一区| 99精品国产99久久久久久福利| 久久一区二区精品| 亚洲成人自拍视频| 欧美日本不卡高清| 欧美激情四色 | 亚洲激精日韩激精欧美精品| 香蕉国产精品偷在线观看不卡| 在线精品视频在线观看高清| 国产一区二区三区奇米久涩| 亚洲片国产一区一级在线观看| 亚洲国产精品精华液网站| 亚洲成在线观看| 亚洲欧美视频在线观看视频| 久久久精品2019中文字幕神马| 欧美成人三级在线| 久久综合九色综合欧美狠狠| 美女主播精品视频一二三四| 久久女同精品一区二区| 欧美激情aⅴ一区二区三区 | 国产精品igao视频网网址不卡日韩| 久久久国产精品一区二区中文 | 国产精品女人久久久久久| 欧美激情日韩| 国产欧美一区二区色老头| 亚洲精品日韩久久| 欧美ed2k| 在线视频欧美日韩精品| 午夜视频一区| 欧美日韩一区二区三| 亚洲精品偷拍| 午夜精彩国产免费不卡不顿大片| 久久久久久久久久看片| 一区二区欧美激情| 欧美成人午夜激情视频| 亚洲黄色性网站| 亚洲国产精品久久| 欧美成人精品一区二区| 一区二区三区四区国产| 国产欧美一区二区三区在线老狼| 国产精品久久久久一区| 亚洲国内精品在线| 在线亚洲电影| 国产在线高清精品| 亚洲一级黄色av| 久久动漫亚洲| 亚洲美女一区| 欧美一区二区三区在线视频| 亚洲免费av片| 性色av一区二区三区在线观看| 国产精品久久久久久久久| 欧美综合激情网| 久久婷婷成人综合色| 激情欧美一区| 极品日韩av| 久久在线精品| 欧美日本不卡高清| 久久黄金**| 久久久国产成人精品| 亚洲综合视频在线| 欧美成人精品在线| 久久精精品视频| 男男成人高潮片免费网站| 亚洲——在线| 欧美日韩成人在线观看| 欧美 日韩 国产一区二区在线视频 | 国产美女精品视频| 久久精品亚洲一区| 欧美顶级大胆免费视频| 欧美在线视频不卡| 欧美日韩国产美女| 亚洲激情午夜| 国产一区二区三区视频在线观看 | 亚洲七七久久综合桃花剧情介绍| 欧美jizz19性欧美| 国产美女诱惑一区二区| 一区二区三区视频在线播放| 亚洲视频一区二区在线观看| 欧美www视频在线观看| 久久九九久精品国产免费直播| 欧美国产日韩xxxxx| 久久久噜噜噜久久中文字免| 欧美视频精品一区| 99视频+国产日韩欧美| 亚洲免费在线电影| 欧美日韩色一区| 亚洲美女中出| 亚洲视频中文字幕| 国产精品成人aaaaa网站| 欧美凹凸一区二区三区视频| 在线欧美三区| 麻豆freexxxx性91精品| 欧美大片在线观看| 国产日韩视频| 亚洲三级免费| 亚洲一区二区高清| 欧美三日本三级少妇三2023| 亚洲国内精品在线| 欧美人妖另类| 亚洲视频免费| 欧美wwwwww| 久久se精品一区二区| 国产综合精品| 欧美一区二区黄| 欧美国产精品劲爆| 亚洲少妇在线| 国产区日韩欧美| 美女网站久久| 欧美亚洲三区| 久久久久久久性| 在线精品视频在线观看高清| 欧美紧缚bdsm在线视频| 亚洲淫性视频| 久久亚洲精品一区| 亚洲欧美春色| 一区二区三欧美| 国产精品欧美日韩| 久久综合九色综合欧美就去吻 | 一区二区日韩伦理片| 久久在精品线影院精品国产| 91久久国产自产拍夜夜嗨| 久久久欧美一区二区| 亚洲精品欧美精品| 国产美女高潮久久白浆| 欧美日韩性生活视频| 久久xxxx| 日韩视频不卡| 欧美激情按摩在线| 久久久久久97三级| 一区二区三区精品视频在线观看| 欧美久久一区| 亚洲制服少妇| 亚洲国产一区二区三区在线播 | 国产精品一区二区久久国产| 欧美在线播放一区二区| 欧美伊人久久| 亚洲人成啪啪网站| 欧美xx69| 久久国产色av| 午夜精品久久| 亚洲毛片在线观看| 亚洲网友自拍| 一区二区三区回区在观看免费视频| 夜夜嗨av一区二区三区四区| 激情欧美丁香| 国产日韩欧美制服另类| 国产精品久久久久久久久久免费| 欧美一区二区三区男人的天堂| 欧美国产第一页| 久久综合影音| 久久国产精品网站| 午夜一区不卡| 男人的天堂亚洲在线| 亚洲一区二区三区影院| 亚洲欧美综合精品久久成人| 性欧美大战久久久久久久久| 亚洲欧美日韩国产中文| 亚洲视频1区| 欧美专区第一页| 久久久一本精品99久久精品66| 亚洲在线成人| 亚洲午夜久久久|