简体   繁体   中英

XMMATRIX use as a transform matrix

In my graphics project i use XMMATRIX to represent transforms of bodies. Now i need to scale translation part of my matrix. How i can do it with XMMATRIX? XMMatrixScale function let me modify only X, y or z rows, but not T.

And in general, i think it is not very comfortable to use XMMATRIX as a transformation matrix. What choices do i have? I would like to have abilities to easily rotate, scale, tranform etc.. A lot of this i have with XMMATRIX, but do i need something else to operate on translation part?

You can just concatenate the operations to get a matrix with scale and translation. If you take your 4x4 matrix with scale coefficients, and apply it to a identity matrix with a translation row, you'll notice that the translation part will also be scaled. You simply have to concatenate the matrices (ie Vector * Scale * Translation for DirectX IIRC.)

In "normal" maths, you would have a scale matrix S, a translation matrix T, and a vector V, and your resulting vecor V' = S * T * V; which first translates V, then scales the complete scene (that is, if you translated 1 unit to the right, and scale by 2, the total translation will be 2.). In DirectX, the order is different IIRC, due to column/row major matrix storage.

Small numeric example: Let's take V = (1, 0, 0), T = Translation by (1, 0, 0), and S = (2, 2, 2). T * V -> (2, 0, 0), this scaled by S = (4, 0, 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM