directx9学習(カメラの回転修正)
カメラを回転させるとupベクトルとカメラの向きが近いとき
画面がぱちぱち切り替わる現象が発生した。
モデルを回転させる方式に戻した
VOID SetupMatrices()
{
// Set up world matrix
D3DXMATRIXA16 matWorld, matScl;
D3DXMATRIXA16 mattmp1, mattmp2;
D3DXMatrixTranslation(&mattmp1, -cx, -cy, -cz);
D3DXMatrixTranslation(&mattmp2, cx, cy, cz);
// D3DXMatrixIdentity(&matWorld);
matWorld = mattmp1 * matRot * mattmp2;
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );// Set up our view matrix. A view matrix can be defined given an eye point,
// a point to lookat, and a direction for which way is up. Here, we set the
// eye five units back along the z-axis and up three units, look at the
// origin, and define "up" to be in the y-direction.
D3DXVECTOR3 vEyePt( cx, cy, cz+clen );
D3DXVECTOR3 vLookatPt( cx, cy, cz );
// vEyePt -= vLookatPt;
// D3DXVec3TransformCoord(&vEyePt, &vEyePt, &matRot);
// vEyePt += vLookatPt;
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );