Setting up Blender for Inverse Kinematics Rigging and Skinning

Let us assume you have motion captured some movement of an object or agent, and you want to animated the same object in 3D. The first part is to setup your mesh with the correct bones, and an additional IK (Inverse Kinematics) bone that will move all these bones, so that any movement to that IK bone will trigger the entire mesh to move. The complexity is that each bone has in Blender has it’s own matrix transformation, and each bone is relative to the armature, which by itself has a coordinate system. So how do you translate a global (x,y,z) coordinate to the bone’s local coordinate system? No worries! This little script below will do it for you:

 

def modify_bone_pos(pose):
 armature=bpy.data.objects['Armature']
 armature_matrix=armature.matrix_world.copy()
 v = Vector()
 v.x,v.y,v.z=pose.x,pose.y,pose.z
 vec_arm=armature_matrix.inverted()*v
 pose_bone=armature.pose.bones['RArm_IK']
 pose_bone_marix=pose_bone.matrix.copy()
 vec_bone=pose_bone_marix.inverted()*vec_arm
 pose_bone.location+=vec_bone

Where the pose is a data structure that contains the bone’s RArm_IK global position. Here’s the result:

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s