# ================ # SOFTWARE LICENSE # ================ # The MIT License (MIT) # Copyright (c) 2018 Yutaca Sawai (Varipon Institute) # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # ============================================================== # LICENSE FOR CONTENT PROCEDURALLY GENERATED USING THIS SOFTWARE # ============================================================== # All content procedurally generated by this software and its permutations # are licensed under Creative Commons Attribution By 3.0: # https://creativecommons.org/licenses/by/3.0/ # If in doubt, please get in touch. As a rule of thumb I'm fine with anyone # using these spaceships in commercial works, but I am less okay with people # selling the spaceship models directly for commercial gain. Use common sense. #!/usr/bin/python import bpy from bpy import * import mathutils import math from mathutils import * from math import * class Formula: J = 18 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 0 frame_end = 120 def __init__(self, P, A, move, part, helicity, start, end): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.a = [0 for i in range(4)] # Joint α self.b = [0 for i in range(self.J)] # Joint β self.y = [0 for i in range(self.J)] # Joint γ self.o = [0 for i in range(self.J)] # Joint δ # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y, self.o) # Construction Movement self.constructMovement(self.J, self.helicity, self.amt, self.rig, self.a, self.b, self.y, self.o) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) # Configuration Linkage self.configLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) def configMovement(self, P, A, J, a, b, y, o): mat_a = [0 for i in range(4)] # Joint α matrix mat_b = [0 for i in range(self.J)] # Joint β matrix mat_y = [0 for i in range(self.J)] # Joint γ matrix mat_o = [0 for i in range(self.J)] # Joint δ matrix a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) o[1] = mathutils.Euler((A, A, 0), 'XYZ') print ("o1 =", o[1]) B = A * 2 * sqrt (2) C = B + (B * sqrt (2)) D = C * sqrt (2) E = C + D a[0] = mathutils.Euler((-A - E + (D * 0.5), -A - (D * 0.5), 0), 'XYZ') print ("a0 =", a[0]) mat_a[0] = Matrix.Translation(a[0]) a[3] = mathutils.Euler((0-a[0].x, 0-a[0].y, 0-a[0].z), 'XYZ') print ("a3 =", a[3]) mat_a[3] = Matrix.Translation(a[3]) y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) mat_y[1] = Matrix.Translation(y[1]) ### pattern A b[2] = mathutils.Euler((a[0].x + E + (A * 2), a[0].y + (A * 2), 0), 'XYZ') print ("b2 =", b[2]) mat_b[2] = Matrix.Translation(b[2]) b[3] = mathutils.Euler((a[0].x + E - (D * 0.5), a[0].y - (A * 2), 0), 'XYZ') print ("b3 =", b[3]) mat_b[3] = Matrix.Translation(b[3]) y[2] = mathutils.Euler((a[0].x + E, a[0].y, 0), 'XYZ') print ("y2 =", y[2]) mat_y[2] = Matrix.Translation(y[2]) y[3] = mathutils.Euler((a[0].x + E - (D * 0.5), a[0].y - (D * 0.5), 0), 'XYZ') print ("y3 =", y[3]) mat_y[3] = Matrix.Translation(y[3]) o[2] = mathutils.Euler((a[0].x + E + (A * 2), a[0].y - (A * 2), 0), 'XYZ') print ("o2 =", o[2]) mat_o[2] = Matrix.Translation(o[2]) o[3] = mathutils.Euler((a[0].x + E - (D * 0.5) - (A * 2), a[0].y - (D * 0.5) - (A * 2), 0), 'XYZ') print ("o3 =", o[3]) mat_o[3] = Matrix.Translation(o[3]) ### pattern A end org_rot_mat = Matrix.Rotation(math.radians(0), 4, 'Z') # define the rotation rot_mat = Matrix.Rotation(math.radians(-45), 4, 'Z') for j in range(2, J - 2): mat_y[j + 2] = mat_a[0] * org_rot_mat * rot_mat * mat_a[3] * mat_y[j] # obj.matrix_world = mat_y[j + 2] # extract components back out of the matrix loc, rot, sca = mat_y[j + 2].decompose() y[j + 2] = mathutils.Euler(loc, 'XYZ') print("y"+str(j + 2)+" = ", y[j + 2], rot, sca) mat_b[j + 2] = mat_a[0] * org_rot_mat * rot_mat * mat_a[3] * mat_b[j] # obj.matrix_world = mat_b[j + 2] # extract components back out of the matrix loc, rot, sca = mat_b[j + 2].decompose() b[j + 2] = mathutils.Euler(loc, 'XYZ') print("b"+str(j + 2)+" = ", b[j + 2], rot, sca) mat_o[j + 2] = mat_a[0] * org_rot_mat * rot_mat * mat_a[3] * mat_o[j] # obj.matrix_world = mat_o[j + 2] # extract components back out of the matrix loc, rot, sca = mat_o[j + 2].decompose() o[j + 2] = mathutils.Euler(loc, 'XYZ') print("o"+str(j + 2)+" = ", o[j + 2], rot, sca) def constructMovement(self, J, helicity, amt, rig, a, b, y, o): # Linkages aa = [[0 for i in range(4)] for j in range(4)] # Link α(i) - α(j) ab = [[0 for i in range(4)] for j in range(4)] # Link α(i) - β(j) ya = [[0 for i in range(4)] for j in range(4)] # Link γ(i) - α(j) ao = [[0 for i in range(4)] for j in range(4)] # Link α(i) - δ(j) ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) rig.location = mathutils.Euler((0.0, 0.0, 0.0), 'XYZ') rig.show_x_ray = True amt.show_names = True # amt.draw_type = 'STICK' amt.draw_type = 'BBONE' # Link object to scene scn = bpy.context.scene scn.objects.link(rig) scn.objects.active = rig scn.update() # Edit bpy.ops.object.editmode_toggle() # Construction Linkage aa[2][1] = amt.edit_bones.new('a2a1') aa[2][1].head = a[2] aa[2][1].tail = a[1] ab[1][1] = amt.edit_bones.new('a1b1') ab[1][1].head = a[1] ab[1][1].tail = b[1] ab[1][1].parent = aa[2][1] by[1][1] = amt.edit_bones.new('b1y1') by[1][1].head = b[1] by[1][1].tail = y[1] by[1][1].parent = ab[1][1] by[1][1].use_inherit_rotation = False ya[1][2] = amt.edit_bones.new('y1a2') ya[1][2].head = y[1] ya[1][2].tail = a[2] ya[1][2].parent = by[1][1] ao[2][1] = amt.edit_bones.new('a2o1') ao[2][1].head = a[2] ao[2][1].tail = o[1] ao[2][1].parent = ya[1][2] ob[1][2] = amt.edit_bones.new('o1b2') ob[1][2].head = o[1] ob[1][2].tail = b[2] ob[1][2].parent = ao[2][1] yy[1][2] = amt.edit_bones.new('y1y2') yy[1][2].head = y[1] yy[1][2].tail = y[2] yy[1][2].parent = by[1][1] for j in range(2, J - 1): by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j)) by[j][j].head = b[j] by[j][j].tail = y[j] by[j][j].parent = ob[j-1][j] yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j)) yo[j][j].head = y[j] yo[j][j].tail = o[j] yo[j][j].parent = yy[j-1][j] yy[j][j+1] = amt.edit_bones.new('y'+ str(j) + 'y'+ str(j+1)) yy[j][j+1].head = y[j] yy[j][j+1].tail = y[j+1] yy[j][j+1].parent = by[j][j] if j < (J-2): ob[j][j+1] = amt.edit_bones.new('o'+ str(j) + 'b'+ str(j+1)) ob[j][j+1].head = o[j] ob[j][j+1].tail = b[j+1] ob[j][j+1].parent = yo[j][j] # all bones select #bpy.ops.pose.select_all(action="SELECT") for b in amt.edit_bones: b.select = True if helicity == 'right': bpy.ops.armature.calculate_roll(type='GLOBAL_POS_Z') else: bpy.ops.armature.calculate_roll(type='GLOBAL_NEG_Z') # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # IK constraint cns = rig.pose.bones['y1a2'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'a2a1' cns.chain_count = 2 cns.use_stretch = False for j in range(2, J - 1): cns = rig.pose.bones['b'+str(j) +'y'+str(j)].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False bpy.ops.object.mode_set(mode='OBJECT') def configRotation(self, rig, interval, frame_start, frame_end, start, end): # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # key insert keyframe_insert_interval = interval rig.pose.bones["a1b1"].rotation_mode = 'XYZ' rig.pose.bones["a1b1"].rotation_euler.z = math.radians(start) rig.pose.bones["a1b1"].keyframe_insert(data_path="rotation_euler",frame=frame_start) rig.pose.bones["a1b1"].rotation_mode = 'XYZ' rig.pose.bones["a1b1"].rotation_euler.z = math.radians(end) rig.pose.bones["a1b1"].keyframe_insert(data_path="rotation_euler",frame=frame_end) for curve in bpy.context.active_object.animation_data.action.fcurves: cycles = curve.modifiers.new(type='CYCLES') cycles.mode_before = 'REPEAT_OFFSET' cycles.mode_after = 'REPEAT_OFFSET' for keyframe in curve.keyframe_points: keyframe.interpolation = 'LINEAR' bpy.ops.object.mode_set(mode='OBJECT') def configLink(self, A, J, helicity, rig, move, part): bpy.ops.object.mode_set(mode='OBJECT') Q = (0.18648+0.146446)*A # Z = -Q*2 Z = 0.0 obj_joint = bpy.data.objects["joint.gold.000"].copy() obj_joint.location = (0.0, 0.0, -Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a2a1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.silver.001"].copy() obj_joint.location = (0.0, 0.0, +Q+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y1a2.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a2o1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a1b1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for n in range(1, J - 1): if n <= (J-2): # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yy obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, +Q*(1 - (n % 2))*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) if n <= (J-3): # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n+1)+"o"+str(n+1)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for ob in context.scene.objects: if "mesh" in ob.name: ob.select = True bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', object=True, obdata=True, material=True, texture=True, animation=True) bpy.context.scene.cursor_location = (0.0, 0.0, 0.0) bpy.ops.object.origin_set(type='ORIGIN_CURSOR') def constructLink(self, A, J, helicity, rig, move, part): # Move and rotate the tip bone in pose mode bpy.context.scene.objects.active = rig Y = 1.1838*A for n in rig.pose.bones: if n.name != "o" + str(J-2) + "b" + str(J-1): # we can get the object from the pose bone obj = n.id_data matrix_final = obj.matrix_world * n.matrix # Create armature and object lnk = bpy.data.armatures.new(n.name[:len(n.name)]+'.data.' + helicity) lnk_rig = bpy.data.objects.new(n.name[:len(n.name)]+'.link.' + helicity, lnk) lnk_rig.location = mathutils.Euler((0.0, 0.0, 0.0), 'XYZ') # rig.show_x_ray = True lnk.show_names = True lnk.draw_type = 'STICK' # Link object to scene scn = bpy.context.scene scn.objects.link(lnk_rig) scn.objects.active = lnk_rig scn.update() # Create bones # mode='EDIT' bpy.ops.object.editmode_toggle() link = lnk.edit_bones.new(n.name[:len(n.name)]) link.head = (0, 0, 0) link.tail = (0, Y, 0) link_head = lnk.edit_bones.new('head') link_head.head = (0, 0, 0.1) link_head.tail = (0, 0, 0) link_head.parent = link link_head.use_inherit_scale = False link_tail = lnk.edit_bones.new('tail') link_tail.head = (0, Y, 0) link_tail.tail = (0, Y, -0.1) link_tail.parent = link link_tail.use_inherit_scale = False bpy.ops.object.mode_set(mode='OBJECT') ob = bpy.data.objects[n.name[:len(n.name)]+'.mesh.' + move + '.' + part +'.' + helicity] ob.location = mathutils.Euler((0, 0, 0), 'XYZ') # Give mesh object an armature modifier, using vertex groups but # not envelopes mod = ob.modifiers.new('MyRigModif', 'ARMATURE') mod.object = lnk_rig mod.use_bone_envelopes = False mod.use_vertex_groups = True # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # Copy rotation constraints Base -> Tip pBase = lnk_rig.pose.bones[n.name[:len(n.name)]] cns = pBase.constraints.new('COPY_LOCATION') cns.name = 'Copy_Location' cns.target = rig cns.subtarget = n.name[:len(n.name)] cns.owner_space = 'WORLD' cns.target_space = 'WORLD' # Copy rotation constraints Base -> Tip pBase = lnk_rig.pose.bones[n.name[:len(n.name)]] cns = pBase.constraints.new('COPY_ROTATION') cns.name = 'Copy_Rotation' cns.target = rig cns.subtarget = n.name[:len(n.name)] cns.owner_space = 'WORLD' cns.target_space = 'WORLD' # StretchTo constraint Mid -> Tip with influence 0.5 cns1 = pBase.constraints.new('STRETCH_TO') cns1.name = 'Stretch' cns1.target = rig cns1.subtarget = n.name[:len(n.name)] cns1.head_tail = 1 cns1.rest_length = Y cns1.influence = 1 cns1.keep_axis = 'PLANE_Z' cns1.volume = 'NO_VOLUME' bpy.ops.object.mode_set(mode='OBJECT') class Yaw(Formula): J = 7 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 133 frame_end = 148 def __init__(self, P, A, move, part, helicity, start, end, yaw_loc, yaw_rot, pitch_loc, pitch_rot, pitch, body): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end # yaw self.yaw_loc = yaw_loc self.yaw_rot = yaw_rot # pitch self.pitch_loc = pitch_loc self.pitch_rot = pitch_rot self.pitch = pitch self.body = body bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.a = [0 for i in range(4)] # Joint α self.b = [0 for i in range(self.J)] # Joint β self.y = [0 for i in range(self.J)] # Joint γ self.o = [0 for i in range(self.J)] # Joint δ self.upper_b = [0 for i in range(self.J)] # Joint β matrix self.upper_y = [0 for i in range(self.J)] # Joint γ matrix self.upper_o = [0 for i in range(self.J)] # Joint δ matrix self.upper_w = [0 for i in range(self.J)] # Joint ω matrix self.lower_b = [0 for i in range(self.J)] # Joint β matrix self.lower_y = [0 for i in range(self.J)] # Joint γ matrix self.lower_w = [0 for i in range(2)] # Joint ω matrix self.lower_left_b = [0 for i in range(self.J)] # Joint β matrix self.lower_left_y = [0 for i in range(self.J)] # Joint γ matrix self.lower_left_o = [0 for i in range(self.J)] # Joint δ matrix self.lower_left_w = [0 for i in range(2)] # Joint ω matrix self.lower_right_b = [0 for i in range(self.J)] # Joint β matrix self.lower_right_y = [0 for i in range(self.J)] # Joint γ matrix self.lower_right_o = [0 for i in range(self.J)] # Joint δ matrix self.lower_right_w = [0 for i in range(2)] # Joint ω matrix # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y, self.o, self.upper_b, self.upper_y, self.upper_o, self.upper_w, self.lower_b, self.lower_y, self.lower_w, self.lower_left_b, self.lower_left_y, self.lower_left_o, self.lower_left_w, self.lower_right_b, self.lower_right_y, self.lower_right_o, self.lower_right_w) # Construction Movement self.constructMovement(self.J, self.helicity, self.amt, self.rig, self.a, self.b, self.y, self.o, self.upper_b, self.upper_y, self.upper_o, self.upper_w, self.lower_b, self.lower_y, self.lower_w, self.lower_left_b, self.lower_left_y, self.lower_left_o, self.lower_left_w, self.lower_right_b, self.lower_right_y, self.lower_right_o, self.lower_right_w) # Parent set pitch to yaw self.setParent(self.helicity, self.move, self.rig, yaw_loc, yaw_rot, pitch_loc, pitch_rot, pitch, body) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) # Configuration Linkage self.configLink(self.A * 0.25, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A * 0.25, self.J, self.helicity, self.rig, self.move, self.part) def configMovement(self, P, A, J, a, b, y, o, upper_b, upper_y, upper_o, upper_w, lower_b, lower_y, lower_w, lower_left_b, lower_left_y, lower_left_o, lower_left_w, lower_right_b, lower_right_y, lower_right_o, lower_right_w): mat_a = [0 for i in range(4)] # Joint α matrix mat_b = [0 for i in range(self.J)] # Joint β matrix mat_y = [0 for i in range(self.J)] # Joint γ matrix mat_o = [0 for i in range(self.J)] # Joint δ matrix upper_mat_b = [0 for i in range(self.J)] # Joint β matrix upper_mat_y = [0 for i in range(self.J)] # Joint γ matrix upper_mat_o = [0 for i in range(self.J)] # Joint δ matrix upper_mat_w = [0 for i in range(self.J)] # Joint ω matrix lower_mat_b = [0 for i in range(self.J)] # Joint β matrix lower_mat_y = [0 for i in range(self.J)] # Joint γ matrix lower_mat_w = [0 for i in range(2)] # Joint ω matrix lower_left_mat_b = [0 for i in range(self.J)] # Joint β matrix lower_left_mat_y = [0 for i in range(self.J)] # Joint γ matrix lower_left_mat_o = [0 for i in range(self.J)] # Joint δ matrix lower_left_mat_w = [0 for i in range(2)] # Joint ω matrix lower_right_mat_b = [0 for i in range(self.J)] # Joint β matrix lower_right_mat_y = [0 for i in range(self.J)] # Joint γ matrix lower_right_mat_o = [0 for i in range(self.J)] # Joint δ matrix lower_right_mat_w = [0 for i in range(2)] # Joint ω matrix a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) mat_y[1] = Matrix.Translation(y[1]) o[1] = mathutils.Euler((A, A, 0), 'XYZ') print ("o1 =", o[1]) upper_b[2] = mathutils.Euler((5.40939, -2.87735, 0), 'XYZ') print ("upper_b2 =", upper_b[2]) upper_mat_b[2] = Matrix.Translation(upper_b[2]) upper_y[2] = mathutils.Euler((4.39357, -2.95756, 0), 'XYZ') print ("upper_y2 =", upper_y[2]) upper_mat_y[2] = Matrix.Translation(upper_y[2]) upper_o[2] = mathutils.Euler((3.61516, -2.09638, 0), 'XYZ') print ("o2 =", o[2]) upper_mat_o[2] = Matrix.Translation(upper_o[2]) upper_w[1] = mathutils.Euler((4.39357, -2.95756, 23.2308), 'XYZ') print ("upper_w1 =", upper_w[1]) upper_mat_w[1] = Matrix.Translation(upper_w[1]) upper_w[2] = mathutils.Euler((8.19003, -8.48921, 2.42495), 'XYZ') print ("upper_w2 =", upper_w[2]) upper_mat_w[2] = Matrix.Translation(upper_w[2]) upper_w[3] = mathutils.Euler((13.3388, -1.17576, 2.42495), 'XYZ') print ("upper_w3 =", upper_w[3]) upper_mat_w[3] = Matrix.Translation(upper_w[3]) upper_w[4] = mathutils.Euler((13.3388, -1.17576, 30.6122), 'XYZ') print ("upper_w4 =", upper_w[4]) upper_mat_w[4] = Matrix.Translation(upper_w[4]) upper_w[5] = mathutils.Euler((13.3388, -1.17576, 29.9866), 'XYZ') print ("upper_w5 =", upper_w[5]) upper_mat_w[5] = Matrix.Translation(upper_w[5]) upper_w[6] = mathutils.Euler((13.3388, 0, 29.9866), 'XYZ') print ("upper_w6 =", upper_w[6]) upper_mat_w[6] = Matrix.Translation(upper_w[6]) lower_w[1] = mathutils.Euler((8.19003, -8.48921, 0), 'XYZ') print ("lower_w1 =", lower_w[1]) lower_mat_w[1] = Matrix.Translation(lower_w[1]) lower_b[2] = mathutils.Euler((5.72759, -6.1022, 0), 'XYZ') print ("lower_b2 =", lower_b[2]) lower_mat_b[2] = Matrix.Translation(lower_b[2]) lower_y[2] = mathutils.Euler((7.29866, -4.39351, 0), 'XYZ') print ("lower_y2 =", lower_y[2]) lower_mat_y[2] = Matrix.Translation(lower_y[2]) lower_left_o[2] = mathutils.Euler((0.333433, 8.17479, 0), 'XYZ') print ("lower_left_o2 =", lower_left_o[2]) lower_left_mat_o[2] = Matrix.Translation(lower_left_o[2]) lower_left_b[3] = mathutils.Euler((7.33373, 7.72061, 0), 'XYZ') print ("lower_left_b3 =", lower_left_b[3]) lower_left_mat_b[3] = Matrix.Translation(lower_left_b[3]) lower_left_y[3] = mathutils.Euler((-1.15831, 3.11248, 0), 'XYZ') print ("lower_left_y3 =", lower_left_y[3]) lower_left_mat_y[3] = Matrix.Translation(lower_left_y[3]) lower_left_o[3] = mathutils.Euler((-1.15831, 4.12125, 0), 'XYZ') print ("lower_left_o3 =", lower_left_o[3]) lower_left_mat_o[3] = Matrix.Translation(lower_left_o[3]) lower_left_w[1] = mathutils.Euler((3.02315, 8.00786, 0), 'XYZ') print ("lower_left_w1 =", lower_left_w[1]) lower_left_mat_w[1] = Matrix.Translation(lower_left_w[1]) lower_right_o[2] = mathutils.Euler((6.72417, -15.9045, 0), 'XYZ') print ("lower_right_o2 =", lower_right_o[2]) lower_right_mat_o[2] = Matrix.Translation(lower_right_o[2]) lower_right_b[3] = mathutils.Euler((13.0432, -17.9857, 0), 'XYZ') print ("lower_right_b3 =", lower_right_b[3]) lower_right_mat_b[3] = Matrix.Translation(lower_right_b[3]) lower_right_y[3] = mathutils.Euler((6.09549, -14.1632, 0), 'XYZ') print ("lower_right_y3 =", lower_right_y[3]) lower_right_mat_y[3] = Matrix.Translation(lower_right_y[3]) lower_right_o[3] = mathutils.Euler((5.79574, -15.2852, 0), 'XYZ') print ("lower_right_o3 =", lower_right_o[3]) lower_right_mat_o[3] = Matrix.Translation(lower_right_o[3]) lower_right_w[1] = mathutils.Euler((8.93583, -16.6329, 0), 'XYZ') print ("lower_right_w1 =", lower_right_w[1]) lower_right_mat_w[1] = Matrix.Translation(lower_right_w[1]) def constructMovement(self, J, helicity, amt, rig, a, b, y, o, upper_b, upper_y, upper_o, upper_w, lower_b, lower_y, lower_w, lower_left_b, lower_left_y, lower_left_o, lower_left_w, lower_right_b, lower_right_y, lower_right_o, lower_right_w): # Linkages aa = [[0 for i in range(4)] for j in range(4)] # Link α(i) - α(j) ab = [[0 for i in range(4)] for j in range(4)] # Link α(i) - β(j) ya = [[0 for i in range(4)] for j in range(4)] # Link γ(i) - α(j) ao = [[0 for i in range(4)] for j in range(4)] # Link α(i) - δ(j) ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) upper_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) upper_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) upper_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_yw = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - ω(j) upper_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link ω(i) - ω(j) lower_aw = [[0 for i in range(2)] for j in range(3)] # Link α(i) - ω(j) lower_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) lower_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_left_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_left_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) lower_left_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_left_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) lower_left_wb = [[0 for i in range(self.J)] for j in range(2)] # Link β(i) - ω(j) lower_right_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_right_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) lower_right_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_right_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) lower_right_wb = [[0 for i in range(self.J)] for j in range(2)] # Link β(i) - ω(j) rig.location = mathutils.Euler((0.0, 0.0, 0.0), 'XYZ') rig.show_x_ray = True amt.show_names = True # amt.draw_type = 'STICK' amt.draw_type = 'BBONE' # Link object to scene scn = bpy.context.scene scn.objects.link(rig) scn.objects.active = rig scn.update() # Edit bpy.ops.object.editmode_toggle() j = 1 # Construction Linkage aa[j+1][j] = amt.edit_bones.new('a' + str(j+1) + 'a' + str(j)) aa[j+1][j].head = a[j+1] aa[j+1][j].tail = a[j] ab[j][j] = amt.edit_bones.new('a' + str(j) + 'b' + str(j)) ab[j][j].head = a[j] ab[j][j].tail = b[j] ab[j][j].parent = aa[j+1][j] by[j][j] = amt.edit_bones.new('b' + str(j) + 'y' + str(j)) by[j][j].head = b[j] by[j][j].tail = y[j] by[j][j].parent = ab[j][j] by[j][j].use_inherit_rotation = False ya[j][j+1] = amt.edit_bones.new('y' + str(j) + 'a' + str(j+1)) ya[j][j+1].head = y[j] ya[j][j+1].tail = a[j+1] ya[j][j+1].parent = by[j][j] ao[j+1][j] = amt.edit_bones.new('a' + str(j+1) + 'o' + str(j)) ao[j+1][j].head = a[j+1] ao[j+1][j].tail = o[j] ao[j+1][j].parent = ya[j][j+1] upper_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b' + str(j+1) +'.upper') upper_ob[j][j+1].head = o[j] upper_ob[j][j+1].tail = upper_b[j+1] upper_ob[j][j+1].parent = ao[j+1][j] upper_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.upper') upper_yy[j][j+1].head = y[j] upper_yy[j][j+1].tail = upper_y[j+1] upper_yy[j][j+1].parent = by[j][j] lower_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b' + str(j+1) +'.lower') lower_ob[j][j+1].head = o[j] lower_ob[j][j+1].tail = lower_b[j+1] lower_ob[j][j+1].parent = ao[j+1][j] lower_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.lower') lower_yy[j][j+1].head = y[j] lower_yy[j][j+1].tail = lower_y[j+1] lower_yy[j][j+1].parent = by[j][j] lower_aw[j+1][j] = amt.edit_bones.new('a' + str(j+1) + 'w' + str(j) +'.lower') lower_aw[j+1][j].head = a[j+1] lower_aw[j+1][j].tail = lower_w[j] lower_aw[j+1][j].parent = aa[j+1][j] upper_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w' + str(j+1) +'.upper') upper_ww[j][j+1].head = lower_w[j] upper_ww[j][j+1].tail = upper_w[j+1] upper_ww[j][j+1].parent = lower_aw[j+1][j] j = 2 upper_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w' + str(j+1) +'.upper') upper_ww[j][j+1].head = upper_w[j] upper_ww[j][j+1].tail = upper_w[j+1] upper_ww[j][j+1].parent = upper_ww[j-1][j] upper_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) +'.upper') upper_by[j][j].head = upper_b[j] upper_by[j][j].tail = upper_y[j] upper_by[j][j].parent = upper_ob[j-1][j] upper_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) +'.upper') upper_yo[j][j].head = upper_y[j] upper_yo[j][j].tail = upper_o[j] upper_yo[j][j].parent = upper_yy[j-1][j] upper_yw[j][j-1] = amt.edit_bones.new('y'+ str(j) + 'w'+ str(j-1) +'.upper') upper_yw[j][j-1].head = upper_y[j] upper_yw[j][j-1].tail = upper_w[j-1] upper_yw[j][j-1].parent = upper_by[j][j] lower_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.lower') lower_by[j][j].head = lower_b[j] lower_by[j][j].tail = lower_y[j] lower_by[j][j].parent = lower_ob[j-1][j] lower_left_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.lower.left') lower_left_yy[j][j+1].head = lower_y[j] lower_left_yy[j][j+1].tail = lower_left_y[j+1] lower_left_yy[j][j+1].parent = lower_by[j][j] lower_left_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) +'.lower.left') lower_left_yo[j][j].head = lower_y[j] lower_left_yo[j][j].tail = lower_left_o[j] lower_left_yo[j][j].parent = lower_yy[j-1][j] lower_left_ob[j][j+1] = amt.edit_bones.new('o'+ str(j) + 'b'+ str(j+1) +'.lower.left') lower_left_ob[j][j+1].head = lower_left_o[j] lower_left_ob[j][j+1].tail = lower_left_b[j+1] lower_left_ob[j][j+1].parent = lower_left_yo[j][j] lower_right_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.lower.right') lower_right_yy[j][j+1].head = lower_y[j] lower_right_yy[j][j+1].tail = lower_right_y[j+1] lower_right_yy[j][j+1].parent = lower_by[j][j] lower_right_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) +'.lower.right') lower_right_yo[j][j].head = lower_y[j] lower_right_yo[j][j].tail = lower_right_o[j] lower_right_yo[j][j].parent = lower_yy[j-1][j] lower_right_ob[j][j+1] = amt.edit_bones.new('o'+ str(j) + 'b'+ str(j+1) +'.lower.right') lower_right_ob[j][j+1].head = lower_right_o[j] lower_right_ob[j][j+1].tail = lower_right_b[j+1] lower_right_ob[j][j+1].parent = lower_right_yo[j][j] j = 3 upper_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w' + str(j+1) +'.upper') upper_ww[j][j+1].head = upper_w[j] upper_ww[j][j+1].tail = upper_w[j+1] upper_ww[j][j+1].parent = upper_ww[j-1][j] lower_left_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.lower.left') lower_left_by[j][j].head = lower_left_b[j] lower_left_by[j][j].tail = lower_left_y[j] lower_left_by[j][j].parent = lower_left_ob[j-1][j] lower_left_wb[1][j] = amt.edit_bones.new('w'+ str(1) + 'b'+ str(j) +'.lower.left') lower_left_wb[1][j].head = lower_left_w[1] lower_left_wb[1][j].tail = lower_left_b[j] lower_left_wb[1][j].parent = lower_left_ob[j-1][j] lower_left_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) +'.lower.left') lower_left_yo[j][j].head = lower_left_y[j] lower_left_yo[j][j].tail = lower_left_o[j] lower_left_yo[j][j].parent = lower_left_yy[j-1][j] lower_right_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.lower.right') lower_right_by[j][j].head = lower_right_b[j] lower_right_by[j][j].tail = lower_right_y[j] lower_right_by[j][j].parent = lower_right_ob[j-1][j] lower_right_wb[1][j] = amt.edit_bones.new('w'+ str(1) + 'b'+ str(j) +'.lower.right') lower_right_wb[1][j].head = lower_right_w[1] lower_right_wb[1][j].tail = lower_right_b[j] lower_right_wb[1][j].parent = lower_right_ob[j-1][j] lower_right_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) +'.lower.right') lower_right_yo[j][j].head = lower_right_y[j] lower_right_yo[j][j].tail = lower_right_o[j] lower_right_yo[j][j].parent = lower_right_yy[j-1][j] for j in range(4, 6): upper_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w' + str(j+1) +'.upper') upper_ww[j][j+1].head = upper_w[j] upper_ww[j][j+1].tail = upper_w[j+1] upper_ww[j][j+1].parent = upper_ww[j-1][j] # all bones select #bpy.ops.pose.select_all(action="SELECT") for b in amt.edit_bones: b.select = True if helicity == 'right': bpy.ops.armature.calculate_roll(type='GLOBAL_POS_Z') else: bpy.ops.armature.calculate_roll(type='GLOBAL_NEG_Z') # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # IK constraint cns = rig.pose.bones['y1a2'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'a2a1' cns.chain_count = 2 cns.use_stretch = False j = 2 cns = rig.pose.bones['b'+str(j) +'y'+str(j) +'.upper'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j) +'.upper' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['b'+str(j) +'y'+str(j) +'.lower'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j) +'.lower.left' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False j = 3 cns = rig.pose.bones['b'+str(j) +'y'+str(j) +'.lower.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j) +'.lower.left' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['b'+str(j) +'y'+str(j) +'.lower.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j) +'.lower.right' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False bpy.ops.object.mode_set(mode='OBJECT') def configLink(self, A, J, helicity, rig, move, part): bpy.ops.object.mode_set(mode='OBJECT') Q = (0.18648+0.146446)*A # Z = -Q*2 Z = 0.0 obj_joint = bpy.data.objects["joint.gold.000"].copy() obj_joint.location = (0.0, 0.0, -Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a2a1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.silver.001"].copy() obj_joint.location = (0.0, 0.0, +Q*1+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y1a2.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a2o1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a1b1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 1 # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q*1 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, +Q*2 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yy obj_joint = bpy.data.objects["joint.gold.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.A"].copy() obj_joint.location = (0.0, 0.0, +Q*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yy obj_joint = bpy.data.objects["joint.gold.C"].copy() obj_joint.location = (0.0, 0.0, -Q*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.B"].copy() obj_joint.location = (0.0, 0.0, +Q*2 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "a"+str(n+1)+"w"+str(n)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.A3"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 2 obj_joint = bpy.data.objects["joint.gold.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.A"].copy() obj_joint.location = (0.0, 0.0, -Q*1 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*1 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.gold.D"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"w"+str(n-1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, +Q*7 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yy obj_joint = bpy.data.objects["joint.gold.B"].copy() obj_joint.location = (0.0, 0.0, +Q*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*5 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, +Q*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yy obj_joint = bpy.data.objects["joint.gold.B"].copy() obj_joint.location = (0.0, 0.0, +Q*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*5 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, +Q*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 3 obj_joint = bpy.data.objects["joint.gold.A2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, +Q*7 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.C"].copy() obj_joint.location = (0.0, 0.0, +Q*1 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(1)+"b"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*8 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of by obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, +Q*7 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 1 of ob obj_joint = bpy.data.objects["joint.blue.C"].copy() obj_joint.location = (0.0, 0.0, +Q*1 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(1)+"b"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # Pattern 2 of yo obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*8 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for n in range(4, 6): obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for ob in context.scene.objects: if "mesh" in ob.name: ob.select = True bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', object=True, obdata=True, material=True, texture=True, animation=True) bpy.context.scene.cursor_location = (0.0, 0.0, 0.0) bpy.ops.object.origin_set(type='ORIGIN_CURSOR') # Parent set fingers to arm def setParent(self, helicity, move, rig, yaw_loc, yaw_rot, pitch_loc, pitch_rot, pitch, body): # yaw position rig.location = yaw_loc rig.rotation_euler = yaw_rot # pitch position pitch.rig.location = pitch_loc pitch.rig.rotation_euler = pitch_rot # pitch to yaw bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.frame_current = 0 bpy.ops.object.select_all(action='DESELECT') rig.select = True bpy.context.scene.objects.active = rig bpy.ops.object.editmode_toggle() parent_bone = 'y2w1.upper' # choose the bone name which you want to be the parent rig.data.edit_bones.active = rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects pitch.rig.select = True rig.select = True bpy.context.scene.objects.active = rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) bpy.ops.object.select_all(action='DESELECT') #deselect all objects # end j = 1 cns = body.rig.pose.bones['w' +str(j) +'w' +str(j+2)+'.upper.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w5w6.upper' cns.chain_count = 1 cns.use_stretch = False cns = body.rig.pose.bones['w' +str(j) +'w' +str(j+2)+'.upper.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w5w6.upper' cns.chain_count = 1 cns.use_stretch = False j = 2 cns = body.rig.pose.bones['w' +str(j) +'w' +str(j+1)+'.upper'].constraints.new('COPY_LOCATION') cns.name = 'Copy Location' cns.target = rig cns.subtarget = 'w4w5.upper' cns = body.rig.pose.bones['w' +str(j) +'w' +str(j+1)+'.upper'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w5w6.upper' cns.chain_count = 1 cns.use_stretch = False cns = body.rig.pose.bones['w' +str(j) +'w' +str(j+1)+'.upper'].constraints.new('COPY_ROTATION') cns.name = 'Copy Rotation' cns.target = rig cns.subtarget = 'a2a1' cns.target_space = 'LOCAL' cns.owner_space = 'WORLD' j = 4 cns = body.rig.pose.bones['y'+str(j) +'y'+str(j+1)+'.lower.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w1b3.lower.left' cns.pole_target = rig cns.pole_subtarget = 'o2b3.lower.left' cns.pole_angle = 0 cns.iterations = 500 cns.chain_count = 3 cns.use_stretch = False cns = body.rig.pose.bones['y'+str(j) +'y'+str(j+1)+'.lower.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w1b3.lower.right' cns.pole_target = rig cns.pole_subtarget = 'o2b3.lower.right' cns.pole_angle = math.radians(180) cns.iterations = 500 cns.chain_count = 3 cns.use_stretch = False class Pitch(Formula): J = 2 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 133 frame_end = 148 # Overriding def __init__(self, P, A, move, part, helicity, start, end, body_loc, body_rot, body): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end # body self.body_loc = body_loc self.body_rot = body_rot self.body = body bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n] self.a = [0 for i in range(4)] # Joint α self.b = [0 for i in range(self.J)] # Joint β self.y = [0 for i in range(self.J)] # Joint γ # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y) # Construction Movement self.constructMovement(self.J, self.helicity, self.amt, self.rig, self.a, self.b, self.y) # Parent body to pitch self.setParent(self.helicity, self.move, self.rig, self.body_loc, self.body_rot, self.body) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) # Configuration Linkage self.configLink(self.A*0.3, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A*0.3, self.J, self.helicity, self.rig, self.move, self.part) def configMovement(self, P, A, J, a, b, y): mat_a = [0 for i in range(4)] # Joint α matrix mat_b = [0 for i in range(self.J)] # Joint β matrix mat_y = [0 for i in range(self.J)] # Joint γ matrix a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) mat_y[1] = Matrix.Translation(y[1]) def constructMovement(self, J, helicity, amt, rig, a, b, y): # Linkages aa = [[0 for i in range(4)] for j in range(4)] # Link α(i) - α(j) ab = [[0 for i in range(4)] for j in range(4)] # Link α(i) - β(j) ya = [[0 for i in range(4)] for j in range(4)] # Link γ(i) - α(j) by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) rig.location = mathutils.Euler((0.0, 0.0, 0.0), 'XYZ') rig.show_x_ray = True amt.show_names = True # amt.draw_type = 'STICK' amt.draw_type = 'BBONE' # Link object to scene scn = bpy.context.scene scn.objects.link(rig) scn.objects.active = rig scn.update() # Edit bpy.ops.object.editmode_toggle() # Construction Linkage aa[2][1] = amt.edit_bones.new('a2a1') aa[2][1].head = a[2] aa[2][1].tail = a[1] ab[1][1] = amt.edit_bones.new('a1b1') ab[1][1].head = a[1] ab[1][1].tail = b[1] ab[1][1].parent = aa[2][1] by[1][1] = amt.edit_bones.new('b1y1') by[1][1].head = b[1] by[1][1].tail = y[1] by[1][1].parent = ab[1][1] by[1][1].use_inherit_rotation = False ya[1][2] = amt.edit_bones.new('y1a2') ya[1][2].head = y[1] ya[1][2].tail = a[2] ya[1][2].parent = by[1][1] # all bones select #bpy.ops.pose.select_all(action="SELECT") for b in amt.edit_bones: b.select = True if helicity == 'right': bpy.ops.armature.calculate_roll(type='GLOBAL_POS_Z') else: bpy.ops.armature.calculate_roll(type='GLOBAL_NEG_Z') # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # IK constraint cns = rig.pose.bones['y1a2'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'a2a1' cns.chain_count = 2 cns.use_stretch = False bpy.ops.object.mode_set(mode='OBJECT') def configLink(self, A, J, helicity, rig, move, part): bpy.ops.object.mode_set(mode='OBJECT') Q = (0.18648+0.146446)*A # Z = -Q*2 Z = 0.0 obj_joint = bpy.data.objects["joint.gold.000"].copy() obj_joint.location = (0.0, 0.0, -Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a2a1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.silver.A"].copy() obj_joint.location = (0.0, 0.0, +Q+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y1a2.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "a1b1.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 1 obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for ob in context.scene.objects: if "mesh" in ob.name: ob.select = True bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', object=True, obdata=True, material=True, texture=True, animation=True) bpy.context.scene.cursor_location = (0.0, 0.0, 0.0) bpy.ops.object.origin_set(type='ORIGIN_CURSOR') # Parent set fingers to arm def setParent(self, helicity, move, rig, body_loc, body_rot, body): # body position body.rig.location = body_loc body.rig.rotation_euler = body_rot # body to pitch bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.frame_current = 0 bpy.ops.object.select_all(action='DESELECT') rig.select = True bpy.context.scene.objects.active = rig bpy.ops.object.editmode_toggle() parent_bone = 'b1y1' # choose the bone name which you want to be the parent rig.data.edit_bones.active = rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects body.rig.select = True rig.select = True bpy.context.scene.objects.active = rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) bpy.ops.object.select_all(action='DESELECT') #deselect all objects # end class Body(Formula): J = 7 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 133 frame_end = 148 # Overriding def __init__(self, P, A, move, part, helicity, start, end, arm_left_loc, arm_left_rot, arm_left, arm_right_loc, arm_right_rot, arm_right): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) self.arm_left_loc = arm_left_loc self.arm_left_rot = arm_left_rot self.arm_left = arm_left self.arm_right_loc = arm_right_loc self.arm_right_rot = arm_right_rot self.arm_right = arm_right # Centroid # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.a = [0 for i in range(3)] # Joint α self.b = [0 for i in range(2)] # Joint β self.y = [0 for i in range(2)] # Joint γ self.o = [0 for i in range(2)] # Joint δ # Upper body # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.upper_b = [0 for i in range(self.J)] # Joint β self.upper_y = [0 for i in range(self.J)] # Joint γ self.upper_o = [0 for i in range(self.J)] # Joint δ # Joints ω(n) -> w[n] self.upper_w = [0 for i in range(self.J)] # Joint ω # Left shoulder # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.upper_left_b = [0 for i in range(self.J)] # Joint β self.upper_left_y = [0 for i in range(self.J)] # Joint γ self.upper_left_o = [0 for i in range(self.J)] # Joint δ self.upper_left_w = [0 for i in range(self.J)] # Joint ω matrix # Right shoulder # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.upper_right_b = [0 for i in range(self.J)] # Joint β self.upper_right_y = [0 for i in range(self.J)] # Joint γ self.upper_right_o = [0 for i in range(self.J)] # Joint δ self.upper_right_w = [0 for i in range(self.J)] # Joint ω matrix # Lower body # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.lower_b = [0 for i in range(self.J)] # Joint β self.lower_y = [0 for i in range(self.J)] # Joint γ self.lower_o = [0 for i in range(self.J)] # Joint δ # Joints ω(n) -> w[n] self.lower_w = [0 for i in range(self.J)] # Joint ω # Left leg # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.lower_left_b = [0 for i in range(self.J)] # Joint β self.lower_left_y = [0 for i in range(self.J)] # Joint γ self.lower_left_o = [0 for i in range(self.J)] # Joint δ # Right leg # Joints α(n) -> a[n], β(n) -> b[n], γ(n) -> y[n], δ(n) -> o[n] self.lower_right_b = [0 for i in range(self.J)] # Joint β self.lower_right_y = [0 for i in range(self.J)] # Joint γ self.lower_right_o = [0 for i in range(self.J)] # Joint δ # gimbal self.gimbal_lower_left_o = [0 for i in range(self.J)] # Joint δ self.gimbal_lower_left_b = [0 for i in range(self.J)] # Joint β self.gimbal_lower_right_o = [0 for i in range(self.J)] # Joint δ self.gimbal_lower_right_b = [0 for i in range(self.J)] # Joint β # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y, self.o, self.upper_b, self.upper_y, self.upper_o, self.upper_w, self.upper_left_b, self.upper_left_y, self.upper_left_o, self.upper_left_w, self.upper_right_b, self.upper_right_y, self.upper_right_o, self.upper_right_w, self.lower_b, self.lower_y, self.lower_o, self.lower_w, self.lower_left_b, self.lower_left_y, self.lower_left_o, self.lower_right_b, self.lower_right_y, self.lower_right_o, self.gimbal_lower_left_o, self.gimbal_lower_left_b, self.gimbal_lower_right_o, self.gimbal_lower_right_b) # Construction Movement self.constructMovement(self.J, self.amt, self.rig, self.a, self.b, self.y, self.o, self.upper_b, self.upper_y, self.upper_o, self.upper_w, self.upper_left_b, self.upper_left_y, self.upper_left_o, self.upper_left_w, self.upper_right_b, self.upper_right_y, self.upper_right_o, self.upper_right_w, self.lower_b, self.lower_y, self.lower_o, self.lower_w, self.lower_left_b, self.lower_left_y, self.lower_left_o, self.lower_right_b, self.lower_right_y, self.lower_right_o, self.gimbal_lower_left_o, self.gimbal_lower_left_b, self.gimbal_lower_right_o, self.gimbal_lower_right_b) # Parent set arms to body self.setParent(self.helicity, self.move, self.rig, self.arm_left_loc, self.arm_left_rot, self.arm_left, self.arm_right_loc, self.arm_right_rot, self.arm_right) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) self.configLink(self.A*0.7, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A*0.7, self.J, self.helicity, self.rig, self.move, self.part) # Overriding Configuration Movement def configMovement(self, P, A, J, a, b, y, o, upper_b, upper_y, upper_o, upper_w, upper_left_b, upper_left_y, upper_left_o, upper_left_w, upper_right_b, upper_right_y, upper_right_o, upper_right_w, lower_b, lower_y, lower_o, lower_w, lower_left_b, lower_left_y, lower_left_o, lower_right_b, lower_right_y, lower_right_o, gimbal_lower_left_o, gimbal_lower_left_b, gimbal_lower_right_o, gimbal_lower_right_b): a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) o[1] = mathutils.Euler((A, A, 0), 'XYZ') print ("o1 =", o[1]) y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) lower_b[2] = mathutils.Euler((1.35031, -1.93408, 0), 'XYZ') print ("b2.lower =", lower_b[2]) lower_o[2] = mathutils.Euler((-1.18173, -3.18999, 0), 'XYZ') print ("o2.lower =", lower_o[2]) lower_y[2] = mathutils.Euler((-0.761987, -3.11885, 0), 'XYZ') print ("y2.lower =", lower_y[2]) lower_y[3] = mathutils.Euler((-0.425565, -8.51839, 0), 'XYZ') print ("y3.lower =", lower_y[3]) lower_w[1] = mathutils.Euler((-0.425565, -8.51839, 2.50277), 'XYZ') print ("w1.lower =", lower_w[1]) lower_left_o[3] = mathutils.Euler((1.76787, -8.43042, 1.81914), 'XYZ') print ("o3.lower.left =", lower_left_o[3]) lower_left_b[4] = mathutils.Euler((1.76787, -19.2299, 5.0545), 'XYZ') print ("b4.lower.left =", lower_left_b[4]) lower_left_y[4] = mathutils.Euler((1.76787, -27.4568, 2.13126), 'XYZ') print ("y4.lower.left =", lower_left_y[4]) lower_left_y[5] = mathutils.Euler((1.76787, -29.0398, 4.39707), 'XYZ') print ("y5.lower.left =", lower_left_y[5]) gimbal_lower_left_o[3] = mathutils.Euler((1.87361, -8.51839, 2.50277), 'XYZ') print ("o3.gimbal.lower.left =", gimbal_lower_left_o[3]) gimbal_lower_left_b[4] = mathutils.Euler((1.87361, -19.7847, 2.50277), 'XYZ') print ("b4.gimbal.lower.left =", gimbal_lower_left_b[4]) lower_right_o[3] = mathutils.Euler((-2.89871, -8.60219, 1.75624), 'XYZ') print ("o3.lower.right =", lower_right_o[3]) lower_right_b[4] = mathutils.Euler((-2.89871, -19.3735, 5.04104), 'XYZ') print ("b4.lower.right =", lower_right_b[4]) lower_right_y[4] = mathutils.Euler((-2.89871, -27.5528, 1.98242), 'XYZ') print ("y4.lower.right =", lower_right_y[4]) lower_right_y[5] = mathutils.Euler((-2.89871, -29.1751, 4.22026), 'XYZ') print ("y5.lower.right =", lower_right_y[5]) gimbal_lower_right_o[3] = mathutils.Euler((-3.01028, -8.51839, 2.50277), 'XYZ') print ("o3.gimbal.lower.right =", gimbal_lower_right_o[3]) gimbal_lower_right_b[4] = mathutils.Euler((-3.01028, -19.7726, 2.50277), 'XYZ') print ("b4.gimbal.lower.right =", gimbal_lower_right_b[4]) upper_b[2] = mathutils.Euler((0.510293, 5.22315, 0), 'XYZ') print ("b2.upper =", upper_b[2]) upper_o[2] = mathutils.Euler((-1.65578, 4.62023, 0), 'XYZ') print ("o2.upper =", upper_o[2]) upper_y[2] = mathutils.Euler((-1.56747, 4.00093, 0), 'XYZ') print ("y2.upper =", upper_y[2]) upper_w[3] = mathutils.Euler((-1.56747, 4.00093, 9.05079), 'XYZ') print ("w3.upper =", upper_w[3]) upper_w[4] = mathutils.Euler((-1.65459, 3.99465, 9.05079), 'XYZ') print ("w4.upper =", upper_w[4]) upper_w[5] = mathutils.Euler((-1.65459, 3.99465, 1.61675), 'XYZ') print ("w5.upper =", upper_w[5]) upper_y[3] = mathutils.Euler((-1.65459, 4.6204, 0), 'XYZ') print ("y3.upper.left =", upper_y[3]) upper_w[2] = mathutils.Euler((-1.65459, 4.6204, 9.05079), 'XYZ') print ("w2.upper =", upper_w[2]) upper_o[3] = mathutils.Euler((-2.07892, 9.71201, 0), 'XYZ') print ("o3.upper =", upper_o[3]) upper_w[1] = mathutils.Euler((-2.07852, 9.71278, 0.712845), 'XYZ') print ("w1.upper =", upper_w[1]) upper_b[4] = mathutils.Euler((-2.07852, 10.4327, 0.669667), 'XYZ') print ("o3.upper =", upper_o[3]) upper_left_y[3] = mathutils.Euler((-1.65578, 4.62023, 0), 'XYZ') print ("y3.upper.left =", upper_left_y[3]) upper_left_b[3] = mathutils.Euler((2.04941, 4.82274, 0), 'XYZ') print ("b3.upper.left =", upper_left_b[3]) upper_left_y[2] = mathutils.Euler((-1.56747, 3.99717, 0), 'XYZ') print ("y2.upper.left =", upper_left_y[2]) upper_left_o[2] = mathutils.Euler((2.28887, 4.24878, 0), 'XYZ') print ("o2.upper.left =", upper_left_o[2]) upper_left_w[1] = mathutils.Euler((2.52833, 3.67482, 0), 'XYZ') print ("w1.upper.left =", upper_left_w[1]) upper_left_w[2] = mathutils.Euler((1.49581, 3.75702, 2.28162), 'XYZ') print ("w2.upper.left =", upper_left_w[2]) upper_left_w[3] = mathutils.Euler((0.480431, 3.83787, 4.52539), 'XYZ') print ("w3.upper.left =", upper_left_w[3]) upper_left_w[4] = mathutils.Euler((-0.54352, 3.9194, 6.78809), 'XYZ') print ("w4.upper.left =", upper_left_w[4]) upper_left_w[5] = mathutils.Euler((2.28863, 3.62687, 0), 'XYZ') print ("w5.upper.left =", upper_left_w[5]) upper_left_w[6] = mathutils.Euler((2.28863, 3.62687, 4.96987), 'XYZ') print ("w6.upper.left =", upper_left_w[6]) upper_right_y[3] = mathutils.Euler((-1.65578, 4.62023, 0), 'XYZ') print ("y3.upper.right =", upper_right_y[3]) upper_right_b[3] = mathutils.Euler((-5.45688, 3.83647, 0), 'XYZ') print ("b3.upper.right =", upper_right_b[3]) upper_right_y[2] = mathutils.Euler((-1.56747, 3.99717, 0), 'XYZ') print ("y2.upper.right =", upper_right_y[2]) upper_right_o[2] = mathutils.Euler((-5.37016, 3.21603, 0), 'XYZ') print ("o2.upper.right =", upper_right_o[2]) upper_right_w[1] = mathutils.Euler((-5.28344, 2.59559, 0), 'XYZ') print ("w1.upper.right =", upper_right_w[1]) upper_right_w[2] = mathutils.Euler((-4.36226, 2.94397, 2.24368), 'XYZ') print ("w2.upper.right =", upper_right_w[2]) upper_right_w[3] = mathutils.Euler((-3.42546, 3.29826, 4.52539), 'XYZ') print ("w3.upper.right =", upper_right_w[3]) upper_right_w[4] = mathutils.Euler((-2.49646, 3.64959, 6.78809), 'XYZ') print ("w4.upper.right =", upper_right_w[4]) upper_right_w[5] = mathutils.Euler((-5.37016, 2.58956, 0), 'XYZ') print ("w5.upper.right =", upper_right_w[5]) upper_right_w[6] = mathutils.Euler((-5.37016, 2.58956, 4.94216), 'XYZ') print ("w6.upper.right =", upper_right_w[6]) def constructMovement(self, J, amt, rig, a, b, y, o, upper_b, upper_y, upper_o, upper_w, upper_left_b, upper_left_y, upper_left_o, upper_left_w, upper_right_b, upper_right_y, upper_right_o, upper_right_w, lower_b, lower_y, lower_o, lower_w, lower_left_b, lower_left_y, lower_left_o, lower_right_b, lower_right_y, lower_right_o, gimbal_lower_left_o, gimbal_lower_left_b, gimbal_lower_right_o, gimbal_lower_right_b): # Linkages aa = [[0 for i in range(3)] for j in range(3)] # Link α(i) - α(j) ab = [[0 for i in range(3)] for j in range(3)] # Link α(i) - β(j) ya = [[0 for i in range(3)] for j in range(3)] # Link γ(i) - α(j) ao = [[0 for i in range(3)] for j in range(3)] # Link α(i) - δ(j) by = [[0 for i in range(2)] for j in range(2)] # Link β(i) - γ(j) upper_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) upper_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) upper_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) upper_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_ow = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_left_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) upper_left_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) upper_left_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) upper_left_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_left_ow = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) upper_left_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link ω(i) - ω(j) upper_right_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) upper_right_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) upper_right_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) upper_right_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) upper_right_ow = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) upper_right_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link ω(i) - ω(j) lower_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) lower_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) lower_yw = [[0 for i in range(2)] for j in range(self.J)] # Link γ(i) - ω(j) lower_left_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_left_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) lower_left_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_left_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) lower_right_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) lower_right_yy = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - δ(j) lower_right_by = [[0 for i in range(self.J)] for j in range(self.J)] # Link β(i) - γ(j) lower_right_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link γ(i) - γ(j) gimbal_lower_left_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) gimbal_lower_left_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) gimbal_lower_right_yo = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) gimbal_lower_right_ob = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - β(j) gimbal_upper_left_ow = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) gimbal_upper_left_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) gimbal_upper_right_ow = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) gimbal_upper_right_ww = [[0 for i in range(self.J)] for j in range(self.J)] # Link δ(i) - ω(j) rig.location = mathutils.Euler((0.0, 0.0, 0.0), 'XYZ') rig.show_x_ray = True amt.show_names = True # amt.draw_type = 'STICK' amt.draw_type = 'BBONE' # Link object to scene scn = bpy.context.scene scn.objects.link(rig) scn.objects.active = rig scn.update() # Edit bpy.ops.object.editmode_toggle() j = 1 # Construction Linkage aa[j+1][j] = amt.edit_bones.new('a'+ str(j+1)+'a'+ str(j)) aa[j+1][j].head = a[j+1] aa[j+1][j].tail = a[j] # aa[j+1][j].parent = by[j][j]_body ab[j][j] = amt.edit_bones.new('a'+ str(j)+'b'+ str(j)) ab[j][j].head = a[j] ab[j][j].tail = b[j] ab[j][j].parent = aa[j+1][j] by[j][j] = amt.edit_bones.new('b'+ str(j)+'y'+ str(j)) by[j][j].head = b[j] by[j][j].tail = y[j] by[j][j].parent = ab[j][j] by[j][j].use_inherit_rotation = False ya[j][j+1] = amt.edit_bones.new('y'+ str(j)+'a'+ str(j+1)) ya[j][j+1].head = y[j] ya[j][j+1].tail = a[j+1] ya[j][j+1].parent = by[j][j] ao[j+1][j] = amt.edit_bones.new('a'+ str(j+1)+'o'+str(j)) ao[j+1][j].head = a[j+1] ao[j+1][j].tail = o[j] ao[j+1][j].parent = ya[j][j+1] lower_ob[j][j+1] = amt.edit_bones.new('o'+ str(j)+'b'+ str(j+1)+'.lower') lower_ob[j][j+1].head = o[j] lower_ob[j][j+1].tail = lower_b[j+1] lower_ob[j][j+1].parent = ao[j+1][j] lower_yy[j][j+1] = amt.edit_bones.new('y'+ str(j)+'y'+ str(j+1)+'.lower') lower_yy[j][j+1].head = y[j] lower_yy[j][j+1].tail = lower_y[j+1] lower_yy[j][j+1].parent = by[j][j] upper_ob[j][j+1] = amt.edit_bones.new('o'+ str(j)+'b'+ str(j+1)+'.upper') upper_ob[j][j+1].head = o[j] upper_ob[j][j+1].tail = upper_b[j+1] upper_ob[j][j+1].parent = ao[j+1][j] upper_yy[j][j+1] = amt.edit_bones.new('y'+ str(j)+'y'+ str(j+1)+'.upper') upper_yy[j][j+1].head = y[j] upper_yy[j][j+1].tail = upper_y[j+1] upper_yy[j][j+1].parent = by[j][j] j = 2 lower_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.lower') lower_by[j][j].head = lower_b[j] lower_by[j][j].tail = lower_y[j] lower_by[j][j].parent = lower_ob[j-1][j] lower_yy[j][j+1] = amt.edit_bones.new('y'+ str(j) + 'y'+ str(j+1) + '.lower') lower_yy[j][j+1].head = lower_y[j] lower_yy[j][j+1].tail = lower_y[j+1] lower_yy[j][j+1].parent = lower_by[j][j] lower_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.lower') lower_yo[j][j].head = lower_y[j] lower_yo[j][j].tail = lower_o[j] lower_yo[j][j].parent = lower_yy[j-1][j] upper_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.upper') upper_by[j][j].head = upper_b[j] upper_by[j][j].tail = upper_y[j] upper_by[j][j].parent = upper_ob[j-1][j] upper_yy[j][j+1] = amt.edit_bones.new('y'+ str(j) + 'y'+ str(j+1) + '.upper') upper_yy[j][j+1].head = upper_y[j] upper_yy[j][j+1].tail = upper_y[j+1] upper_yy[j][j+1].parent = upper_by[j][j] # upper w2w3 upper_ww[j][j+1] = amt.edit_bones.new('w'+ str(j) + 'w'+ str(j+1) + '.upper') upper_ww[j][j+1].head = upper_w[j] upper_ww[j][j+1].tail = upper_w[j+1] # upper_ww[j][j+1].parent = upper_yy[j][j+1] # left shoulder gimbal upper_left_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.upper.left') upper_left_yo[j][j].head = upper_y[j] upper_left_yo[j][j].tail = upper_left_o[j] upper_left_yo[j][j].parent = upper_yy[j-1][j] upper_left_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) + '.upper.left') upper_left_ob[j][j+1].head = upper_left_o[j] upper_left_ob[j][j+1].tail = upper_left_b[j+1] upper_left_ob[j][j+1].parent = upper_left_yo[j][j] # gimbal o2w5 gimbal_upper_left_ow[j][j+3] = amt.edit_bones.new('o' + str(j) + 'w'+ str(j+3) + '.gimbal.upper.left') gimbal_upper_left_ow[j][j+3].head = upper_left_o[j] gimbal_upper_left_ow[j][j+3].tail = upper_left_w[j+3] gimbal_upper_left_ow[j][j+3].parent = upper_left_ob[j][j+1] upper_left_ow[j][j-1] = amt.edit_bones.new('o' + str(j) + 'w'+ str(j-1) + '.upper.left') upper_left_ow[j][j-1].head = upper_left_o[j] upper_left_ow[j][j-1].tail = upper_left_w[j-1] upper_left_ow[j][j-1].parent = upper_left_ob[j][j+1] # w1w3 upper_left_ww[j-1][j+1] = amt.edit_bones.new('w' + str(j-1) + 'w'+ str(j+1) + '.upper.left') upper_left_ww[j-1][j+1].head = upper_left_w[j-1] upper_left_ww[j-1][j+1].tail = upper_left_w[j+1] upper_left_ww[j-1][j+1].parent = upper_left_ow[j][j-1] # left w3w2 upper_left_ww[j+1][j] = amt.edit_bones.new('w' + str(j+1) + 'w'+ str(j) + '.upper.left') upper_left_ww[j+1][j].head = upper_w[j+1] upper_left_ww[j+1][j].tail = upper_left_w[j] upper_left_ww[j+1][j].parent = upper_ww[j][j+1] # left w2w1 upper_left_ww[j][j-1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j-1) + '.upper.left') upper_left_ww[j][j-1].head = upper_left_w[j] upper_left_ww[j][j-1].tail = upper_left_w[j-1] upper_left_ww[j][j-1].parent = upper_left_ww[j+1][j] # left gimbal w2w4 gimbal_upper_left_ww[j][j+2] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+2) +'.gimbal.upper.left') gimbal_upper_left_ww[j][j+2].head = upper_w[j] gimbal_upper_left_ww[j][j+2].tail = upper_w[j+2] gimbal_upper_left_ww[j][j+2].parent = upper_ww[j][j+1] # right shoulder gimbal upper_right_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.upper.right') upper_right_yo[j][j].head = upper_y[j] upper_right_yo[j][j].tail = upper_right_o[j] upper_right_yo[j][j].parent = upper_yy[j-1][j] upper_right_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) + '.upper.right') upper_right_ob[j][j+1].head = upper_right_o[j] upper_right_ob[j][j+1].tail = upper_right_b[j+1] upper_right_ob[j][j+1].parent = upper_right_yo[j][j] # gimbal o2w5 gimbal_upper_right_ow[j][j+3] = amt.edit_bones.new('o' + str(j) + 'w'+ str(j+3) + '.gimbal.upper.right') gimbal_upper_right_ow[j][j+3].head = upper_right_o[j] gimbal_upper_right_ow[j][j+3].tail = upper_right_w[j+3] gimbal_upper_right_ow[j][j+3].parent = upper_right_ob[j][j+1] upper_right_ow[j][j-1] = amt.edit_bones.new('o' + str(j) + 'w'+ str(j-1) + '.upper.right') upper_right_ow[j][j-1].head = upper_right_o[j] upper_right_ow[j][j-1].tail = upper_right_w[j-1] upper_right_ow[j][j-1].parent = upper_right_ob[j][j+1] # w1w3 upper_right_ww[j-1][j+1] = amt.edit_bones.new('w' + str(j-1) + 'w'+ str(j+1) + '.upper.right') upper_right_ww[j-1][j+1].head = upper_right_w[j-1] upper_right_ww[j-1][j+1].tail = upper_right_w[j+1] upper_right_ww[j-1][j+1].parent = upper_right_ow[j][j-1] # right w3w2 upper_right_ww[j+1][j] = amt.edit_bones.new('w' + str(j+1) + 'w'+ str(j) + '.upper.right') upper_right_ww[j+1][j].head = upper_w[j+1] upper_right_ww[j+1][j].tail = upper_right_w[j] upper_right_ww[j+1][j].parent = upper_ww[j][j+1] # right w2w1 upper_right_ww[j][j-1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j-1) + '.upper.right') upper_right_ww[j][j-1].head = upper_right_w[j] upper_right_ww[j][j-1].tail = upper_right_w[j-1] upper_right_ww[j][j-1].parent = upper_right_ww[j+1][j] # right gimbal w2w4 gimbal_upper_right_ww[j][j+2] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+2) +'.gimbal.upper.right') gimbal_upper_right_ww[j][j+2].head = upper_w[j] gimbal_upper_right_ww[j][j+2].tail = upper_w[j+2] gimbal_upper_right_ww[j][j+2].parent = upper_ww[j][j+1] j = 3 lower_yw[j][1] = amt.edit_bones.new('y'+ str(j) + 'w'+ str(1) + '.lower') lower_yw[j][1].head = lower_y[j] lower_yw[j][1].tail = lower_w[1] lower_yw[j][1].parent = lower_yy[2][j] lower_left_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.lower.left') lower_left_yo[j][j].head = lower_w[1] lower_left_yo[j][j].tail = lower_left_o[j] lower_left_yo[j][j].parent = lower_yw[j][1] lower_left_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) + '.lower.left') lower_left_ob[j][j+1].head = lower_left_o[j] lower_left_ob[j][j+1].tail = lower_left_b[j+1] lower_left_ob[j][j+1].parent = lower_left_yo[j][j] lower_right_yo[j][j] = amt.edit_bones.new('y' + str(j) + 'o'+ str(j) +'.lower.right') lower_right_yo[j][j].head = lower_w[1] lower_right_yo[j][j].tail = lower_right_o[j] lower_right_yo[j][j].parent = lower_yw[j][1] lower_right_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) +'.lower.right') lower_right_ob[j][j+1].head = lower_right_o[j] lower_right_ob[j][j+1].tail = lower_right_b[j+1] lower_right_ob[j][j+1].parent = lower_right_yo[j][j] # gimbal gimbal_lower_left_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.gimbal.lower.left') gimbal_lower_left_yo[j][j].head = lower_w[1] gimbal_lower_left_yo[j][j].tail = gimbal_lower_left_o[j] gimbal_lower_left_yo[j][j].parent = lower_yw[j][1] gimbal_lower_left_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) + '.gimbal.lower.left') gimbal_lower_left_ob[j][j+1].head = gimbal_lower_left_o[j] gimbal_lower_left_ob[j][j+1].tail = gimbal_lower_left_b[j+1] gimbal_lower_left_ob[j][j+1].parent = gimbal_lower_left_yo[j][j] gimbal_lower_right_yo[j][j] = amt.edit_bones.new('y' + str(j) + 'o'+ str(j) +'.gimbal.lower.right') gimbal_lower_right_yo[j][j].head = lower_w[1] gimbal_lower_right_yo[j][j].tail = gimbal_lower_right_o[j] gimbal_lower_right_yo[j][j].parent = lower_yw[j][1] gimbal_lower_right_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) +'.gimbal.lower.right') gimbal_lower_right_ob[j][j+1].head = gimbal_lower_right_o[j] gimbal_lower_right_ob[j][j+1].tail = gimbal_lower_right_b[j+1] gimbal_lower_right_ob[j][j+1].parent = gimbal_lower_right_yo[j][j] # end upper_left_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.upper.left') upper_left_by[j][j].head = upper_left_b[j] upper_left_by[j][j].tail = upper_left_y[j] upper_left_by[j][j].parent = upper_left_ob[j-1][j] upper_right_by[j][j] = amt.edit_bones.new('b'+ str(j) + 'y'+ str(j) + '.upper.right') upper_right_by[j][j].head = upper_right_b[j] upper_right_by[j][j].tail = upper_right_y[j] upper_right_by[j][j].parent = upper_right_ob[j-1][j] upper_yo[j][j] = amt.edit_bones.new('y'+ str(j) + 'o'+ str(j) + '.upper') upper_yo[j][j].head = upper_y[j] upper_yo[j][j].tail = upper_o[j] upper_yo[j][j].parent = upper_yy[j-1][j] upper_ob[j][j+1] = amt.edit_bones.new('o' + str(j) + 'b'+ str(j+1) + '.upper') upper_ob[j][j+1].head = upper_w[1] upper_ob[j][j+1].tail = upper_b[j+1] upper_ob[j][j+1].parent = upper_yo[j][j] upper_left_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) + '.upper.left') upper_left_ww[j][j+1].head = upper_left_w[j] upper_left_ww[j][j+1].tail = upper_left_w[j+1] upper_left_ww[j][j+1].parent = upper_left_ww[j-2][j] upper_right_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) + '.upper.right') upper_right_ww[j][j+1].head = upper_right_w[j] upper_right_ww[j][j+1].tail = upper_right_w[j+1] upper_right_ww[j][j+1].parent = upper_right_ww[j-2][j] j = 4 lower_left_by[j][j] = amt.edit_bones.new('b' + str(j) + 'y' + str(j) +'.lower.left') lower_left_by[j][j].head = lower_left_b[j] lower_left_by[j][j].tail = lower_left_y[j] lower_left_by[j][j].parent = lower_left_ob[j-1][j] lower_left_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.lower.left') lower_left_yy[j][j+1].head = lower_left_y[j] lower_left_yy[j][j+1].tail = lower_left_y[j+1] lower_left_yy[j][j+1].parent = lower_left_by[j][j] # gimbal w4w5 gimbal_upper_left_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) +'.gimbal.upper.left') gimbal_upper_left_ww[j][j+1].head = upper_w[j] gimbal_upper_left_ww[j][j+1].tail = upper_w[j+1] gimbal_upper_left_ww[j][j+1].parent = gimbal_upper_left_ww[j-2][j] lower_right_by[j][j] = amt.edit_bones.new('b' + str(j) + 'y' + str(j) +'.lower.right') lower_right_by[j][j].head = lower_right_b[j] lower_right_by[j][j].tail = lower_right_y[j] lower_right_by[j][j].parent = lower_right_ob[j-1][j] lower_right_yy[j][j+1] = amt.edit_bones.new('y' + str(j) + 'y' + str(j+1) +'.lower.right') lower_right_yy[j][j+1].head = lower_right_y[j] lower_right_yy[j][j+1].tail = lower_right_y[j+1] lower_right_yy[j][j+1].parent = lower_right_by[j][j] # gimbal w4w5 gimbal_upper_right_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) +'.gimbal.upper.right') gimbal_upper_right_ww[j][j+1].head = upper_w[j] gimbal_upper_right_ww[j][j+1].tail = upper_w[j+1] gimbal_upper_right_ww[j][j+1].parent = gimbal_upper_right_ww[j-2][j] j = 5 # gimbal w5w6 gimbal_upper_left_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) + '.gimbal.upper.left') gimbal_upper_left_ww[j][j+1].head = upper_left_w[j] gimbal_upper_left_ww[j][j+1].tail = upper_left_w[j+1] gimbal_upper_left_ww[j][j+1].parent = gimbal_upper_left_ow[j-3][j] gimbal_upper_right_ww[j][j+1] = amt.edit_bones.new('w' + str(j) + 'w'+ str(j+1) + '.gimbal.upper.right') gimbal_upper_right_ww[j][j+1].head = upper_right_w[j] gimbal_upper_right_ww[j][j+1].tail = upper_right_w[j+1] gimbal_upper_right_ww[j][j+1].parent = gimbal_upper_right_ow[j-3][j] # all bones select #bpy.ops.pose.select_all(action="SELECT") for b in amt.edit_bones: b.select = True bpy.ops.armature.calculate_roll(type='GLOBAL_NEG_Z') for b in amt.edit_bones: b.select = False amt.edit_bones["o3b4.lower.left"].select = True amt.edit_bones["b4y4.lower.left"].select = True amt.edit_bones["y4y5.lower.left"].select = True bpy.ops.armature.calculate_roll(type='GLOBAL_NEG_X') for b in amt.edit_bones: b.select = False amt.edit_bones["o3b4.lower.right"].select = True amt.edit_bones["b4y4.lower.right"].select = True amt.edit_bones["y4y5.lower.right"].select = True bpy.ops.armature.calculate_roll(type='GLOBAL_POS_X') # Bone constraints. Armature must be in pose mode. bpy.ops.object.mode_set(mode='POSE') # IK constraint j = 1 cns = rig.pose.bones['y' +str(j) +'a' +str(j+1)].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'a'+str(j+1)+'a'+str(j) cns.chain_count = 2 cns.use_stretch = False j = 2 cns = rig.pose.bones['b'+str(j) +'y'+str(j)+'.lower'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j)+'.lower' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['b'+str(j) +'y'+str(j)+'.upper'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j)+'.upper.left' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['w' +str(j+1) +'w' +str(j)+'.upper.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w' +str(j-1) +'w' +str(j+1)+'.upper.left' cns.chain_count = 1 cns.use_stretch = False cns = rig.pose.bones['w' +str(j+1) +'w' +str(j)+'.upper.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w' +str(j-1) +'w' +str(j+1)+'.upper.right' cns.chain_count = 1 cns.use_stretch = False j = 3 cns = rig.pose.bones['b'+str(j) +'y'+str(j)+'.upper.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j)+'.upper' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['b'+str(j) +'y'+str(j)+'.upper.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'y'+str(j)+'o'+str(j)+'.upper' cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['o'+str(j) +'b'+str(j+1)+'.gimbal.lower.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'b'+str(j+1)+'y'+str(j+1)+'.lower.left' cns.pole_target = rig cns.pole_subtarget = 'o'+str(j)+'b'+str(j+1)+'.lower.left' cns.pole_angle = 0 cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['o'+str(j) +'b'+str(j+1)+'.gimbal.lower.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'b'+str(j+1)+'y'+str(j+1)+'.lower.right' cns.pole_target = rig cns.pole_subtarget = 'o'+str(j)+'b'+str(j+1)+'.lower.right' cns.pole_angle = math.radians(180) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False j = 4 cns = rig.pose.bones['w'+str(j) +'w'+str(j+1)+'.gimbal.upper.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w'+str(j-2)+'w'+str(j-3)+'.upper.left' cns.pole_target = rig cns.pole_subtarget = 'w'+str(j-1)+'w'+str(j-2)+'.upper.left' cns.pole_angle = math.radians(-90) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['w'+str(j) +'w'+str(j+1)+'.gimbal.upper.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w'+str(j-2)+'w'+str(j-3)+'.upper.right' cns.pole_target = rig cns.pole_subtarget = 'w'+str(j-1)+'w'+str(j-2)+'.upper.right' cns.pole_angle = math.radians(-90) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False j = 5 cns = rig.pose.bones['w'+str(j) +'w'+str(j+1)+'.gimbal.upper.left'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w'+str(j-2)+'w'+str(j-1)+'.upper.left' cns.pole_target = rig cns.pole_subtarget = 'w'+str(j-4)+'w'+str(j-2)+'.upper.left' cns.pole_angle = math.radians(90) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False cns = rig.pose.bones['w'+str(j) +'w'+str(j+1)+'.gimbal.upper.right'].constraints.new('IK') cns.name = 'Ik' cns.target = rig cns.subtarget = 'w'+str(j-2)+'w'+str(j-1)+'.upper.right' cns.pole_target = rig cns.pole_subtarget = 'w'+str(j-4)+'w'+str(j-2)+'.upper.right' cns.pole_angle = math.radians(90) cns.iterations = 500 cns.chain_count = 2 cns.use_stretch = False bpy.ops.object.mode_set(mode='OBJECT') def configLink(self, A, J, helicity, rig, move, part): bpy.ops.object.mode_set(mode='OBJECT') Q = (0.18648+0.146446)*A # Z = -Q*2 Z = 0.0 n = 1 obj_joint = bpy.data.objects["joint.gold.E"].copy() obj_joint.location = (0.0, 0.0, -Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = 'a'+ str(n+1)+'a'+ str(n)+ ".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = 'a'+ str(n)+'b'+ str(n)+ ".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.silver.001"].copy() obj_joint.location = (0.0, 0.0, +Q+Z) obj_joint.scale = (A, A, A) obj_joint.name = 'y'+ str(n)+'a'+ str(n+1)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, +Q*3+Z) obj_joint.scale = (A, A, A) obj_joint.name = 'a'+ str(n+1)+'o'+ str(n)+".mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, +Q*(1 - (n % 2))*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, +Q*(1 - (n % 2))*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 2 obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, +Q*(1 - (n % 2))*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*(n % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, +Q*(1 - (n % 2))*2+Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*(n % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*(n % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.B.R"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"w"+str(n-1)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n-1)+"w"+str(n+1)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+1)+"w"+str(n+2)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w5.gimbal obj_joint = bpy.data.objects["joint.gold.g1.y.C.R2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"w"+str(n+3)+".gimbal.upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w5w6.gimbal obj_joint = bpy.data.objects["joint.silver.g1.z.C.R2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+3)+"w"+str(n+4)+".gimbal.upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.B.L"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"w"+str(n-1)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n-1)+"w"+str(n+1)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+1)+"w"+str(n+2)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w5.gimbal obj_joint = bpy.data.objects["joint.gold.g1.y.C.L2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"w"+str(n+3)+".gimbal.upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w5w6.gimbal obj_joint = bpy.data.objects["joint.silver.g1.z.C.L2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+3)+"w"+str(n+4)+".gimbal.upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w3.upper obj_joint = bpy.data.objects["joint.gold.B2"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w4.gimbal.upper.left obj_joint = bpy.data.objects["joint.gold.g1.y.C.L"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+2)+".gimbal.upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w4w5.gimbal.upper.left obj_joint = bpy.data.objects["joint.silver.g1.z.C.L"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+2)+"w"+str(n+3)+".gimbal.upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w3w2.upper.left obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+1)+"w"+str(n)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w1.upper.left obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n-1)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w4.gimbal.upper.right obj_joint = bpy.data.objects["joint.gold.g1.y.C.R"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n+2)+".gimbal.upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w4w5.gimbal.upper.right obj_joint = bpy.data.objects["joint.silver.g1.z.C.R"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+2)+"w"+str(n+3)+".gimbal.upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w3w2.upper.right obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n+1)+"w"+str(n)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) # w2w1.upper.right obj_joint = bpy.data.objects["joint.cursor"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "w"+str(n)+"w"+str(n-1)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 3 obj_joint = bpy.data.objects["joint.gold.A"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"w"+str(1)+".lower.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.A"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.B"].copy() # obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*6 +Z) obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.A"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.B"].copy() # obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*6 +Z) obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.g1.y.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".gimbal.lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.g1.z.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".gimbal.lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.g1.y.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".gimbal.lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.g1.z.B"].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".gimbal.lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".upper.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*((n+1) % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".upper.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.copper.001"].copy() obj_joint.location = (0.0, 0.0, -Q + Q*(n % 2)*4 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"o"+str(n)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.blue.001"].copy() obj_joint.location = (0.0, 0.0, -Q*2 + Q*(n % 2)*6 +Z) obj_joint.scale = (A, A, A) obj_joint.name = "o"+str(n)+"b"+str(n+1)+".upper.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) n = 4 obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, Q +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.left.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.green.001"].copy() obj_joint.location = (0.0, 0.0, Q +Z) obj_joint.scale = (A, A, A) obj_joint.name = "b"+str(n)+"y"+str(n)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) obj_joint = bpy.data.objects["joint.gold.00"+str(1 + (n+1) % 2)].copy() obj_joint.location = (0.0, 0.0, 0.0) obj_joint.scale = (A, A, A) obj_joint.name = "y"+str(n)+"y"+str(n+1)+".lower.right.mesh." + move + '.' + part +'.' + helicity bpy.context.scene.objects.link(obj_joint) for ob in context.scene.objects: if "mesh" in ob.name: ob.select = True bpy.ops.object.make_single_user(type='SELECTED_OBJECTS', object=True, obdata=True, material=True, texture=True, animation=True) bpy.context.scene.cursor_location = (0.0, 0.0, 0.0) bpy.ops.object.origin_set(type='ORIGIN_CURSOR') # Parent set arms to body def setParent(self, helicity, move, rig, arm_left_loc, arm_left_rot, arm_left, arm_right_loc, arm_right_rot, arm_right): bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.frame_current = 0 # arm left bpy.ops.object.select_all(action='DESELECT') rig.select = True bpy.context.scene.objects.active = rig bpy.ops.object.editmode_toggle() # parent_bone = 'o2b3.upper.left' # choose the bone name which you want to be the parent parent_bone = 'o2w5.gimbal.upper.left' # choose the bone name which you want to be the parent rig.data.edit_bones.active = rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects arm_left.rig.select = True rig.select = True bpy.context.scene.objects.active = rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) # arm left end # arm right bpy.ops.object.select_all(action='DESELECT') #deselect all objects rig.select = True bpy.context.scene.objects.active = rig bpy.ops.object.editmode_toggle() # parent_bone = 'o2b3.upper.right' # choose the bone name which you want to be the parent parent_bone = 'o2w5.gimbal.upper.right' # choose the bone name which you want to be the parent rig.data.edit_bones.active = rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects arm_right.rig.select = True rig.select = True bpy.context.scene.objects.active = rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) # arm right end bpy.ops.object.select_all(action='DESELECT') #deselect all objects # arms position arm_left.rig.location = arm_left_loc arm_left.rig.rotation_euler = arm_left_rot arm_right.rig.location = arm_right_loc arm_right.rig.rotation_euler = arm_right_rot class Arm(Formula): J = 5 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 133 frame_end = 148 # Overriding def __init__(self, P, A, move, part, helicity, start, end, fingers_loc, fingers_rot, middle_finger): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end # fingers position self.fingers_loc = fingers_loc self.fingers_rot = fingers_rot # middle_finger self.middle_finger = middle_finger bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) # Joints self.a = [0 for i in range(4)] # Joint α self.b = [0 for i in range(self.J)] # Joint β self.y = [0 for i in range(self.J)] # Joint γ self.o = [0 for i in range(self.J)] # Joint δ # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y, self.o) # Construction Movement self.constructMovement(self.J, self.helicity, self.amt, self.rig, self.a, self.b, self.y, self.o) # Parent set fingers to arm self.setParent(self.helicity, self.move, self.rig, self.fingers_loc, self.fingers_rot, self.middle_finger) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) # Configuration Linkage self.configLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) # Overriding Configuration Movement def configMovement(self, P, A, J, a, b, y, o): a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) o[1] = mathutils.Euler((A, A, 0), 'XYZ') print ("o1 =", o[1]) B = A * 2 * sqrt (2) C = B + (B * sqrt (2)) D = C * sqrt (2) E = C + D y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) b[2] = mathutils.Euler((5.36277, -3.83599, 0), 'XYZ') print ("b2 =", b[2]) b[3] = mathutils.Euler((8.70172, -3.80032, 0), 'XYZ') print ("b3 =", b[3]) y[2] = mathutils.Euler((4.45922, -4.71667, 0), 'XYZ') print ("y2 =", y[2]) y[3] = mathutils.Euler((9.98465, -3.94095, 0), 'XYZ') print ("y3 =", y[3]) o[2] = mathutils.Euler((3.97637, -4.57217, 0), 'XYZ') print ("o2 =", o[2]) o[3] = mathutils.Euler((10.0529, -4.3022, 0), 'XYZ') print ("o3 =", o[3]) y[4] = mathutils.Euler((10.8499, -3.82056, 0), 'XYZ') print ("y4 =", y[4]) # Parent set fingers to arm def setParent(self, helicity, move, rig, fingers_loc, fingers_rot, middle_finger): bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.frame_current = 0 bpy.ops.object.select_all(action='DESELECT') rig.select = True bpy.context.scene.objects.active = rig bpy.ops.object.editmode_toggle() parent_bone = 'y3y4' # choose the bone name which you want to be the parent rig.data.edit_bones.active = rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects middle_finger.rig.select = True # bpy.data.objects[move+'.middle.'+ helicity].select = True rig.select = True bpy.context.scene.objects.active = rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) bpy.ops.object.select_all(action='DESELECT') #deselect all objects # fingers position middle_finger.rig.location.x += fingers_loc[0] middle_finger.rig.location.y += fingers_loc[1] middle_finger.rig.location.z += fingers_loc[2] middle_finger.rig.rotation_euler = fingers_rot class Finger(Formula): J = 6 #joint number #frame_start = bpy.context.scene.frame_start #frame_end = bpy.context.scene.frame_end #bpy.context.scene.frame_current = frame_end interval = 120 frame_start = 0 frame_end = 120 # Overriding def __init__(self, P, A, move, part, helicity, start, end, y2, y3, y4, y5): # pivot factor self.P = P # scale factor self.A = A # name self.move = move # element self.part = part # element helicity self.helicity = helicity self.start = start self.end = end # phalanx length self.y2 = y2 self.y3 = y3 self.y4 = y4 self.y5 = y5 bpy.ops.object.mode_set(mode='OBJECT') # Create armature and object self.amt = bpy.data.armatures.new(move + '.' + part + '.' + helicity + '.data') self.rig = bpy.data.objects.new(move + '.' + part + '.' + helicity, self.amt) # Joints self.a = [0 for i in range(4)] # Joint α self.b = [0 for i in range(self.J)] # Joint β self.y = [0 for i in range(self.J)] # Joint γ self.o = [0 for i in range(self.J)] # Joint δ # Configuration Movement self.configMovement(self.P, self.A, self.J, self.a, self.b, self.y, self.o, self.y2, self.y3, self.y4, self.y5) # Construction Movement self.constructMovement(self.J, self.helicity, self.amt, self.rig, self.a, self.b, self.y, self.o) # Construction Rotation self.configRotation(self.rig, self.interval, self.frame_start, self.frame_end, self.start, self.end) # Configuration Linkage self.configLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) # Construction Linkage self.constructLink(self.A, self.J, self.helicity, self.rig, self.move, self.part) # Overriding Configuration Movement def configMovement(self, P, A, J, a, b, y, o, y2, y3, y4, y5): a[1] = mathutils.Euler((P, A, 0), 'XYZ') print ("a1 =", a[1]) a[2] = mathutils.Euler((A, -A, 0), 'XYZ') print ("a2 =", a[2]) b[1] = mathutils.Euler((-A, A, 0), 'XYZ') print ("b1 =", b[1]) o[1] = mathutils.Euler((A, A, 0), 'XYZ') print ("o1 =", o[1]) B = A * 2 * sqrt (2) C = B + (B * sqrt (2)) D = C * sqrt (2) E = C + D y[1] = mathutils.Euler((-A, -A, 0), 'XYZ') print ("y1 =", y[1]) y[2] = y2 print ("y2 =", y[2]) y[3] = y3 print ("y3 =", y[3]) y[4] = y4 print ("y4 =", y[4]) y[5] = y5 print ("y5 =", y[5]) b[2] = mathutils.Euler((y[2].x+0.10012, y[2].y+0.170067, 0), 'XYZ') print ("b2 =", b[2]) b[3] = mathutils.Euler((y[3].x-0.12471, y[3].y-0.03395, 0), 'XYZ') print ("b3 =", b[3]) b[4] = mathutils.Euler((y[4].x-0.11426, y[4].y-0.03342, 0), 'XYZ') print ("b4 =", b[4]) o[2] = mathutils.Euler((y[2].x+0.09016, y[2].y+0.142795, 0), 'XYZ') print ("o2 =", o[2]) o[3] = mathutils.Euler((y[3].x+0.07367, y[3].y+0.09711, 0), 'XYZ') print ("o3 =", o[3]) o[4] = mathutils.Euler((y[4].x+0.00899, y[4].y+0.03297, 0), 'XYZ') print ("o4 =", o[4]) def formula(): # pivot factor P = 0 # scale factor A = 1 # name move = 'formula' # element part = 'universe' # left or right helicity = 'left' start = 0 end = start+360 formula = Formula(P, A, move, part, helicity, start, end) def hands(): # name move = 'kungfu' # scale factor A = 0.107 # pivot factor P = -0.048266 # finger element part = 'middle' # phalanx length y2 = mathutils.Euler((1.427, -1.08668, 0), 'XYZ') y3 = mathutils.Euler((2.15534, -1.56395, 0), 'XYZ') y4 = mathutils.Euler((2.67012, -1.90121, 0), 'XYZ') y5 = mathutils.Euler((2.90459, -2.05473, 0), 'XYZ') # config nonlocal global middle_left global middle_right # left finger element helicity = 'left' start = 720-124 end = start middle_left = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) middle_left.rig.location = (0, 0, 0) middle_left.rig.rotation_euler = mathutils.Euler((math.radians(0), math.radians(0), math.radians(0)), 'XYZ') # right finger element helicity = 'right' start = 124 end = start middle_right = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) middle_right.rig.location = (0, 0, 0) middle_right.rig.rotation_euler = mathutils.Euler((math.radians(180-0), math.radians(0), math.radians(0)), 'XYZ') # finger element part = 'ring' y2 = mathutils.Euler((1.36978, -1.04933, 0), 'XYZ') y3 = mathutils.Euler((2.16696, -1.57161, 0), 'XYZ') y4 = mathutils.Euler((2.63809, -1.8803, 0), 'XYZ') y5 = mathutils.Euler((2.87256, -2.03382, 0), 'XYZ') # left finger element helicity = 'left' start = 720-124 end = start ring_left = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) ring_left.rig.location = (-0.010689, 0.001192, 0.241051) ring_left.rig.rotation_euler = mathutils.Euler((math.radians(-5.10153), math.radians(-1.70737), math.radians(0.02464)), 'XYZ') # right finger element helicity = 'right' start = 124 end = start ring_right = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) ring_right.rig.location = (-0.010689, -0.001192, 0.241051) ring_right.rig.rotation_euler = mathutils.Euler((math.radians(180+5.10153), math.radians(-1.70737), math.radians(-0.02464)), 'XYZ') # finger element part = 'little' y2 = mathutils.Euler((1.45986, -1.08525, 0), 'XYZ') y3 = mathutils.Euler((2.10861, -1.50077, 0), 'XYZ') y4 = mathutils.Euler((2.5324, -1.77219, 0), 'XYZ') y5 = mathutils.Euler((2.72302, -1.89418, 0), 'XYZ') # left finger element helicity = 'left' start = 720-124 end = start little_left = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) little_left.rig.location = (-0.020568, 0.002289, 0.463882) little_left.rig.rotation_euler = mathutils.Euler((math.radians(-10.1646), math.radians(-2.09755), math.radians(-0.518101)), 'XYZ') # right finger element helicity = 'right' start = 124 end = start little_right = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) little_right.rig.location = (-0.020568, -0.002289, 0.463882) little_right.rig.rotation_euler = mathutils.Euler((math.radians(180+10.1646), math.radians(-2.09755), math.radians(0.518101)), 'XYZ') # finger element part = 'index' y2 = mathutils.Euler((1.36561, -1.0465, 0), 'XYZ') y3 = mathutils.Euler((2.0559, -1.49887, 0), 'XYZ') y4 = mathutils.Euler((2.52701, -1.80756, 0), 'XYZ') y5 = mathutils.Euler((2.76149, -1.96108, 0), 'XYZ') # left finger element helicity = 'left' start = 720-124 end = start index_left = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) index_left.rig.location = (0.012703, -0.00141, -0.286505) index_left.rig.rotation_euler = mathutils.Euler((math.radians(2.53073), math.radians(2.85122), math.radians(0.320067)), 'XYZ') # right finger element helicity = 'right' start = 124 end = start index_right = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) index_right.rig.location = (0.012703, 0.00141, -0.286505) index_right.rig.rotation_euler = mathutils.Euler((math.radians(180-2.53073), math.radians(2.85122), math.radians(-0.320067)), 'XYZ') # finger element P = -0.075869 #pivot factor start = 124 end = start part = 'thumb' y2 = mathutils.Euler((0.265988, -0.219792, 0), 'XYZ') y3 = mathutils.Euler((1.0999, -0.768173, 0), 'XYZ') y4 = mathutils.Euler((1.71494, -1.17263, 0), 'XYZ') y5 = mathutils.Euler((1.97601, -1.3443, 0), 'XYZ') # left finger element helicity = 'left' start = 720-124 end = start thumb_left = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) thumb_left.rig.location = (0.009956, -0.090396, -0.3247) thumb_left.rig.rotation_euler = mathutils.Euler((math.radians(87.8968), math.radians(-3.16487), math.radians(-23.1096)), 'XYZ') # right finger element helicity = 'right' start = 124 end = start thumb_right = Finger(P, A, move, part, helicity, start, end, y2, y3, y4, y5) thumb_right.rig.location = (0.009956, 0.090396, -0.3247) thumb_right.rig.rotation_euler = mathutils.Euler((math.radians(180-87.8968), math.radians(-3.16487), math.radians(23.1096)), 'XYZ') # Parent set four fingers to middle finger bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.frame_current = 0 # left hand bpy.ops.object.select_all(action='DESELECT') middle_left.rig.select = True bpy.context.scene.objects.active = middle_left.rig bpy.ops.object.editmode_toggle() parent_bone = 'a2a1' # choose the bone name which you want to be the parent middle_left.rig.data.edit_bones.active = middle_left.rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects ring_left.rig.select = True little_left.rig.select = True index_left.rig.select = True thumb_left.rig.select = True middle_left.rig.select = True bpy.context.scene.objects.active = middle_left.rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) # right hand bpy.ops.object.select_all(action='DESELECT') #deselect all objects middle_right.rig.select = True bpy.context.scene.objects.active = middle_right.rig bpy.ops.object.editmode_toggle() parent_bone = 'a2a1' # choose the bone name which you want to be the parent middle_right.rig.data.edit_bones.active = middle_right.rig.data.edit_bones[parent_bone] bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') #deselect all objects ring_right.rig.select = True little_right.rig.select = True index_right.rig.select = True thumb_right.rig.select = True middle_right.rig.select = True bpy.context.scene.objects.active = middle_right.rig #the active object will be the parent of all selected object bpy.ops.object.parent_set(type='BONE', keep_transform=True) bpy.ops.object.select_all(action='DESELECT') #deselect all objects def arms(): # scale factor A = 0.473 # pivot factor P = (A * 0.5) # name move = 'kungfu' # arm element part = 'arm' # left arm element helicity = 'left' start = -1138-67+180 end = start+360 fingers_loc = (9.93914, -3.98605, 0.102497) fingers_rot = mathutils.Euler((math.radians(71.0974), math.radians(-37.0012), math.radians(24.6771)), 'XYZ') global middle_left middle_finger = middle_left global arm_left arm_left = Arm(P, A, move, part, helicity, start, end, fingers_loc, fingers_rot, middle_finger) # right arm element helicity = 'right' start = 720-(-1138-67) end = start-360 fingers_loc = (9.93914, -3.98605, 0.102497) fingers_rot = mathutils.Euler((math.radians(-47.5806), math.radians(41.2298), math.radians(26.8721)), 'XYZ') global middle_right middle_finger = middle_right global arm_right arm_right = Arm(P, A, move, part, helicity, start, end, fingers_loc, fingers_rot, middle_finger) def body(): # scale factor A = 1 # pivot factor P = -(A * 0.724843) # name move = 'kungfu' # arm element part = 'body' # helicity of element helicity = 'right' start = 720 - 425 end = start + 360 # start = 295 # end = 632.6244 global arm_left global arm_right arm_left_loc = (2.74172, 4.13548, -0.088542) arm_left_rot = mathutils.Euler((math.radians(-120.006), math.radians(-53.0662), math.radians(148.417)), 'XYZ') arm_right_loc = (-5.56559, 3.16373, -0.440029) arm_right_rot = mathutils.Euler((math.radians(110.568), math.radians(-134.792), math.radians(-131.795)), 'XYZ') global body body = Body(P, A, move, part, helicity, start, end, arm_left_loc, arm_left_rot, arm_left, arm_right_loc, arm_right_rot, arm_right) def pitch(): # scale factor A = 2 # pivot factor P = -1.65 # name move = 'kungfu' # arm element part = 'pitch' # helicity of element helicity = 'left' start = -3170.27 end = -2450.27 global body body_loc = (-2.02365, 1.5293, -2.88764) body_rot = mathutils.Euler((math.radians(11.0558), math.radians(95.1801), math.radians(60.6234)), 'XYZ') global pitch pitch = Pitch(P, A, move, part, helicity, start, end, body_loc, body_rot, body) def yaw(): # scale factor A = 5 # pivot factor P = -4.6 # name move = 'kungfu' # arm element part = 'yaw' # helicity of element helicity = 'left' start = 2084+95 end = 1724+95 global pitch pitch_loc = (-0.588748, -2.53526, 25.8234) pitch_rot = mathutils.Euler((math.radians(90.0), math.radians(45.0), math.radians(-125.0)), 'XYZ') global body yaw_loc = (5.13868, -0.546263, 1.65167) yaw_rot = mathutils.Euler((math.radians(0.0), math.radians(0.0), math.radians(0.0-104.719)), 'XYZ') yaw = Yaw(P, A, move, part, helicity, start, end, yaw_loc, yaw_rot, pitch_loc, pitch_rot, pitch, body) def main(origin): # formula() hands() arms() body() #roll pitch() yaw() if __name__ == "__main__": # renaming of corrada objects # for ob in context.scene.objects: # if "joint_" in ob.name: # ob.name = ob.name.replace("_", ".") main((0,0,0))