Notifications
Clear all

[Closed] Linking postion based controllers to bone rotations

So after getting a joystick creation script work, the next step it to link the controllers to bones, but I’m having to fudge this with hard coded correctional values on a per bone basis. I don’t want to do this if possible.

(Some of this is hard coded at the minute, I’ll be creating a function that is much more generic once the basics are done).

Ok, so my problem is that when I link the controller to the bone, the bone rotates from it’s rest postion as soon as I perform the link, and I find that I have to apply a correction to this.

For the central brow controller, I link the (negative) Y postion to the Z rotation:

paramWire.connect $JS_Circle_Brow.pos.controller.Y_Position.controller[#Limited_Controller__Bezier_Float] $FB_C_Brow.rotation.controller[#Z_Rotation] “(-Limited_Controller__Bezier_Float) + DegToRad(70)”

However, the correction I’m applying “+ DegToRad(70)” works because I tried lots of numbers until I got one that worked. I don’t understand WHAT I’m actually applying as a correction, and I’m loathe to just throw in arbitrary values.

Can this offset be calculated in script instead?

2 Replies

So, knowing that I need to multiply my normalised slider value by the rotational angle limit, I’ve pushed a little further, but I still can’t get it work out the offset

– normalise the slider (will be passed in as variable)
nrmlzr = 20.0

– The rotational limit (will be passed in as variable)
rotl = 45.0

–some if statements here to decide what controllers to create…
–basically build stuff from the funtions input, for now hardcoded

pwcontrol = $JS_Circle_Up.pos.controller.Y_Position.controller[#Limited_Controller__Bezier_Float]

pwtarget = $Bone01.rotation.controller[#Z_Rotation]

controlexp = “Limited_Controller__Bezier_Float *” + degtorad(nrmlzr * rotl) as string

paramWire.connect pwcontrol pwtarget controlexp

The expression is rotating the correct angle now, if I can figure out the offset I should be good.

I think I’ve cracked this – $.rotation and $.transform.rotation give different results, the transform one is correct.

This script is still a mess, hardcoded for one axis, but it SEEMS to work. When tidied and turned into a funtion, it should be good.

– bone and controller (will be passed in as variable)
thebone = $Bone01
thecontrol = $JS_Circle_Blink

– normalise the slider (will be passed in as variable)
nrmlzr = 20.0

– The rotational limit (will be passed in as variable)
rotl = 45.0

– Get the current base rotations of the bone.

tr = in coordsys world thebone.transform.rotation as eulerangles
rx = tr.x
ry = tr.y
rz = tr.z

pwcontrol = thecontrol.pos.controller.Y_Position.controller[#Limited_Controller__Bezier_Float]

pwtarget = thebone.rotation.controller[#Z_Rotation]

– calculate a normalized rotation
controlexp = “(Limited_Controller__Bezier_Float * degtorad ” + ((nrmlzr * rotl) as string) + “)”

– add the rotational offset
controlexp = controlexp + ” + degtorad ” + (rz as string)

– link ’em
paramWire.connect pwcontrol pwtarget controlexp