Archived

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

Translations in d3d

This topic is 5980 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

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
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
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