I am considering dropping non uniform scale support, if I do, I downsize my SRT structure from 10 floats to 8, chances are scale won't even be used at all, but the reason why I added it on the first place was because of a model that used mirror scaling on X to duplicate the piece of armor from the right to the left. Granted, I could modify, and fix the model, but, but there were thousand of these shortcuts taken by the modelers, I'd have a problem. I am using stock models so its not like I could go to the modeler and ask him/her to fix it and submit it again.
Adding or Concatenating Transforms (Scale, Rotation, Translation)
Members - Reputation: 1148
Posted 31 January 2013 - 12:31 AM
Not really pointing out an error in the first part, just explaining that what you originally wanted to do - concatenate sequence of SRT into a single SRT where S scales using a vector that represents scaling on different axes, is (technically speaking) impossible - you indeed need a full blown matrix here, or if you want to optimize a tiny bit, 3x3 matrix and translation. That's because sequence of R S R can produce scaling along the diagonal, which you can not represent with one S R T . (I am assuming matrices apply in left to right, i.e. directx order)
I am not sure I follow, what do you mean? in the end what my SRT operations do is a simplified matrix multiplication, so if you take S,R,and T as matrices with scale, rotation and translation respectively, and I as identity the operation you describe would be something along these lines:
( I * R * I ) * (S * I * I) * ( I * *R * I ),
which is the same as RSR, wouldn't the scale vector (diagonal) on the second matrix be doing the scale on world axes rather than object axes as well?
I think I see where you're going, but I haven't had time to think more about it.
The second part of your post, I am not sure if you're pointing out a (another?) problem or providing me with an optimization
Thank you for your comments!
edit:However if you are certain you only use non uniform scaling as the first transformation applied, then it can work. If U is uniform scaling and you only have S R T U R T U R T U R T .... sequence, then you're in the clear.
Second is indeed providing with an optimization. In my software I have a class that does rotation using quaternion and translation using a vector, it works pretty much same from outside as a matrix. The reason I'm using that is not so much optimization as convenience when doing physics or especially when interpolating rotations between frames (which I do because I run physics at constant framerate). In your case I'd probably just convert to matrices then multiply those together, I'd probably use 3x3 matrices with translation rather than full blown 4x4 , basically, you assume the right column (or bottom row, depending to convention) is always 0 0 0 1 .
Edited by Dmytry, 31 January 2013 - 12:56 AM.
GDNet+ - Reputation: 1331
Posted 31 January 2013 - 08:43 AM
Alright, thanks Dmytry, I am just using these for DCC animation interpolation, skeletal animation to be exact at the moment, so I think Rob is right on the money, I still need to go back and factor in scaling properly, currently busy with my resource system.
Thanks to all again!