Notifications
Clear all

[Closed] Reading rotation keys

I promise I’ve searched the forums but either I don’t know what I’m looking for or don’t understand what I find.

Anyway, I want to set rotations on a biped (using biped.settransform) based on the rotation keys of another object. I specifically want to read those rotation keys and apply the exact same rotations. I can get the biped.settransform to work just fine as long as I make up my own quat, but what I can’t figure out is how to get the quat from the object key.

If someone could even point me in the right direction I would appreciate it (I’m feeling particular stupid since the closest I can come is getKey object.rotation.z_rotation.controller, but how this gets me a quat or even what to do with it after I do this is beyond me).

3 Replies

I may have misunderstood the question but does this help?

objQuatVal = $nonBipedObject.transform.[font=‘Courier New’]rotationpart – should return a quat value[/font]

Dan

getKey $.rotation.z_rotation.controller 1
 

where 1 is the index of the key you want. Once you have the key you can query the properties of the key.

yourKey = getKey $.rotation.z_rotation.controller 1
print yourKey.time
print yourKey.value
print yourKey.intangent

Thanks, guys. Turns out both of you are correct (and helpful).

My problem was bigger than this and even with this information I was rather stuck but I eventually worked through it. Just in case anyone finds this thread sometime later I’d like to at least finish the information.

As it happens you can indeed use Getkey or query the object directly to get a quat, but the bigger issue is setting a biped part (in this case, the head) to that quat. This code is one way that should work but will fail with any kind of “normal” object:

anim_Start = animationRange.start
anim_End = animationRange.end
DisableSceneRedraw()

Animate On

  For t = anim_Start to anim_End Do
  (
    sliderTime = t
  biped.setTransform $'Bip01 Head' #pos ($box02.transform.pos) True
    biped.setTransform $'Bip01 Head' #rotation ($box02.transform.rotation) True
  t += 1
  )

Animate Off
EnableSceneRedraw()

If you try this (you should, it’s instructive) the biped head will immediately lay over on its side and turn around 180 degrees. Same for using Getkey and Setkey. Now, if you create two bones (you don’t need more) and use the topmost bone as your object, both this code as well as Getkey and Setkey will work (actually there’s one more “gotcha” in that the bone assembly needs to be rotated in the same orientation as your biped, but that’s no big deal – the only symptom will be the biped head will rotate in whatever direction the bone assembly is created).

So applying rotations to a biped head cannot be done from a single object – somehow it needs the matching bone structure to work properly. This isn’t a big deal – if you want to apply the rotations from a box you can first apply them to the bone structure (which will work correctly) and then to the biped. But it’s one more quirky thing with biped.