首页 新闻 搜索 专区 学院

Direct9旋转平移

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-10-13 09:12

各位大侠,请问下为什么我的程序内的平移和旋转两个矩阵不能同时存在,否则其中一个会失效。

 1 D3DXMATRIX world;
 2 D3DXMATRIX Ry; 
 3 D3DXMatrixRotationY(&Ry, -3.14f / 4.0f); 
 4 D3DXMATRIX y = Ry; 
 5 Device->SetTransform(D3DTS_WORLD, &y);
 6 // draw the scene:
 7  Device->Clear(0, 0, D3DCLEAR_TARGET |D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB( 255,255,255), 1.0f, 0); 
 8 Device->BeginScene();
 9 Device->SetStreamSource(0, VB, 0, sizeof(ColorVertex)); 
10 Device->SetIndices(IB); 
11 Device->SetFVF(ColorVertex::FVF);
12 D3DXMATRIX q; D3DXMatrixTranslation(&q,0.0f,-3.0f,0.0f); Device->SetTransform(D3DTS_WORLD,&q); 
13 Device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
14  Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 8, 0, 12); 
15 D3DXMATRIX p;
16  D3DXMatrixTranslation(&p,-3.0f,-4.0f,-2.0f); 
17 Device->SetTransform(D3DTS_WORLD,&p); Device->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE); Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,4,30, 2); 
18 Device->EndScene(); Device->Present(0, 0, 0, 0); } 
19 return true;
AXIA_zy的主页 AXIA_zy | 菜鸟二级 | 园豆:201
提问于:2012-10-13 08:54
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册