[Closed] Copy Rotation
Anyone knows if there’s a easy way to copy a rotation from one object to other in maxscript?.
Because if I try to copy straight the rotation from object A to object B like this sometimes makes strange things.
A.rotation = B. rotation
I even tried…
A.rotation = in coordsys local B.rotation
But just works sometimes…
P.S. Maybe a good link to a tutorial of the quad, euler rotation coordinates stuff?.
thank you very much in advance.
hi fabman,
depending on the type of rotation controller u have, the result is different. I only tried copying rotation keys between 2 objects that uses eulerXYZ as rotation, and i use these:
ObjectA.rotation.controller.x_rotation = ObjectB.rotation.controller.x_rotation
ObjectA.rotation.controller.y_rotation = ObjectB.rotation.controller.y_rotation
ObjectA.rotation.controller.z_rotation = ObjectB.rotation.controller.z_rotation
if they’re both using TCB, i think just ObjectA.rotation = ObjectB.rotation would work.
hope this helps.
-yan
It should work if you do this:
p = a.pos
a.rotation = inverse b.transform.rotation
a.pos = p
Rotation is an amazingly complex subject, and can be confusing at times. In 3D, you have left-hand coordinate systems and right-hand ones. The reason the above code works is that when you get the transform of an object with Maxscript it is returned in one coordinate system, but when you set the .rotation property it is performed in the other. Thus you have to invert the transform matrix of the ‘source’ to put it in the coordinate system that will give the expected result on the ‘target’. And since setting rotations explicitly like this works in world space rather than local, you need to re-set the position after performing the rotation; otherwise your object will be moved off somewhere you’re not expecting it to be.
If that clarifies anything, then I’m glad I could help! Otherwise, I hope I didn’t confuse you further:surprised
RH
i’m confused…:shrug: , especially about inversing the transform. I’ve only use scripting on a case by case basis, can u explain a bit more about this whole transform idea if it’s not too time consuming? thanx in advance.
-yan
p.s. sorry for giving out my cheap solution earlier:p
basically back is front, up is down, in is out but up is never over nor out. eh? lol