|
如下代码:
D3DXMATRIX matWorld, matWorldX, matWorldY, matWorldZ;
//Create the transformation matrices
D3DXMatrixRotationX(&matWorldX, timeGetTime()/400.0f);
D3DXMatrixRotationY(&matWorldY, timeGetTime()/400.0f);
D3DXMatrixRotationZ(&matWorldZ, timeGetTime()/400.0f);
//Combine the transformations by multiplying them together
D3DXMatrixMultiply(&matWorld, &matWorldX, &matWorldY);
D3DXMatrixMultiply(&matWorld, &matWorld, &matWorldZ);
//Apply the tansformation
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
这代代码很多示范代码都在用,意思很简单,就是根据时间绕几个轴转。但我在实际使用过程中也发现个问题,首先就是程序运行好几次后,再运行画面就不转了(我是用VC编译运行,直接按的Ctrl+F5)。我检查发现是 timeGetTime()/400.0f出了点问题,并且试着把400改大,改成600,又可以运行了,之后多运行几次又不行了,只有再把600改大为1000.因此看来,那这个值最好设大一点。不知实际情况是不是这样,所以特来向大家求证一下。
|
|