[Closed] Making the CS Biped head control the neck
Since it seems that I’m stuck with Biped for now, I’d like to be able to make the Biped head control the two neck joints underneath it to pass down it’s rotation.
I’ve managed to come up with a script that does actually work, but I have to run it after rotation of the head bone.
So, I was hoping someone could help me figure out how to make it constantly update – I’m thinking that I can probably use a script controller and the dependsOn command to make each neck joints rotation depend on the head. Ideally I’ll end up with an interface that will allow myself or the animators to turn it on or off at will, as there may be occasions when I won’t want the head to control the neck.
Anyway, this is the working code that I have.
– Set up variables to store the rotatation data from the bones via the Expose Transforms
herx = $‘etm_Head’.baseObject[#Local_Euler_X].value
hery = $‘etm_Head’.baseObject[#Local_Euler_Y].value
herz = $‘etm_Head’.baseObject[#Local_Euler_Z].value
– calculate the angles I need to apply, for some reason the biped
– neck xyz is inverted to zyx
rot_nl = eulerangles (herz*.33) (-hery*.33) (herx*.33)
rot_nu = eulerangles (herz*.33) (-hery*.33) (herx*.33)
– perform the rotation
rotate $‘Char NeckL’ rot_nl
rotate $‘Char NeckU’ rot_nu
Got a working method. It’s messy. It doesn’t feel elegant enough…but it works.
Using a scene redraw callback, I perform the rotate at any scene redraw. I should probably check to see if the head rotation has changed…
fn autoRotateNeck = (
– Set up variables to store the rotatation data from the bones via the Expose Transforms
herx = $‘etm_Head’.baseObject[#Local_Euler_X].value
hery = $‘etm_Head’.baseObject[#Local_Euler_Y].value
herz = $‘etm_Head’.baseObject[#Local_Euler_Z].value
-- calculate the angles I need to apply, for some reason the biped
-- neck xyz is inverted to zyx
rot_nl = eulerangles (herz*.33) (-hery*.33) (herx*.33)
rot_nu = eulerangles (herz*.33) (-hery*.33) (herx*.33)
-- perform the rotation
rotate $'Char NeckL' rot_nl
rotate $'Char NeckU' rot_nu
)
rollout necktools “Neck Tooks” width:162 height:300
(
button neckon “Enable Auto Neck” pos:[10,20] width:140 height:30
button neckoff “Disable Auto Neck” pos:[10,60] width:140 height:30
on neckon pressed do registerRedrawViewsCallback autoRotateNeck
on neckoff pressed do unRegisterRedrawViewsCallback autoRotateNeck
)
– Create floater
theNewFloater = newRolloutFloater “Animation Helper Tools” 180 200
– Add the rollout section
addRollout necktools theNewFloater
It also works nicely on my existing rigs that have only 1 neck bone by changing the rotation multiplier to 0.5 and changing a couple of variable names.
Cheers to Luke at work for suggesting the callbacks.