My first update for the Ik arm rig script:
Having made sure my buttons work...it was time to put them to work...collecting information and doing stuff with that information...
The first actions should be creating the shapes for the wrist controller and the elbow pole vector controller...for now they are both boxes and have a set size...in later versions the size will be scalable by the user before the script runs..center their pivots...move the positions and orient the shapes to the bones...then align their pivots accordingly...and freeze their transformations...
To freeze transformations on an object I took a section of code provided by Max, since the tools provided by Max are macro's in themselves, and pasted it inside a function.
fn FreezeTransform item =(local CurObj = itemif classof CurObj.rotation.controller != Rotation_Layer do(-- freeze rotationCurObj.rotation.controller = Euler_Xyz()CurObj.rotation.controller = Rotation_list()CurObj.rotation.controller.available.controller = Euler_xyz()/* "Localization on" */CurObj.rotation.controller.setname 1 "Frozen Rotation"CurObj.rotation.controller.setname 2 "Zero Euler XYZ"/* "Localization off" */CurObj.rotation.controller.SetActive 2)if classof CurObj.position.controller != Position_Layer do(-- freeze positionCurObj.position.controller = Bezier_Position()CurObj.position.controller = position_list()CurObj.position.controller.available.controller = Position_XYZ()/* "Localization on" */CurObj.position.controller.setname 1 "Frozen Position"CurObj.position.controller.setname 2 "Zero Pos XYZ"/* "Localization off" */CurObj.position.controller.SetActive 2-- position to zeroCurObj.Position.controller[2].x_Position = 0CurObj.Position.controller[2].y_Position = 0CurObj.Position.controller[2].z_Position = 0)
The next section of code is my own. Going step by step commenting as I go making things less confusing. Adding the Ikhandle, setting the preferred angle and adding the constraints is the point I'm at now. Currently I have explicit names for these functions. I would like to refer back to the local variables assigned earlier in the script, but for now to get things moving I have given them specific names of scene objects.
)--next update Add selectable controller shapesBox lengthsegs:1 widthsegs:1 heightsegs:1 length:4 width:4 height:4 mapcoords:on name: "ik_arm_ctrl" color: bluewCtrl = $ik_arm_ctrl --wrist ControlwCtrl.pivot = [0, 0, 2] --NEEDto change on next update to centerPivot of any objectparent $ik_arm_ctrl $Bip01_L_HandAlignToParent--alignpivot to wrist bonewBone = wristobj --wrist BonewCtrl.rotation = wBone.rotation --match rotationswCtrl.pos = wBone.transform.position --match positionsfreezeTransform wCtrl --freezeTransformations--Ik stuffIKSys.ikChain bicepobj wristobj "arm_ikh"--add ik handleiksys.ikchain $Bip01_L_UpperArm $Bip01_L_Hand "IKHISolver"select $arm_ikhIKChainControl.setPrefAngles() --assume preferred angle--add position constraint--add rotation constraintbox lengthsegs:1 widthsegs:1 heightsegs:1 length:2 width:2 height:2 mapcoords:on name: "elbow_pv" color: blueeCtrl = $elbow_pv --wrist ControleCtrl.pivot = [0, 0, 1] --NEEDto change on next update to centerPivot of any objecteBone = elbowobj --wrist BoneeCtrl.rotation = eBone.rotation --match rotationseCtrl.pos = eBone.transform.position --match positions)
The next update will be a completed script for rigging an Arm with IK. Future updates will include...right or left arm capability, the FK arm Rig and an option for both IK and FK plus switching.
No comments:
Post a Comment