[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2341] trunk/py/scripts/addons/ io_import_scene_mhx.py: MHX importer v1.8.
Thomas Larsson
thomas_larsson_01 at hotmail.com
Wed Sep 21 16:24:19 CEST 2011
Revision: 2341
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2341
Author: thomasl
Date: 2011-09-21 14:24:19 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
MHX importer v1.8. Pose tools merged with importer.
Modified Paths:
--------------
trunk/py/scripts/addons/io_import_scene_mhx.py
Modified: trunk/py/scripts/addons/io_import_scene_mhx.py
===================================================================
--- trunk/py/scripts/addons/io_import_scene_mhx.py 2011-09-21 08:53:49 UTC (rev 2340)
+++ trunk/py/scripts/addons/io_import_scene_mhx.py 2011-09-21 14:24:19 UTC (rev 2341)
@@ -26,7 +26,7 @@
"""
Abstract
MHX (MakeHuman eXchange format) importer for Blender 2.5x.
-Version 1.7.1
+Version 1.8.0
This script should be distributed with Blender.
If not, place it in the .blender/scripts/addons dir
@@ -39,9 +39,9 @@
bl_info = {
'name': 'Import: MakeHuman (.mhx)',
'author': 'Thomas Larsson',
- 'version': (1, 7, 1),
- "blender": (2, 5, 8),
- "api": 37702,
+ 'version': (1, 8, 0),
+ "blender": (2, 5, 9),
+ "api": 40335,
'location': "File > Import > MakeHuman (.mhx)",
'description': 'Import files in the MakeHuman eXchange format (.mhx)',
'warning': '',
@@ -51,9 +51,9 @@
'category': 'Import-Export'}
MAJOR_VERSION = 1
-MINOR_VERSION = 7
-SUB_VERSION = 1
-BLENDER_VERSION = (2, 58, 0)
+MINOR_VERSION = 8
+SUB_VERSION = 0
+BLENDER_VERSION = (2, 59, 2)
#
#
@@ -62,9 +62,8 @@
import bpy
import os
import time
-from mathutils import Matrix
-#import geometry
-#import string
+import mathutils
+from bpy.props import *
MHX249 = False
Blender24 = False
@@ -2089,145 +2088,8 @@
bpy.ops.mesh.delete(type='VERT')
bpy.ops.object.mode_set(mode='OBJECT')
return
-
-
+
#
-# parseProcess(args, tokens):
-# applyTransform(objects, rig, parents):
-#
-
-def parseProcess(args, tokens):
- return
- """
- if toggle & T_Bend == 0:
- return
- try:
- rig = loadedData['Object'][args[0]]
- except:
- rig = None
- if not rig:
- return
-
- parents = {}
- objects = []
-
- for (key, val, sub) in tokens:
- #print(key, val)
- if key == 'Reparent':
- bname = val[0]
- try:
- eb = ebones[bname]
- parents[bname] = eb.parent.name
- eb.parent = ebones[val[1]]
- except:
- pass
- elif key == 'Bend':
- axis = val[1]
- angle = float(val[2])
- mat = Matrix.Rotation(angle, 4, axis)
- try:
- pb = pbones[val[0]]
- except:
- pb = None
- print("No bone "+val[0])
- if pb:
- prod = pb.matrix_basis * mat
- for i in range(4):
- for j in range(4):
- pb.matrix_basis[i][j] = prod[i][j]
- elif key == 'Snap':
- try:
- eb = ebones[val[0]]
- except:
- eb = None
- tb = ebones[val[1]]
- typ = val[2]
- if eb is None:
- pass
- elif typ == 'Inv':
- eb.head = tb.tail
- eb.tail = tb.head
- elif typ == 'Head':
- eb.head = tb.head
- elif typ == 'Tail':
- eb.tail = tb.tail
- elif typ == 'Both':
- eb.head = tb.head
- eb.tail = tb.tail
- eb.roll = tb.roll
- else:
- MyError("Snap type %s" % typ)
- elif key == 'PoseMode':
- bpy.context.scene.objects.active = rig
- bpy.ops.object.mode_set(mode='POSE')
- pbones = rig.pose.bones
- elif key == 'ObjectMode':
- bpy.context.scene.objects.active = rig
- bpy.ops.object.mode_set(mode='POSE')
- pbones = rig.pose.bones
- elif key == 'EditMode':
- bpy.context.scene.objects.active = rig
- bpy.ops.object.mode_set(mode='EDIT')
- ebones = rig.data.edit_bones
- bpy.ops.armature.select_all(action='DESELECT')
- elif key == 'Roll':
- try:
- eb = ebones[val[0]]
- except:
- eb = None
- if eb:
- eb.roll = float(val[1])
- elif key == 'Select':
- pass
- elif key == 'RollUp':
- pass
- elif key == 'Apply':
- applyTransform(objects, rig, parents)
- elif key == 'ApplyArmature':
- try:
- ob = loadedData['Object'][val[0]]
- objects.append((ob,sub))
- except:
- ob = None
- elif key == 'Object':
- try:
- ob = loadedData['Object'][val[0]]
- except:
- ob = None
- if ob:
- bpy.context.scene.objects.active = ob
- #mod = ob.modifiers[0]
- #ob.modifiers.remove(mod)
- for (key1, val1, sub1) in sub:
- if key1 == 'Modifier':
- parseModifier(ob, val1, sub1)
- return
-
-def applyTransform(objects, rig, parents):
- for (ob,tokens) in objects:
- print("Applying transform to %s" % ob)
- bpy.context.scene.objects.active = ob
- bpy.ops.object.visual_transform_apply()
- bpy.ops.object.modifier_apply(apply_as='DATA', modifier='Armature')
-
- bpy.context.scene.objects.active = rig
- bpy.ops.object.mode_set(mode='POSE')
- bpy.ops.pose.armature_apply()
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.mode_set(mode='EDIT')
- ebones = rig.data.edit_bones
- for (bname, pname) in parents.items():
- eb = ebones[bname]
- par = ebones[pname]
- if eb.use_connect:
- par.tail = eb.head
- eb.parent = par
-
- bpy.ops.object.mode_set(mode='OBJECT')
- return
- """
-
-#
# defaultKey(ext, args, tokens, var, exclude, glbals, lcals):
#
@@ -2400,7 +2262,7 @@
#
def parseMatrix(args, tokens):
- matrix = Matrix()
+ matrix = mathutils.Matrix()
i = 0
for (key, val, sub) in tokens:
if key == 'row':
@@ -3065,6 +2927,716 @@
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
+
+###################################################################################
+#
+# Lipsync panel
+#
+###################################################################################
+
+#
+# visemes
+#
+
+stopStaringVisemes = ({
+ 'Rest' : [
+ ('PMouth', (0,0)),
+ ('PUpLip', (0,-0.1)),
+ ('PLoLip', (0,0.1)),
+ ('PJaw', (0,0.05)),
+ ('PTongue', (0,0.0))],
+ 'Etc' : [
+ ('PMouth', (0,0)),
+ ('PUpLip', (0,-0.1)),
+ ('PLoLip', (0,0.1)),
+ ('PJaw', (0,0.15)),
+ ('PTongue', (0,0.0))],
+ 'MBP' : [('PMouth', (-0.3,0)),
+ ('PUpLip', (0,1)),
+ ('PLoLip', (0,0)),
+ ('PJaw', (0,0.1)),
+ ('PTongue', (0,0.0))],
+ 'OO' : [('PMouth', (-1.5,0)),
+ ('PUpLip', (0,0)),
+ ('PLoLip', (0,0)),
+ ('PJaw', (0,0.2)),
+ ('PTongue', (0,0.0))],
+ 'O' : [('PMouth', (-1.1,0)),
+ ('PUpLip', (0,0)),
+ ('PLoLip', (0,0)),
+ ('PJaw', (0,0.5)),
+ ('PTongue', (0,0.0))],
+ 'R' : [('PMouth', (-0.9,0)),
+ ('PUpLip', (0,-0.2)),
+ ('PLoLip', (0,0.2)),
+ ('PJaw', (0,0.2)),
+ ('PTongue', (0,0.0))],
+ 'FV' : [('PMouth', (0,0)),
+ ('PUpLip', (0,0)),
+ ('PLoLip', (0,-0.8)),
+ ('PJaw', (0,0.1)),
+ ('PTongue', (0,0.0))],
+ 'S' : [('PMouth', (0,0)),
+ ('PUpLip', (0,-0.2)),
+ ('PLoLip', (0,0.2)),
+ ('PJaw', (0,0.05)),
+ ('PTongue', (0,0.0))],
+ 'SH' : [('PMouth', (-0.6,0)),
+ ('PUpLip', (0,-0.5)),
+ ('PLoLip', (0,0.5)),
+ ('PJaw', (0,0)),
+ ('PTongue', (0,0.0))],
+ 'EE' : [('PMouth', (0.3,0)),
+ ('PUpLip', (0,-0.3)),
+ ('PLoLip', (0,0.3)),
+ ('PJaw', (0,0.025)),
+ ('PTongue', (0,0.0))],
+ 'AH' : [('PMouth', (-0.1,0)),
+ ('PUpLip', (0,-0.4)),
+ ('PLoLip', (0,0)),
+ ('PJaw', (0,0.35)),
+ ('PTongue', (0,0.0))],
+ 'EH' : [('PMouth', (0.1,0)),
+ ('PUpLip', (0,-0.2)),
+ ('PLoLip', (0,0.2)),
+ ('PJaw', (0,0.2)),
+ ('PTongue', (0,0.0))],
+ 'TH' : [('PMouth', (0,0)),
+ ('PUpLip', (0,-0.5)),
+ ('PLoLip', (0,0.5)),
+ ('PJaw', (-0.2,0.1)),
+ ('PTongue', (0,-0.6))],
+ 'L' : [('PMouth', (0,0)),
+ ('PUpLip', (0,-0.2)),
+ ('PLoLip', (0,0.2)),
+ ('PJaw', (0.2,0.2)),
+ ('PTongue', (0,-0.8))],
+ 'G' : [('PMouth', (0,0)),
+ ('PUpLip', (0,-0.1)),
+ ('PLoLip', (0,0.1)),
+ ('PJaw', (-0.3,0.1)),
+ ('PTongue', (0,-0.6))],
+
+ 'Blink' : [('PUpLid', (0,1.0)), ('PLoLid', (0,-1.0))],
+ 'Unblink' : [('PUpLid', (0,0)), ('PLoLid', (0,0))],
+})
+
+bodyLanguageVisemes = ({
+ 'Rest' : [
+ ('PMouth', (0,0)),
+ ('PMouthMid', (0,-0.6)),
+ ('PUpLipMid', (0,0)),
+ ('PLoLipMid', (0,0)),
+ ('PJaw', (0,0)),
+ ('PTongue', (0,0))],
+ 'Etc' : [
+ ('PMouth', (0,0)),
+ ('PMouthMid', (0,-0.4)),
+ ('PUpLipMid', (0,0)),
+ ('PLoLipMid', (0,0)),
+ ('PJaw', (0,0)),
+ ('PTongue', (0,0))],
+ 'MBP' : [
+ ('PMouth', (0,0)),
+ ('PMouthMid', (0,0)),
+ ('PUpLipMid', (0,0)),
+ ('PLoLipMid', (0,0)),
+ ('PJaw', (0,0)),
+ ('PTongue', (0,0))],
+ 'OO' : [
+ ('PMouth', (-1.0,0)),
+ ('PMouthMid', (0,0)),
+ ('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)),
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list