Notifications
Clear all

[Closed] Game bone's rotation key issue

Hi, i made a simple tool that build animation into max from a game’s animation file, the script use a recursive function that start from RootBone and follow the children tree:

		if setAnim then
		(
			format "%
" BoneName[iBone]
			local posanim = PosKey[iBone]
			local rotanim = RotKey[iBone]
			local PosControl = obj.position.controller = TCB_Position()
			local RotControl = obj.rotation.controller = TCB_Rotation()
			Kpos = addnewkey PosControl 0
			Krot = addnewkey RotControl 0
			Kpos.value = Rpos
			Krot.value = prevq = quat 0 0 0 1
				
			animate on for t=1 to posanim.count do
			(
				local tt = t+startFrame
				local p = posanim[t]
				local q = rotanim[t]
				local Kpos = addnewkey PosControl tt
				local Krot = addnewkey RotControl tt
				at time tt Kpos.value = Rpos + p 
				at time tt in coordsys local Krot.value = q - prevq -- wrong , quat increase rotation eatch frame
				at time tt in coordsys local obj.rotation = q - prevq --correct		
				prevq = q	
			)
		)

For position controller there aren’t issue, all position key are a increment from basepose (or pos at time 0 ) but for rotation stored as quaternion i find a lot off issue.
I tried many configuration and i find the correct result using code:

at time tt in coordsys local obj.rotation = q - prevq

But i don’t understand the difference from

at time tt in coordsys local Krot.value = q - prevq

Some one had worked with some Game’s tool ? Can tell me or send me a link to understand how games store the quaternion rotation of bones ?

thanks.