Notifications
Clear all

[Closed] Rotate bends gizmo givin a world space rotation matrix

Hi,
I have some animated chunks exported from Thinking particles that I need to rotate the bend gizmo at a certain direction.

Here are the details:
The flat part of the chunks that I need to bend is perpendicular to X axis.
Ai need to rotate the bends gizmo axis around the X axis pointing to a world coordinates vector
The chunks have scale in them (they was exported like this), looks like all of them are uniform scaled.

Here is the calculation of rotation matrix:


vec1 = [-1.0, 0.0, 0.0] --World space need to look at vector
upVecObj = normalize ($.transform).row1 --X axis (in this case the upVector) of the chunk
vecz = normalize (cross upVecObj vec1) --Z axis perpendicular
vecy = normalize (cross upVecObj vecz) --Y axis that is trying to perserve the lookat vector
newRot = matrix3 upVecObj vecy vecz   [1,1,1] --New rotation

now I need to apply this to $.modifiers[1].gizmo.rotation non incremental (absolute)
Didn’t found any good solution…
I even tried to bring the direction vector to object space first then create the rotation matrix, still the X axis was corect but Y an Z offseted in rotation 🙁

Thanks