在CubeMap中怎样获得6个观察矩阵?
如题。
我自己试了一下,但是效果不对,大家帮我看看。谢谢!
//
//
//Cube观察矩阵
D3DXMATRIX matCubeView;
//观察方向
D3DXVECTOR3 LookatPt( 0.0f, 0.0f, 0.0f );
EyePt=D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXVECTOR3 vUpVec;
switch(iFace)
{
case D3DCUBEMAP_FACE_POSITIVE_X:
{
LookatPt=D3DXVECTOR3( 1.0f, 0.0f, 0.0f );
vUpVec=D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
}
case D3DCUBEMAP_FACE_NEGATIVE_X :
{
LookatPt=D3DXVECTOR3( -1.0f, 0.0f, 0.0f );
vUpVec=D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
}
case D3DCUBEMAP_FACE_POSITIVE_Y:
{
LookatPt=D3DXVECTOR3( 0.0f, 2.0f, 0.0f );
vUpVec=D3DXVECTOR3( 0.0f, 0.0f, -1.0f );
break;
}
case D3DCUBEMAP_FACE_NEGATIVE_Y:
{
LookatPt=D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
vUpVec=D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
break;
}
case D3DCUBEMAP_FACE_POSITIVE_Z:
{
LookatPt=D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
vUpVec=D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
}
case D3DCUBEMAP_FACE_NEGATIVE_Z :
{
LookatPt=D3DXVECTOR3( 0.0f, 0.0f, -1.0f );
vUpVec=D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
}
}
D3DXMatrixLookAtLH( &matCubeView, &EyePt, &LookatPt, &vUpVec );
[解决办法]
lookatPt错了,你那算出来时斜的
比如eyeat = 0,1,0, 向左看, lookatpt = -1,1,0, 而不是你的 -1,0,0
[解决办法]
好像是矩阵的顺序错了吧??
LZ再好好看看……