Skip to main content
gamedev.net
🔒 Locked

TranslateRotateScale function ??

Started by MarkThrush 2 replies 550+ views
Original Post
MarkThrush
MarkThrush
I want to do a function like this: Matrix TranslateRotateScale(Vector pos, float X, float Y, float Z, float S); The function would 1. translate object to pos 2. rotate around X-axis by X radians 3. rotate around Y-axis by Y radians 4. rotate around Z-axis by Z radians 5. scale the object by factor S 6. return the Matrix containing all these steps How to do this correctly with D3DXMatrix... functions ?
Illco
Illco
Use D3DXMatrixTranslation, D3DXMatrixYawPitchRoll and D3DXMatrixScaling to create three matrices. Then multiply them together and return the result.

Illco
MarkThrush
MarkThrush
Thank you Illco.

Is the correct order to multiply:

Rotate x Translate x Scale

I get different results when multiplying in different order .

?
Evil Steve
Evil Steve
Quote:
Original post by MarkThrush
Thank you Illco.

Is the correct order to multiply:

Rotate x Translate x Scale

I get different results when multiplying in different order .

?
That depends on what you want to do. You probably want Rotate x Scale x Translate. That'll rotate the object about it's origin, scale it, then translate it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.