Jump to content
  • Advertisement
Sign in to follow this  
Evil Steve

ID3DXLine::DrawTransform

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm having a bit of difficulty understanding exactly what matrix ID3DXLine::DrawTransform() expects me to pass it. The docs say that it's "A scale, rotate, and translate (SRT) matrix for transforming the points." Does that not mean that if I pass in an identity matrix, the line will be drawn as it would in ID3DXLine::Draw()? Basically, I just want to translate all of my lines by a certain x and y value. So, does anyone know what sort of matrix this function expects? Cheers, Steve

Share this post


Link to post
Share on other sites
Advertisement
I believe it's a matrix with one, two, or all three combined. Just the same as you would set the world transform:

WorldMat = MatA*MatB*MatC;

You can ignore A, B, or C, and that factor (whether it is scaling, translation, or rotation) won't be applied to the world transform.

In short, I think you could just set a matrix using D3DXMatrixTranslation(...) and pass that in.

I believe that's how it works anyway, haven't tested it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Supernat02
I believe it's a matrix with one, two, or all three combined. Just the same as you would set the world transform:

WorldMat = MatA*MatB*MatC;

You can ignore A, B, or C, and that factor (whether it is scaling, translation, or rotation) won't be applied to the world transform.

In short, I think you could just set a matrix using D3DXMatrixTranslation(...) and pass that in.

I believe that's how it works anyway, haven't tested it.
That's what I thought too. But passing an identity matrix causes the lines not to be displayed at all.
Passing the exact same data to ID3DXLine::Draw() works fine. I just set the Z coordinate to 0.0f in the points passed to DrawTransform.

Share this post


Link to post
Share on other sites
Quote:

A scale, rotate, and translate (SRT) matrix for transforming the points. See D3DXMATRIX. If this matrix is a projection matrix, any stippled lines will be drawn with a perspective-correct stippling pattern. Or, you can transform the vertices and use ID3DXLine::Draw to draw the line with a nonperspective-correct stipple pattern.


I'm guessing you need a projection matrix, something like:
D3DXMATRIX Mat;
D3DXMatrixPerspectiveFovLH( &Mat, D3DX_PI/4, 1.0f, 0.3f, 224.5f );
(That's for 3D - dunno about 2D stuff :)).

I suppose if you want to apply transformation, you could multiply that by a translation matrix, just watch your order, it would matter :).

Hope this helps.

Share this post


Link to post
Share on other sites
Ugh, I'm an idiot as usual. I need to supply a view-projection matrix. I tried that earlier, but I did proj*view, not view*proj.

Oh well, here's the working code I have, for future posterity:

D3DXMATRIX matTrans, matProj, matView, matFinal;
D3DXVECTOR3 vEye(0.0f,0.0f,-50.0f), vAt(0.0f,0.0f,0.0f), vUp(0.0f,1.0f,0.0f);
D3DXMatrixTranslation(&matTrans,m_pMap->GetXPos()*-32.0f,m_pMap->GetYPos()*-32.0f,0.0f);
D3DXMatrixOrthoOffCenterLH(&matProj,0.0f,1024.0f,768.0f,0.0f,1.0f,100.0f);
D3DXMatrixLookAtLH(&matView,&vEye,&vAt,&vUp);
matFinal = matTrans*matView*matProj;




Thanks for all the replies [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!