How to draw perspective correct ID3DXLine using DrawTransform?
Hi:
I am wondering what transformation is needed to draw perspective correct lines? I had non-perspective-correct version working but when I say this:
HR(mLine->DrawTransform(pVertexList, 5, &mViewMatrix, D3DCOLOR_XRGB(255, 0, 0))); //does not work
instead of this:
HR(mLine->Draw(pVertexList, 5, D3DCOLOR_XRGB(255, 0, 0)));//works
I see nothing displayed on screen.
Here is my view matrix. I am wondering if I should use some other matrix.
D3DXMATRIX mViewMatrix;
D3DXVECTOR3 pos(0.0f, 0.0f, -1000.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXMatrixLookAtLH(&mViewMatrix, &pos, &target, &up);
HR(gd3dDevice->SetTransform(D3DTS_VIEW, &mViewMatrix));
I also tried to use my projection matrix. This time I see my lines but they are several times bigger than expected.
D3DXMATRIX P;
RECT R;
GetClientRect(mhMainWnd, &R);
float width = (float)R.right;
float height = (float)R.bottom;
D3DXMatrixPerspectiveFovLH(&mProjectionMatrix, D3DX_PI*0.25f, width/height, 1.0f, 5000.0f);
HR(gd3dDevice->SetTransform(D3DTS_PROJECTION, &mProjectionMatrix));
Thanks!
[Edited by - ynkm169 on November 4, 2007 9:33:29 AM]
I think you need to send in the combination of both the view and projection matrices. It looks like you tried one, then the other. All you should have to do is multiply them together and pass it into the function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement