|

楼主 |
发表于 2003-8-18 17:10:00
|
显示全部楼层
Re: 急!dx3d 的问题
[em4] [em4] [em4]
我就是八十点改为在z轴上观察的,初始状态如下:
g_matWorld( 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 );
g_matview( 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 );
g_EyePt( 0.0f, 0.0f, -10.0f );
g_LookatPt( 0.0f, 0.0f, 1.0f );
g_vUpVec( 0.0f, 1.0f, 0.0f );
g_FieldOfView( D3DX_PI / 4 );
g_AspectRatio( 1.0f );
g_NearClip( 0.0f );
g_FarClip( 100.0f );
{ -1.0f,-1.0f, 0.0f, 0xffff0000, },
{ 1.0f,-1.0f, 0.0f, 0xffff0000, },
{ 0.0f, 1.0f, 0.0f, 0xffff0000, },
这时是正三角形没错,我在SetupMatrices里改了一下,大概如下:
case VK_NEXT: //得到绕z轴旋转的矩阵
D3DXMatrixRotationZ( &matTemp, -g_RotationDelta );
//设置世界矩阵
g_pd3dDevice->SetTransform( D3DTS_WORLD, &g_matWorld );
//设置视点矩阵,我试过旋转世界矩阵或视点矩阵都是一样的结果:
//只要不是在0度获180度,三角形旋转后看起来不再是正三角形了
D3DXMATRIXA16 matView;
D3DXMatrixMultiply( &matView, &g_matView, &matTemp );
g_matView = matView;
D3DXMatrixLookAtLH( &matTemp, &g_vEyePt, &g_vLookatPt, &g_vUpVec );
D3DXMatrixMultiply( &matView, &g_matView, &matTemp );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
//投影矩阵
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, g_FieldOfView, g_AspectRatio, g_NearClip, g_FarClip );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
请各位高人看看 ! |
|