Translations in d3d

Started by
1 comment, last by Agrajag 22 years, 8 months ago
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.
I am so hip, I have difficulty seeing over my pelvis
Advertisement
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...
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
I am so hip, I have difficulty seeing over my pelvis

This topic is closed to new replies.

Advertisement