So, how do I set up the SRT matrix for ID3DXLine:rawTransform?
I've already got primitive drawing working at a given pos by this sequence:
Code:
(in render setup)
D3DXMatrixPerspectiveFovRH(&proj, cam->Fov*0.6f, 1920.0f/1200.0f, 0.0f, 1.00f);
idVec3 forward;
cam->Forward(forward);
idVec3 up;
cam->Up(up);
D3DXVECTOR3 vEyePt( cam->vecPosition[0], cam->vecPosition[1], cam->vecPosition[2] );
D3DXVECTOR3 vLookatPt( cam->vecPosition[0]+forward[0], cam->vecPosition[1]+forward[1], cam->vecPosition[2]+forward[2] );
D3DXVECTOR3 vUpVec(up[0], up[1], up[2]); //0.0f, 0.0f, 1.0f );
D3DXMatrixLookAtRH(&view, &vEyePt, &vLookatPt, &vUpVec);
...
(in primitive render)
D3DXMatrixTranslation(&world, X, Y, Z);
m_pDevice->SetTransform(D3DTS_WORLD, &world);
m_pDevice->SetTransform(D3DTS_VIEW, &view);
m_pDevice->SetTransform(D3DTS_PROJECTION, &proj);
...
m_pDevice->SetStreamSource(0, m_vb_red, 0, sizeof(CUSTOMVERTEX));
m_pDevice->SetIndices(m_ib_red);
m_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,5,0,2);
However, a similar sequence for DrawTransform isn't working correctly. I get a strangely foreshortened line, and only when I view the line segments at a particular camera position.
Code:
(same render setup)
D3DXMatrixTranslation(&world, 0, 0, 0);
m_pDevice->SetTransform(D3DTS_WORLD, &world);
m_pDevice->SetTransform(D3DTS_VIEW, &view);
m_pDevice->SetTransform(D3DTS_PROJECTION, &proj);
m_pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
m_pLine->DrawTransform(pVertices, dwVertexCount, &view, dwColor);
m_pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
I can't figure out which matrix to use in the DrawTransform call. Supposedly I should use the projection mat, but that doesn't work either.
I turn off the ZENABLE switch because I'd read that there was a Z-buffer issue with DrawTransform.
I know I'm flailing here, but I'm not sure which matrix I should be using.