Notifications
Clear all

[Closed] Matching Rotation Problems

Hello All,

I have been trying to write a small utility that takes an FK chain and rotates its childen so the FK chain pose matches the pose of an IK chain in the scene.

But unfortunatly the results I get are wrong, I know very little about the way maxscript works with rotations. And I suspect it is a very complex area?

I would be very greatful if somebody could give me some pointers on how I should be
[font=Verdana]approaching [/font]this task.

I have attached a test scene and a few lines of script to demonstrate what I have so far.

Many Thanks

Dan

2 Replies

Hi.

I’m not an expert in rigging and things like that but I think you could use something like this:

fn copyMat srcMat &dstMat matchPosition = (
	local dstPos = if matchPosition then srcMat.row4 else dstMat.row4
	dstMat = matrix3 srcMat.row1 srcMat.row2 srcMat.row3 dstPos
)

fn matchHierarchy srcRoot dstRoot = (
	copyMat srcRoot.transform &(dstRoot.transform) false

	local nBone = 1
	for b in dstRoot.children do (
		matchHierarchy srcRoot.children[nBone] b
		nBone += 1
	)
)

matchHierarchy $IKsys_Bicep $FK_Bicep

If you execute this script with your scene opened in MAX, the FK_* hierarchy should take the orientation (and scale) of the IKsys_* hierarchy. If you want your hierarchy to also take the position of the source hierarchy, you should change the line:

copyMat srcRoot.transform &(dstRoot.transform) false

to:

copyMat srcRoot.transform &(dstRoot.transform) true

HalfVector.

That works really well, many thanks for that, the function works perfect. Though how it actualy works goes way over my head!!

I only have one question, I am intending to use your function in animate mode, and at the moment the FK chain children get keys on rotation,position and scale. How would I edit it so to only sets keys for rotation.

Thanks again for your help

much appreciated

Dan