• Advertisement
Sign in to follow this  

transformations.

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

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


Link to post
Share on other sites
Advertisement

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


Link to post
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.

Share this post


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

  • Advertisement