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