I've written a COLLADA importer that uses the element of the COLLADA file to define rotation, translation, and scale values for transforms. The values of the matrix are as follows:
Rotation and translation are working correctly by creating the coordinate basis from the x,y, and z axes, and taking the x,y, and z position values. The problem is that scale values, which are derived from the magnitude of the basis vectors represent scaling in the global coordinate system (not the local system as one would assume). This is a problem because after creating the transform, parenting it, and setting it's translation and rotation, the local system is rotated and setting transform.localScale (the only scale property available) applies the global scale values to the local system.
How do I set a transform's global scale in a transform hierarchy?
Maybe it will be helpful:
where thisTransform = gameObject.transform
answered Apr 18 '11 at 10:30 AM
It was much easier than I was making it out to be. The COLLADA matrices make complete sense if you decompose them and set the localPosition, localScale, and localRotation as follows:
Because well-formed COLLADA files have one top-level element, you can rotate the entire scene by -90 deg around the x axis, if Z_UP is true.
answered Sep 18 '10 at 03:12 AM