|
|
试图把摄像机单独弄成一个类 感觉应该挺简单 但是写完后遇到一个很诡异的问题
void MyCamera::SetupCamera(){
D3DXMATRIX View;
D3DXMatrixLookAtLH(&mView, &mPosition, &mLookat, &mUp);
View = mView;
mDevice->SetTransform(D3DTS_VIEW, &View);
}
void MyCamera::SetupPerspective(){
D3DXMATRIX projection;
D3DXMatrixPerspectiveFovLH(&mProj,mFov, mHeight/mWidth,mZnear,mZfar);
projection = mProj;
mDevice->SetTransform(D3DTS_PROJECTION, &projection);
}
void MyCamera::Setup(){
this->SetupCamera();
this->SetupPerspective();
}
效果是黑屏
void MyCamera::Setup(){
D3DXMATRIX View;
D3DXVECTOR3 cameraPos(12.0f, 12.0f, -12.0f);
D3DXVECTOR3 cameraLookAt(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 upVector(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&View, &cameraPos, &cameraLookAt, &upVector);
mDevice->SetTransform(D3DTS_VIEW, &View);
D3DXMATRIX projection;
D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI * 0.5f, 8/6,1.0f,1000.0f);
mDevice->SetTransform(D3DTS_PROJECTION, &projection);
}
效果正确
参数数值检查过也没什么区别 为什么会有这种效果 |
|