# transformations.

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

## Recommended Posts

ok how do you translate and scale a 3d object. This is what Im doing D3DXMATRIX tra; D3DXMATRIX scale; D3DXMatrixTransalation(&tra, 1.0f,1.0f,1.0f); D3DXMatrixScaling(&scale, 1.0f,2.0f,1.0f); Device->SetTransform(D3DTS_WORLD, &tra); Device->SetTransform(D3DTS_WORLD, &scale); ///Drawinf the object here but the thing is the object only gets scaled. and if I move the Device->SetTransform(D3DTS_WORLD, &tra); down, then it only gets translated. so whats wrong?

##### Share on other sites

SetTransform() is like SetRenderState() in so much as only the most recent value for a state will be used for drawing.

So if you have:
SetTransform(D3DTS_WORLD, &A);
SetTransform(D3DTS_WORLD, &B);
SetTransform(D3DTS_WORLD, &C);
DrawPrimitive( blah );

The value of D3DTS_WORLD that gets used is C, and *only* C.

D3D doesn't concatenate your matrices for you, it just accepts a single matrix for the world matrix and uses that to draw with.

D3DXMatrixTransalation() and D3DXMatrixScaling() build entirely independent matrices that only serve one purpose (i.e. translate, or scale).

If you want the matrix to serve multiple purposes, you should multiply (concatenate) the matrices together, e.g.:

D3DXMATRIX tra;D3DXMATRIX scale;D3DXMatrixTransalation(&tra, 1.0f,1.0f,1.0f);D3DXMatrixScaling(&scale, 1.0f,2.0f,1.0f);...D3DXMATRIX scale_and_translate;D3DXMatrixMultiply( &scale_and_translate, &translate, &scale );...Device->SetTransform(D3DTS_WORLD, &scale_and_translate);

The following tutorial may be of use to you:
http://www.andypike.com/tutorials/directx8/005.asp

##### Share on other sites
great, Ill remember that, Thank You, you are now my hero. but as far as matricies are concerned I do understand them fairly well, I just didnt know you had to concatnate them.

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5
Rutin
10

• 18
• 13
• 14
• 76
• 22
• ### Forum Statistics

• Total Topics
632149
• Total Posts
3004363

×

## Important Information

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!