Original Post
sorry for longish post, but i''m at the end of my rope.
here is code that doesn''t display anything at all:
D3DMATRIX projMatrix, viewMatrix, destMatrix1, destMatrix2;
D3DVECTOR scrCenter( 400.0f, 300.0f, 0.0f );
D3DUtil_SetTranslateMatrix( destMatrix1, scrCenter );
D3DUtil_SetProjectionMatrix( projMatrix, 3.141592f/4.0f, 1.0f, 1.0f, 100.0f );
D3DMath_MatrixMultiply( destMatrix2, destMatrix1, projMatrix );
projMatrix = destMatrix2;
D3DVECTOR vEyePt = m_vPos; // m_vPos is a vector describing camera pos (init 0,0,-1)
D3DVECTOR vLookatPt = D3DVECTOR( 0.0f, 0.0f, 0.0f );
D3DVECTOR vUpVec = D3DVECTOR( 0.0f, 1.0f, 0.0f );
D3DUtil_SetViewMatrix( destMatrix, vEyePt, vLookatPt, vUpVec );
pd3d->SetTransformState( D3DTRANSFORMSTATE_PROJECTION, projMatrix );
pd3d->SetTransformState( D3DTRANSFORMSTATE_VIEW, viewMatrix );
D3DVECTOR lpVerts[4];
lpVerts[0] = D3DVECTOR( -1.0f, -1.0f, 0.0f );
lpVerts[1] = D3DVECTOR( 5.0f, -1.0f, 0.0f );
lpVerts[2] = D3DVECTOR( -1.0f, 5.0f, 0.0f );
lpVerts[3] = D3DVECTOR( 5.0f, 5.0f, 0.0f );
D3DLVERTEX verts[] = {
D3DLVERTEX( lpVerts[0], RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 0.0f, 0.0f ),
D3DLVERTEX( lpVerts[1], RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 1.0f, 0.0f ),
D3DLVERTEX( lpVerts[2], RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 0.0f, 1.0f ),
D3DLVERTEX( lpVerts[3], RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 1.0f, 1.0f )
};
pdxInterface->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, (LPVOID)verts, 4, NULL);
here is code that displays something ok straight on but is all f* up as soon as camera moves:
D3DMATRIX projMatrix, destMatrix, destMatrix1, destMatrix2;
D3DVECTOR scrCenter( 400.0f, 300.0f, 0.0f );
D3DUtil_SetTranslateMatrix( destMatrix1, scrCenter );
D3DUtil_SetProjectionMatrix( projMatrix, 3.141592f/4.0f, 1.0f, 1.0f, 100.0f );
D3DMath_MatrixMultiply( destMatrix2, destMatrix1, projMatrix );
projMatrix = destMatrix2;
D3DVECTOR vEyePt = m_vPos; // m_vPos is a vector describing camera pos (init 0,0,-1)
D3DVECTOR vLookatPt = D3DVECTOR( 0.0f, 0.0f, 0.0f );
D3DVECTOR vUpVec = D3DVECTOR( 0.0f, 1.0f, 0.0f );
D3DUtil_SetViewMatrix( destMatrix, vEyePt, vLookatPt, vUpVec );
D3DMath_MatrixMultiply( m_mComposite, destMatrix1, projMatrix );
D3DVECTOR lpVerts[4];
lpVerts[0] = D3DVECTOR( -1.0f, -1.0f, 0.0f );
lpVerts[1] = D3DVECTOR( 5.0f, -1.0f, 0.0f );
lpVerts[2] = D3DVECTOR( -1.0f, 5.0f, 0.0f );
lpVerts[3] = D3DVECTOR( 5.0f, 5.0f, 0.0f );
D3DMath_VectorMatrixMultiply( lpVerts[0], lpVerts[0], m_mComposite );
D3DMath_VectorMatrixMultiply( lpVerts[1], lpVerts[1], m_mComposite );
D3DMath_VectorMatrixMultiply( lpVerts[2], lpVerts[2], m_mComposite );
D3DMath_VectorMatrixMultiply( lpVerts[3], lpVerts[3], m_mComposite );
D3DTLVERTEX verts[] = {
D3DTLVERTEX( lpVerts[0], 1.0f, RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 0.0f, 0.0f ),
D3DTLVERTEX( lpVerts[1], 1.0f, RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 1.0f, 0.0f ),
D3DTLVERTEX( lpVerts[2], 1.0f, RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 0.0f, 1.0f ),
D3DTLVERTEX( lpVerts[3], 1.0f, RGB_MAKE(255,255,255), RGB_MAKE(0,0,0), 1.0f, 1.0f )
};
pdxInterface->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, (LPVOID)verts, 4, NULL);
what i don''t understand is the same damn params to the SetTransformState(...) (1st example) calls work fine in an overhauled version of one of the samples but not in mine.
what i also don''t understand is why the second version doesn''t work either. it works relatively well orthographic, but you should see it. it is the most f* up thing i''ve ever seen.
i''ve read dozens of books and tutorials and used twice that many different projection matrices. why doesn''t one of the 3 different ones provided in dx7 sdk doc work? and why the hell can''t d3d transform my f* vertices? it won''t work even with Identity matrices selected into transforms.
thanks (sorry about pissed off attitude, but i''ve worked on this enough myself, it''s time for someone to tell me how to do it).
thanks again in advance. i''ll even send you money to help me fix this. i''m at the end of my rope.
crazy166
some people think i'm crazy, some people know it