Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
('PUpLipMid', (0,0)),
('PLoLipMid', (0,0)),
('PJaw', (0,0.4)),
('PTongue', (0,0))],
'O' : [
('PMouth', (-0.9,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,0)),
('PLoLipMid', (0,0)),
('PJaw', (0,0.8)),
('PTongue', (0,0))],
'R' : [
('PMouth', (-0.5,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.2)),
('PLoLipMid', (0,0.2)),
('PJaw', (0,0)),
('PTongue', (0,0))],
'FV' : [
('PMouth', (-0.2,0)),
('PMouthMid', (0,1.0)),
('PUpLipMid', (0,0)),
('PLoLipMid', (-0.6,-0.3)),
('PJaw', (0,0)),
('PTongue', (0,0))],
'S' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.5)),
('PLoLipMid', (0,0.7)),
('PJaw', (0,0)),
('PTongue', (0,0))],
'SH' : [
('PMouth', (-0.8,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-1.0)),
('PLoLipMid', (0,1.0)),
('PJaw', (0,0)),
('PTongue', (0,0))],
'EE' : [
('PMouth', (0.2,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.6)),
('PLoLipMid', (0,0.6)),
('PJaw', (0,0.05)),
('PTongue', (0,0))],
'AH' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.4)),
('PLoLipMid', (0,0)),
('PJaw', (0,0.7)),
('PTongue', (0,0))],
'EH' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.5)),
('PLoLipMid', (0,0.6)),
('PJaw', (0,0.25)),
('PTongue', (0,0))],
'TH' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,0)),
('PLoLipMid', (0,0)),
('PJaw', (0,0.2)),
('PTongue', (1.0,1.0))],
'L' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.5)),
('PLoLipMid', (0,0.5)),
('PJaw', (0,-0.2)),
('PTongue', (1.0,1.0))],
'G' : [
('PMouth', (0,0)),
('PMouthMid', (0,0)),
('PUpLipMid', (0,-0.5)),
('PLoLipMid', (0,0.5)),
('PJaw', (0,-0.2)),
('PTongue', (-1.0,0))],
'Blink' : [('PUpLid', (0,1.0)), ('PLoLid', (0,-1.0))],
'Unblink' : [('PUpLid', (0,0)), ('PLoLid', (0,0))],
})
VisemeList = [
('Rest', 'Etc', 'AH'),
('MBP', 'OO', 'O'),
('R', 'FV', 'S'),
('SH', 'EE', 'EH'),
('TH', 'L', 'G')
]
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
#
# makeVisemes(ob, scn):
# class VIEW3D_OT_MhxMakeVisemesButton(bpy.types.Operator):
#
def makeVisemes(ob, scn):
if ob.type != 'MESH':
print("Active object %s is not a mesh" % ob)
return
if not ob.data.shape_keys:
print("%s has no shapekeys" % ob)
return
adata = ob.data.shape_keys.animation_data
if not adata:
print("Shapekeys have not drivers")
return
try:
ob.data.shape_keys.key_blocks["VIS_Rest"]
print("Visemes already created")
return
except:
pass
rig = ob.parent
scale = rig.data.bones['PFace'].length*0.2
boneShapes = {}
for fcu in adata.drivers:
name = fcu.data_path.split('"')[1]
for var in fcu.driver.variables:
if var.type == 'TRANSFORMS':
targ = var.targets[0]
fmod = fcu.modifiers[0]
try:
list = boneShapes[targ.bone_target]
except:
list = []
boneShapes[targ.bone_target] = list
list.append((targ.transform_type, fmod, ob.data.shape_keys.key_blocks[name]))
verts = ob.data.vertices
for (vis,bones) in bodyLanguageVisemes.items():
if vis in ['Blink', 'Unblink']:
continue
vkey = ob.shape_key_add(name="VIS_%s" % vis)
print(vkey.name)
for n,v in enumerate(verts):
vkey.data[n].co = v.co
for (bone, xz) in bones:
try:
boneShapes[bone]
single = True
except:
single = False
if single:
addToVisShapeKey(boneShapes[bone], vkey, verts, xz, 1, scale)
else:
try:
boneShapes[bone+"_L"]
double = True
except:
double = False
if double:
addToVisShapeKey(boneShapes[bone+"_L"], vkey, verts, xz, 1, scale)
#addToVisShapeKey(boneShapes[bone+"_R"], vkey, verts, xz, -1, scale)
print("Visemes made")
return
def addToVisShapeKey(shapes, vkey, verts, xz, sign, scale):
for (typ, fmod, skey) in shapes:
factor = fmod.coefficients[1]*scale
(x,z) = xz
if typ == 'LOC_X':
k = factor*sign*x
elif typ == 'LOC_Z':
k = factor*z
if k < skey.slider_min:
k = skey.slider_min
if k > skey.slider_max:
k = skey.slider_max
if abs(k) < 0.001:
continue
print(" %s %.3f %.3f %.3f %.3f" % (skey.name, factor, x, z, k))
for n,v in enumerate(verts):
vkey.data[n].co += k*(skey.data[n].co - v.co)
return
class VIEW3D_OT_MhxMakeVisemesButton(bpy.types.Operator):
bl_idname = "mhx.make_visemes"
bl_label = "Generate viseme shapekeys"
def execute(self, context):
makeVisemes(context.object, context.scene)
return{'FINISHED'}
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
#
# mohoVisemes
# magpieVisemes
#
mohoVisemes = dict({
'rest' : 'Rest',
'etc' : 'Etc',
'AI' : 'AH',
'O' : 'O',
'U' : 'OO',
'WQ' : 'AH',
'L' : 'L',
'E' : 'EH',
'MBP' : 'MBP',
'FV' : 'FV',
})
magpieVisemes = dict({
"CONS" : "t,d,k,g,T,D,s,z,S,Z,h,n,N,j,r,tS",
"AI" : "i,&,V,aU,I,0,@,aI",
"E" : "eI,3,e",
"O" : "O,@U,oI",
"UW" : "U,u,w",
"MBP" : "m,b,p",
"L" : "l",
"FV" : "f,v",
"Sh" : "dZ",
})
#
# setViseme(context, vis, setKey, frame):
# setBoneLocation(context, pbone, loc, mirror, setKey, frame):
# class VIEW3D_OT_MhxVisemeButton(bpy.types.Operator):
#
def getVisemeSet(context, rig):
try:
visset = rig['MhxVisemeSet']
except:
return bodyLanguageVisemes
if visset == 'StopStaring':
return stopStaringVisemes
elif visset == 'BodyLanguage':
return bodyLanguageVisemes
else:
raise NameError("Unknown viseme set %s" % visset)
def setViseme(context, vis, setKey, frame):
rig = getMhxRig(context.object)
pbones = rig.pose.bones
try:
scale = pbones['PFace'].bone.length
except:
return
visemes = getVisemeSet(context, rig)
for (b, (x, z)) in visemes[vis]:
loc = mathutils.Vector((float(x),0,float(z)))
try:
pb = pbones[b]
except:
pb = None
if pb:
setBoneLocation(context, pb, scale, loc, False, setKey, frame)
else:
setBoneLocation(context, pbones[b+'_L'], scale, loc, False, setKey, frame)
setBoneLocation(context, pbones[b+'_R'], scale, loc, True, setKey, frame)
Thomas Larsson
committed
updatePose(context.scene)
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
return
def setBoneLocation(context, pb, scale, loc, mirror, setKey, frame):
if mirror:
loc[0] = -loc[0]
pb.location = loc*scale*0.2
if setKey or context.tool_settings.use_keyframe_insert_auto:
for n in range(3):
pb.keyframe_insert('location', index=n, frame=frame, group=pb.name)
return
class VIEW3D_OT_MhxVisemeButton(bpy.types.Operator):
bl_idname = 'mhx.pose_viseme'
bl_label = 'Viseme'
viseme = StringProperty()
def invoke(self, context, event):
setViseme(context, self.viseme, False, context.scene.frame_current)
return{'FINISHED'}
#
# openFile(context, filepath):
# readMoho(context, filepath, offs):
# readMagpie(context, filepath, offs):
#
def openFile(context, filepath):
(path, fileName) = os.path.split(filepath)
(name, ext) = os.path.splitext(fileName)
return open(filepath, "rU")
def readMoho(context, filepath, offs):
rig = getMhxRig(context.object)
context.scene.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
fp = openFile(context, filepath)
for line in fp:
words= line.split()
if len(words) < 2:
pass
else:
vis = mohoVisemes[words[1]]
setViseme(context, vis, True, int(words[0])+offs)
fp.close()
setInterpolation(rig)
Thomas Larsson
committed
updatePose(context.scene)
print("Moho file %s loaded" % filepath)
return
def readMagpie(context, filepath, offs):
rig = getMhxRig(context.object)
context.scene.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
fp = openFile(context, filepath)
for line in fp:
words= line.split()
if len(words) < 3:
pass
elif words[2] == 'X':
vis = magpieVisemes[words[3]]
setViseme(context, vis, True, int(words[0])+offs)
fp.close()
setInterpolation(rig)
Thomas Larsson
committed
updatePose(context.scene)
print("Magpie file %s loaded" % filepath)
return
#
# class VIEW3D_OT_MhxLoadMohoButton(bpy.types.Operator):
#
class VIEW3D_OT_MhxLoadMohoButton(bpy.types.Operator):
bl_idname = "mhx.pose_load_moho"
bl_label = "Moho (.dat)"
filepath = StringProperty(subtype='FILE_PATH')
startFrame = IntProperty(name="Start frame", description="First frame to import", default=1)
def execute(self, context):
import bpy, os, mathutils
readMoho(context, self.properties.filepath, self.properties.startFrame-1)
return{'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
#
# class VIEW3D_OT_MhxLoadMagpieButton(bpy.types.Operator):
#
class VIEW3D_OT_MhxLoadMagpieButton(bpy.types.Operator):
bl_idname = "mhx.pose_load_magpie"
bl_label = "Magpie (.mag)"
filepath = StringProperty(subtype='FILE_PATH')
startFrame = IntProperty(name="Start frame", description="First frame to import", default=1)
def execute(self, context):
import bpy, os, mathutils
readMagpie(context, self.properties.filepath, self.properties.startFrame-1)
return{'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
#
# class MhxLipsyncPanel(bpy.types.Panel):
#
class MhxLipsyncPanel(bpy.types.Panel):
bl_label = "MHX Lipsync"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_options = {'DEFAULT_CLOSED'}
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
@classmethod
def poll(cls, context):
return context.object
def draw(self, context):
rig = getMhxRig(context.object)
if not rig:
return
layout = self.layout
layout.label(text="Visemes")
for (vis1, vis2, vis3) in VisemeList:
row = layout.row()
row.operator("mhx.pose_viseme", text=vis1).viseme = vis1
row.operator("mhx.pose_viseme", text=vis2).viseme = vis2
row.operator("mhx.pose_viseme", text=vis3).viseme = vis3
layout.separator()
row = layout.row()
row.operator("mhx.pose_viseme", text="Blink").viseme = 'Blink'
row.operator("mhx.pose_viseme", text="Unblink").viseme = 'Unblink'
layout.label(text="Load file")
row = layout.row()
row.operator("mhx.pose_load_moho")
row.operator("mhx.pose_load_magpie")
layout.operator("mhx.update")
layout.separator()
layout.operator("mhx.make_visemes")
#
Thomas Larsson
committed
# updatePose(scn):
# class VIEW3D_OT_MhxUpdateButton(bpy.types.Operator):
#
Thomas Larsson
committed
def updatePose(scn):
scn = bpy.context.scene
scn.frame_current = scn.frame_current
#scn.frame_current -= 1
return
class VIEW3D_OT_MhxUpdateButton(bpy.types.Operator):
bl_idname = "mhx.update"
bl_label = "Update"
def execute(self, context):
Thomas Larsson
committed
updatePose(context.scene)
return{'FINISHED'}
###################################################################################
#
# Expression panel
#
###################################################################################
#
# class VIEW3D_OT_MhxResetExpressionsButton(bpy.types.Operator):
#
class VIEW3D_OT_MhxResetExpressionsButton(bpy.types.Operator):
bl_idname = "mhx.pose_reset_expressions"
bl_label = "Reset expressions"
def execute(self, context):
rig = getMhxRig(context.object)
props = getShapeProps(rig)
for (prop, name) in props:
rig[prop] = 0.0
Thomas Larsson
committed
updatePose(context.scene)
return{'FINISHED'}
#
# class VIEW3D_OT_MhxKeyExpressionButton(bpy.types.Operator):
#
class VIEW3D_OT_MhxKeyExpressionsButton(bpy.types.Operator):
bl_idname = "mhx.pose_key_expressions"
bl_label = "Key expressions"
def execute(self, context):
rig = getMhxRig(context.object)
props = getShapeProps(rig)
frame = context.scene.frame_current
for (prop, name) in props:
rig.keyframe_insert('["%s"]' % prop, frame=frame)
Thomas Larsson
committed
updatePose(context.scene)
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
return{'FINISHED'}
#
# class VIEW3D_OT_MhxPinExpressionButton(bpy.types.Operator):
#
class VIEW3D_OT_MhxPinExpressionButton(bpy.types.Operator):
bl_idname = "mhx.pose_pin_expression"
bl_label = "Pin"
expression = StringProperty()
def execute(self, context):
rig = getMhxRig(context.object)
props = getShapeProps(rig)
if context.tool_settings.use_keyframe_insert_auto:
frame = context.scene.frame_current
for (prop, name) in props:
old = rig[prop]
if prop == self.expression:
rig[prop] = 1.0
else:
rig[prop] = 0.0
if abs(rig[prop] - old) > 1e-3:
rig.keyframe_insert('["%s"]' % prop, frame=frame)
else:
for (prop, name) in props:
if prop == self.expression:
rig[prop] = 1.0
else:
rig[prop] = 0.0
Thomas Larsson
committed
updatePose(context.scene)
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
return{'FINISHED'}
#
# getShapeProps(ob):
#
def getShapeProps(rig):
props = []
plist = list(rig.keys())
plist.sort()
for prop in plist:
if prop[0] == '*':
props.append((prop, prop[1:]))
return props
#
# class MhxExpressionsPanel(bpy.types.Panel):
#
class MhxExpressionsPanel(bpy.types.Panel):
bl_label = "MHX Expressions"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.object
def draw(self, context):
rig = getMhxRig(context.object)
if not rig:
return
props = getShapeProps(rig)
if not props:
return
layout = self.layout
layout.label(text="Expressions")
layout.operator("mhx.pose_reset_expressions")
layout.operator("mhx.pose_key_expressions")
#layout.operator("mhx.update")
layout.separator()
for (prop, name) in props:
Thomas Larsson
committed
row = layout.split(0.85)
row.prop(rig, '["%s"]' % prop, text=name)
Thomas Larsson
committed
row.operator("mhx.pose_pin_expression", text="", icon='UNPINNED').expression = prop
return
###################################################################################
#
# Posing panel
#
###################################################################################
#
# class MhxDriversPanel(bpy.types.Panel):
#
class MhxDriversPanel(bpy.types.Panel):
bl_label = "MHX Drivers"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return pollMhxRig(context.object)
def draw(self, context):
lProps = []
rProps = []
props = []
plist = list(context.object.keys())
plist.sort()
for prop in plist:
Thomas Larsson
committed
if prop[0] == '&':
prop1 = prop[1:]
else:
continue
if prop[-2:] == '_L':
Thomas Larsson
committed
lProps.append((prop, prop1[:-2]))
elif prop[-2:] == '_R':
Thomas Larsson
committed
rProps.append((prop, prop1[:-2]))
Thomas Larsson
committed
props.append((prop, prop1))
ob = context.object
layout = self.layout
Thomas Larsson
committed
for (prop, pname) in props:
layout.prop(ob, '["%s"]' % prop, text=pname)
layout.label("Left")
for (prop, pname) in lProps:
layout.prop(ob, '["%s"]' % prop, text=pname)
layout.label("Right")
for (prop, pname) in rProps:
layout.prop(ob, '["%s"]' % prop, text=pname)
return
###################################################################################
#
# Visibility panel
#
###################################################################################
#
# class MhxVisibilityPanel(bpy.types.Panel):
#
class MhxVisibilityPanel(bpy.types.Panel):
bl_label = "MHX Visibility"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return pollMhxRig(context.object)
def draw(self, context):
ob = context.object
Thomas Larsson
committed
layout = self.layout
props = list(ob.keys())
props.sort()
for prop in props:
if prop[0:4] == "Hide":
Thomas Larsson
committed
layout.prop(ob, '["%s"]' % prop)
layout.separator()
layout.operator("mhx.update_textures")
Thomas Larsson
committed
class VIEW3D_OT_MhxUpdateTexturesButton(bpy.types.Operator):
bl_idname = "mhx.update_textures"
bl_label = "Update"
def execute(self, context):
scn = context.scene
for mat in bpy.data.materials:
if mat.animation_data:
try:
mat["MhxDriven"]
except:
continue
for driver in mat.animation_data.drivers:
prop = mat.path_resolve(driver.data_path)
value = driver.evaluate(scn.frame_current)
#print("Update %s[%d] = %s" % (driver.data_path, driver.array_index, value))
prop[driver.array_index] = value
return{'FINISHED'}
###################################################################################
#
# Layers panel
#
###################################################################################
MhxLayers = [
(( 0, 'Root', 'MhxRoot'),
( 8, 'Face', 'MhxFace')),
(( 9, 'Tweak', 'MhxTweak'),
(10, 'Head', 'MhxHead')),
(( 1, 'FK Spine', 'MhxFKSpine'),
(17, 'IK Spine', 'MhxIKSpine')),
((13, 'Inv FK Spine', 'MhxInvFKSpine'),
(16, 'Clothes', 'MhxClothes')),
('Left', 'Right'),
(( 2, 'IK Arm', 'MhxIKArm'),
(18, 'IK Arm', 'MhxIKArm')),
(( 3, 'FK Arm', 'MhxFKArm'),
(19, 'FK Arm', 'MhxFKArm')),
(( 4, 'IK Leg', 'MhxIKLeg'),
(20, 'IK Leg', 'MhxIKLeg')),
(( 5, 'FK Leg', 'MhxFKLeg'),
(21, 'FK Leg', 'MhxFKLeg')),
((12, 'Extra', 'MhxExtra'),
(28, 'Extra', 'MhxExtra')),
(( 6, 'Fingers', 'MhxFingers'),
(22, 'Fingers', 'MhxFingers')),
(( 7, 'Links', 'MhxLinks'),
(23, 'Links', 'MhxLinks')),
((11, 'Palm', 'MhxPalm'),
(27, 'Palm', 'MhxPalm')),
]
#
# class MhxLayersPanel(bpy.types.Panel):
#
class MhxLayersPanel(bpy.types.Panel):
bl_label = "MHX Layers"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return pollMhxRig(context.object)
def draw(self, context):
layout = self.layout
Thomas Larsson
committed
layout.operator("mhx.pose_enable_all_layers")
layout.operator("mhx.pose_disable_all_layers")
amt = context.object.data
for (left,right) in MhxLayers:
row = layout.row()
if type(left) == str:
row.label(left)
row.label(right)
else:
for (n, name, prop) in [left,right]:
row.prop(amt, "layers", index=n, toggle=True, text=name)
return
Thomas Larsson
committed
class VIEW3D_OT_MhxEnableAllLayersButton(bpy.types.Operator):
bl_idname = "mhx.pose_enable_all_layers"
bl_label = "Enable all layers"
def execute(self, context):
rig = getMhxRig(context.object)
for (left,right) in MhxLayers:
if type(left) != str:
for (n, name, prop) in [left,right]:
Thomas Larsson
committed
rig.data.layers[n] = True
return{'FINISHED'}
class VIEW3D_OT_MhxDisableAllLayersButton(bpy.types.Operator):
bl_idname = "mhx.pose_disable_all_layers"
bl_label = "Disable all layers"
def execute(self, context):
rig = getMhxRig(context.object)
layers = 32*[False]
pb = context.active_pose_bone
if pb:
for n in range(32):
if pb.bone.layers[n]:
layers[n] = True
break
else:
layers[0] = True
rig.data.layers = layers
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
return{'FINISHED'}
###################################################################################
#
# Common functions
#
###################################################################################
#
# pollMhxRig(ob):
# getMhxRig(ob):
#
def pollMhxRig(ob):
try:
return (ob["MhxRig"] == "MHX")
except:
return False
def getMhxRig(ob):
if ob.type == 'ARMATURE':
rig = ob
elif ob.type == 'MESH':
rig = ob.parent
else:
return None
try:
if (rig["MhxRig"] == "MHX"):
return rig
else:
return None
except:
return None
#
# setInterpolation(rig):
#
def setInterpolation(rig):
if not rig.animation_data:
return
act = rig.animation_data.action
if not act:
return
for fcu in act.fcurves:
for pt in fcu.keyframe_points:
pt.interpolation = 'LINEAR'
fcu.extrapolation = 'CONSTANT'
return
###################################################################################
#
# initialize and register
#
###################################################################################
def menu_func(self, context):
self.layout.operator(ImportMhx.bl_idname, text="MakeHuman (.mhx)...")
Campbell Barton
committed
bpy.utils.register_module(__name__)
Thomas Larsson
committed
bpy.utils.unregister_module(__name__)
Thomas Larsson
committed
try:
bpy.types.INFO_MT_file_import.remove(menu_func)
except:
pass
if __name__ == "__main__":
unregister()