@@ -31,7 +31,7 @@ def create_leg( cls, bones ):
31
31
)
32
32
33
33
bones ['ik' ]['ctrl' ]['terminal' ] = []
34
-
34
+
35
35
bpy .ops .object .mode_set (mode = 'EDIT' )
36
36
eb = cls .obj .data .edit_bones
37
37
@@ -49,7 +49,7 @@ def create_leg( cls, bones ):
49
49
ctrl = get_bone_name ( org_bones [2 ], 'ctrl' , 'ik' )
50
50
ctrl = copy_bone ( cls .obj , org_bones [2 ], ctrl )
51
51
52
- # clear parent (so that rigify will parent to root)
52
+ # clear parent (so that rigify will parent to root)
53
53
eb [ ctrl ].parent = None
54
54
eb [ ctrl ].use_connect = False
55
55
@@ -64,7 +64,7 @@ def create_leg( cls, bones ):
64
64
orient_bone ( cls , eb [ ctrl ], 'y' , reverse = True )
65
65
eb [ ctrl ].length = l
66
66
67
- # Parent
67
+ # Parent
68
68
eb [ heel ].use_connect = False
69
69
eb [ heel ].parent = eb [ ctrl ]
70
70
@@ -91,38 +91,38 @@ def create_leg( cls, bones ):
91
91
92
92
# Create 2nd roll mch, and two rock mch bones
93
93
roll2_mch = get_bone_name ( tmp_heel , 'mch' , 'roll' )
94
- roll2_mch = copy_bone ( cls .obj , org_bones [3 ], roll2_mch )
94
+ roll2_mch = copy_bone ( cls .obj , org_bones [3 ], roll2_mch )
95
95
96
96
eb [ roll2_mch ].use_connect = False
97
97
eb [ roll2_mch ].parent = None
98
-
99
- put_bone (
100
- cls .obj ,
101
- roll2_mch ,
98
+
99
+ put_bone (
100
+ cls .obj ,
101
+ roll2_mch ,
102
102
( eb [ tmp_heel ].head + eb [ tmp_heel ].tail ) / 2
103
103
)
104
104
105
105
eb [ roll2_mch ].length /= 4
106
-
106
+
107
107
# Rock MCH bones
108
108
rock1_mch = get_bone_name ( tmp_heel , 'mch' , 'rock' )
109
- rock1_mch = copy_bone ( cls .obj , tmp_heel , rock1_mch )
109
+ rock1_mch = copy_bone ( cls .obj , tmp_heel , rock1_mch )
110
110
111
111
eb [ rock1_mch ].use_connect = False
112
- eb [ rock1_mch ].parent = None
113
-
112
+ eb [ rock1_mch ].parent = None
113
+
114
114
orient_bone ( cls , eb [ rock1_mch ], 'y' , 1.0 , reverse = True )
115
115
eb [ rock1_mch ].length = eb [ tmp_heel ].length / 2
116
-
116
+
117
117
rock2_mch = get_bone_name ( tmp_heel , 'mch' , 'rock' )
118
118
rock2_mch = copy_bone ( cls .obj , tmp_heel , rock2_mch )
119
119
120
120
eb [ rock2_mch ].use_connect = False
121
- eb [ rock2_mch ].parent = None
121
+ eb [ rock2_mch ].parent = None
122
122
123
123
orient_bone ( cls , eb [ rock2_mch ], 'y' , 1.0 )
124
124
eb [ rock2_mch ].length = eb [ tmp_heel ].length / 2
125
-
125
+
126
126
# Parent rock and roll MCH bones
127
127
eb [ roll1_mch ].parent = eb [ roll2_mch ]
128
128
eb [ roll2_mch ].parent = eb [ rock1_mch ]
@@ -135,7 +135,7 @@ def create_leg( cls, bones ):
135
135
'subtarget' : heel ,
136
136
'owner_space' : 'LOCAL' ,
137
137
'target_space' : 'LOCAL'
138
- })
138
+ })
139
139
make_constraint ( cls , roll1_mch , {
140
140
'constraint' : 'LIMIT_ROTATION' ,
141
141
'use_limit_x' : True ,
@@ -150,15 +150,15 @@ def create_leg( cls, bones ):
150
150
'invert_x' : True ,
151
151
'owner_space' : 'LOCAL' ,
152
152
'target_space' : 'LOCAL'
153
- })
153
+ })
154
154
make_constraint ( cls , roll2_mch , {
155
155
'constraint' : 'LIMIT_ROTATION' ,
156
156
'use_limit_x' : True ,
157
157
'max_x' : math .radians (360 ),
158
158
'owner_space' : 'LOCAL'
159
- })
159
+ })
160
160
161
- pb = cls .obj .pose .bones
161
+ pb = cls .obj .pose .bones
162
162
for i ,b in enumerate ([ rock1_mch , rock2_mch ]):
163
163
head_tail = pb [b ].head - pb [tmp_heel ].head
164
164
if '.L' in b :
@@ -176,22 +176,22 @@ def create_leg( cls, bones ):
176
176
min_y = 0
177
177
max_y = math .radians (360 )
178
178
179
-
179
+
180
180
make_constraint ( cls , b , {
181
181
'constraint' : 'COPY_ROTATION' ,
182
182
'subtarget' : heel ,
183
183
'use_x' : False ,
184
184
'use_z' : False ,
185
185
'owner_space' : 'LOCAL' ,
186
186
'target_space' : 'LOCAL'
187
- })
187
+ })
188
188
make_constraint ( cls , b , {
189
189
'constraint' : 'LIMIT_ROTATION' ,
190
190
'use_limit_y' : True ,
191
191
'min_y' : min_y ,
192
192
'max_y' : max_y ,
193
193
'owner_space' : 'LOCAL'
194
- })
194
+ })
195
195
196
196
# Constrain 4th ORG to roll2 MCH bone
197
197
make_constraint ( cls , org_bones [3 ], {
@@ -201,7 +201,7 @@ def create_leg( cls, bones ):
201
201
202
202
# Set up constraints
203
203
# Constrain mch target bone to the ik control and mch stretch
204
-
204
+
205
205
make_constraint ( cls , bones ['ik' ]['mch_target' ], {
206
206
'constraint' : 'COPY_LOCATION' ,
207
207
'subtarget' : bones ['ik' ]['mch_str' ],
@@ -235,7 +235,7 @@ def create_leg( cls, bones ):
235
235
236
236
# Create ik/fk switch property
237
237
pb_parent = pb [ bones ['parent' ] ]
238
-
238
+
239
239
pb_parent ['IK_Strertch' ] = 1.0
240
240
prop = rna_idprop_ui_prop_get ( pb_parent , 'IK_Strertch' , create = True )
241
241
prop ["min" ] = 0.0
@@ -248,7 +248,7 @@ def create_leg( cls, bones ):
248
248
b = bones ['ik' ]['mch_str' ]
249
249
drv = pb [b ].constraints [- 1 ].driver_add ("influence" ).driver
250
250
drv .type = 'AVERAGE'
251
-
251
+
252
252
var = drv .variables .new ()
253
253
var .name = prop .name
254
254
var .type = "SINGLE_PROP"
@@ -257,7 +257,7 @@ def create_leg( cls, bones ):
257
257
pb_parent .path_from_id () + '[' + '"' + prop .name + '"' + ']'
258
258
259
259
drv_modifier = cls .obj .animation_data .drivers [- 1 ].modifiers [0 ]
260
-
260
+
261
261
drv_modifier .mode = 'POLYNOMIAL'
262
262
drv_modifier .poly_order = 1
263
263
drv_modifier .coefficients [0 ] = 1.0
@@ -284,7 +284,7 @@ def create_leg( cls, bones ):
284
284
285
285
eb [ toes ].use_connect = False
286
286
eb [ toes ].parent = eb [ org_bones [3 ] ]
287
-
287
+
288
288
# Constrain toes def bones
289
289
make_constraint ( cls , bones ['def' ][- 2 ], {
290
290
'constraint' : 'DAMPED_TRACK' ,
@@ -293,8 +293,8 @@ def create_leg( cls, bones ):
293
293
make_constraint ( cls , bones ['def' ][- 2 ], {
294
294
'constraint' : 'STRETCH_TO' ,
295
295
'subtarget' : toes
296
- })
297
-
296
+ })
297
+
298
298
make_constraint ( cls , bones ['def' ][- 1 ], {
299
299
'constraint' : 'COPY_TRANSFORMS' ,
300
300
'subtarget' : toes
@@ -303,12 +303,12 @@ def create_leg( cls, bones ):
303
303
# Find IK/FK switch property
304
304
pb = cls .obj .pose .bones
305
305
prop = rna_idprop_ui_prop_get ( pb [ bones ['parent' ] ], 'IK/FK' )
306
-
306
+
307
307
# Add driver to limit scale constraint influence
308
308
b = org_bones [3 ]
309
309
drv = pb [b ].constraints [- 1 ].driver_add ("influence" ).driver
310
310
drv .type = 'AVERAGE'
311
-
311
+
312
312
var = drv .variables .new ()
313
313
var .name = prop .name
314
314
var .type = "SINGLE_PROP"
@@ -317,17 +317,17 @@ def create_leg( cls, bones ):
317
317
pb_parent .path_from_id () + '[' + '"' + prop .name + '"' + ']'
318
318
319
319
drv_modifier = cls .obj .animation_data .drivers [- 1 ].modifiers [0 ]
320
-
320
+
321
321
drv_modifier .mode = 'POLYNOMIAL'
322
322
drv_modifier .poly_order = 1
323
323
drv_modifier .coefficients [0 ] = 1.0
324
324
drv_modifier .coefficients [1 ] = - 1.0
325
-
325
+
326
326
# Create toe circle widget
327
327
create_circle_widget (cls .obj , toes , radius = 0.4 , head_tail = 0.5 )
328
328
329
329
bones ['ik' ]['ctrl' ]['terminal' ] += [ toes ]
330
330
331
331
bones ['ik' ]['ctrl' ]['terminal' ] += [ heel , ctrl ]
332
-
332
+
333
333
return bones
0 commit comments