首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络游戏 >

DirectX问一个世界矩阵有关问题

2012-04-07 
DirectX问一个世界矩阵问题龙书中的D3DXCREATE程序中写着ID3DXMesh* Objects[5] {0, 0, 0, 0, 0}D3DXMA

DirectX问一个世界矩阵问题
龙书中的D3DXCREATE程序中写着
ID3DXMesh* Objects[5] = {0, 0, 0, 0, 0};

D3DXMATRIX ObjWorldMatrices[5];
然后5个物体分别载入Object里。。。
然后之后定位每一个物体时却可以直接用ObjWorldMatrices一一对应,
那么是什么使得Objects和ObjWorldMatrices关联起来了??一下是一段原程序
  D3DXCreateTeapot(
Device,
&Objects[0],
0);

D3DXCreateBox(
Device,
2.0f, // width
2.0f, // height
2.0f, // depth
&Objects[1],
0);

// cylinder is built aligned on z-axis
D3DXCreateCylinder(
Device,
1.0f, // radius at negative z end
1.0f, // radius at positive z end
3.0f, // length of cylinder
10, // slices
10, // stacks
&Objects[2],
0);

D3DXCreateTorus(
Device,
1.0f, // inner radius
3.0f, // outer radius
10, // sides
10, // rings
&Objects[3],
0);

D3DXCreateSphere(
Device,
1.0f, // radius
10, // slices
10, // stacks
&Objects[4],
0);

//
// Build world matrices - position the objects in world space.
// For example, ObjWorldMatrices[1] will position Objects[1] at
// (-5, 0, 5). Likewise, ObjWorldMatrices[2] will position
// Objects[2] at (5, 0, 5).
//

D3DXMatrixTranslation(&ObjWorldMatrices[0], 0.0f, 0.0f, 0.0f);//为什么它能知道对应的是茶壶
D3DXMatrixTranslation(&ObjWorldMatrices[1], -5.0f, 0.0f, 5.0f);//为什么它能知道对应的是箱子
D3DXMatrixTranslation(&ObjWorldMatrices[2], 5.0f, 0.0f, 5.0f);//为什么它能知道对应的是圆柱
D3DXMatrixTranslation(&ObjWorldMatrices[3], -5.0f, 0.0f, -5.0f);//为什么它能知道对应的是圆环
D3DXMatrixTranslation(&ObjWorldMatrices[4], 5.0f, 0.0f, -5.0f);//为什么它能知道对应的是球

[解决办法]
D3DXMatrixTranslation(&ObjWorldMatrices[0], 0.0f, 0.0f, 0.0f);//为什么它能知道对应的是茶壶
====
你理解错了。是这句设置好变换矩阵,然后接着绘制茶壶。
这个关系是需要你指定的。

热点排行