Archived

This topic is now archived and is closed to further replies.

Agrajag

Translations in d3d

Recommended Posts

Agrajag    122
I was wondering how to move only one object at a time in DX. I thought this might work --------------------------------------------------- D3DXMATRIX mat; D3DXMatrixTranslation(&mat, X, Y, 0); // it''s for 2D, so Z isn''t necessary g_pd3dDevice->SetTransform( D3DTS_WORLD, &mat ); ---------------------------------------------------- but this moves all the objects =(. Any help would be great.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
D3DXMATRIX mat, ident;
D3DXMatrixTranslation(&mat, X, Y, 0);
D3DXMatrixIdentity(&ident);

// set world matrix
pd3dDevice->SetTransform(D3DTS_WORLD, &mat);

// draw your object here

// reset world matrix
pd3dDevice->SetTransform(D3DTS_WORLD, &mat);

// draw next thing here


etc...

Share this post


Link to post
Share on other sites
Agrajag    122
thanks a lot, the only thing is that when you reset the matrix, you use `g_pd3dDevice->SetTransform( D3DTS_WORLD, &ident );` instead of ` &mat ` again.

thanks

Share this post


Link to post
Share on other sites