[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4620] trunk/py/scripts/addons/ io_import_scene_mhx.py: FK-IK snapping now works (more or less) with both the alpha7 and alpha8 meshes.
Thomas Larsson
thomas_larsson_01 at hotmail.com
Thu Jul 4 13:42:16 CEST 2013
Revision: 4620
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4620
Author: thomasl
Date: 2013-07-04 11:42:15 +0000 (Thu, 04 Jul 2013)
Log Message:
-----------
FK-IK snapping now works (more or less) with both the alpha7 and alpha8 meshes.
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 2013-07-04 11:18:23 UTC (rev 4619)
+++ trunk/py/scripts/addons/io_import_scene_mhx.py 2013-07-04 11:42:15 UTC (rev 4620)
@@ -38,8 +38,8 @@
bl_info = {
'name': 'Import: MakeHuman (.mhx)',
'author': 'Thomas Larsson',
- 'version': (1, 15, 4),
- "blender": (2, 67, 0),
+ 'version': (1, 16, 0),
+ "blender": (2, 67, 1),
'location': "File > Import > MakeHuman (.mhx)",
'description': 'Import files in the MakeHuman eXchange format (.mhx)',
'warning': '',
@@ -49,10 +49,13 @@
'category': 'Import-Export'}
MAJOR_VERSION = 1
-MINOR_VERSION = 15
+MINOR_VERSION = 16
FROM_VERSION = 13
-SUB_VERSION = 3
+SUB_VERSION = 0
+majorVersion = MAJOR_VERSION
+minorVersion = MINOR_VERSION
+
#
#
#
@@ -117,9 +120,9 @@
T_Opcns = 0x2000
T_Symm = 0x4000
-DefaultToggle = ( T_EnforceVersion + T_Mesh + T_Armature +
+DefaultToggle = ( T_EnforceVersion + T_Mesh + T_Armature +
T_Shapekeys + T_ShapeDrivers + T_Proxy + T_Clothes + T_Rigify )
-
+
toggle = DefaultToggle
toggleSettings = toggle
@@ -146,7 +149,7 @@
'Image' : {},
'MaterialTextureSlot' : {},
'Texture' : {},
-
+
'Bone' : {},
'BoneGroup' : {},
'Rigify' : {},
@@ -165,7 +168,7 @@
'MaterialSlot' : {},
}
return
-
+
def reinitGlobalData():
global loadedData
for key in [
@@ -233,7 +236,7 @@
file= open(fileName, "rU")
print( "Tokenizing" )
lineNo = 0
- for line in file:
+ for line in file:
# print(line)
lineSplit= line.split()
lineNo += 1
@@ -287,11 +290,11 @@
file.close()
if level != 0:
- MyError("Tokenizer error (%d).\nThe mhx file has been corrupted.\nTry to export it again from MakeHuman." % level)
+ MyError("Tokenizer error (%d).\nThe mhx file has been corrupted.\nTry to export it again from MakeHuman." % level)
scn = clearScene()
print( "Parsing" )
parse(tokens)
-
+
for (expr, glbals, lcals) in todo:
try:
print("Doing %s" % expr)
@@ -305,7 +308,7 @@
scn.objects.active = theArmature
theArmature.MhAlpha8 = not alpha7
#bpy.ops.wm.properties_edit(data_path="object", property="MhxRig", value=theArmature["MhxRig"])
-
+
time2 = time.clock()
msg = "File %s loaded in %g s" % (fileName, time2-time1)
if nErrors:
@@ -369,11 +372,14 @@
def parse(tokens):
global MHX249, ifResult, theScale, defaultScale, One
-
- for (key, val, sub) in tokens:
+ global majorVersion, minorVersion
+
+ for (key, val, sub) in tokens:
data = None
if key == 'MHX':
- checkMhxVersion(int(val[0]), int(val[1]))
+ majorVersion = int(val[0])
+ minorVersion = int(val[1])
+ checkMhxVersion(majorVersion, minorVersion)
elif key == 'MHX249':
MHX249 = eval(val[0])
print("Blender 2.49 compatibility mode is %s\n" % MHX249)
@@ -387,12 +393,12 @@
print(msg)
elif key == 'error':
msg = concatList(val)
- MyError(msg)
+ MyError(msg)
elif key == 'NoScale':
if eval(val[0]):
theScale = 1.0
else:
- theScale = defaultScale
+ theScale = defaultScale
One = 1.0/theScale
elif key == "Object":
parseObject(val, sub)
@@ -461,9 +467,9 @@
MyError("ShapeKeys object %s does not exist" % val[0])
if ob:
bpy.context.scene.objects.active = ob
- parseShapeKeys(ob, ob.data, val, sub)
+ parseShapeKeys(ob, ob.data, val, sub)
else:
- data = parseDefaultType(key, val, sub)
+ data = parseDefaultType(key, val, sub)
#
# parseDefaultType(typ, args, tokens):
@@ -485,7 +491,7 @@
for (key, val, sub) in tokens:
defaultKey(key, val, sub, 'data', [], globals(), locals())
return data
-
+
#
# concatList(elts)
#
@@ -515,7 +521,7 @@
for (key, val, sub) in tokens:
if key == 'FCurve':
prepareActionFCurve(ob, created, val, sub)
-
+
act = ob.animation_data.action
loadedData['Action'][name] = act
if act is None:
@@ -523,7 +529,7 @@
return act
act.name = name
print("Action", name, act, ob)
-
+
for (key, val, sub) in tokens:
if key == 'FCurve':
fcu = parseActionFCurve(act, ob, val, sub)
@@ -533,7 +539,7 @@
bpy.ops.object.mode_set(mode='OBJECT')
return act
-def prepareActionFCurve(ob, created, args, tokens):
+def prepareActionFCurve(ob, created, args, tokens):
dataPath = args[0]
index = args[1]
(expr, channel) = channelFromDataPath(dataPath, index)
@@ -635,12 +641,12 @@
def parseAnimationData(rna, args, tokens):
if not eval(args[1]):
return
- if rna.animation_data is None:
+ if rna.animation_data is None:
rna.animation_data_create()
adata = rna.animation_data
for (key, val, sub) in tokens:
if key == 'FCurve':
- fcu = parseAnimDataFCurve(adata, rna, val, sub)
+ fcu = parseAnimDataFCurve(adata, rna, val, sub)
else:
defaultKey(key, val, sub, 'adata', [], globals(), locals())
return adata
@@ -687,7 +693,7 @@
for n in range(len(words)-1):
expr += "." + words[n]
expr += ".driver_add('%s', index)" % channel
-
+
fcu = eval(expr)
drv = fcu.driver
drv.type = args[0]
@@ -743,7 +749,7 @@
defaultKey(key, val, sub, 'targ', [], globals(), locals())
return targ
-
+
#
# parseMaterial(args, ext, tokens):
# parseMTex(mat, args, tokens):
@@ -778,7 +784,7 @@
else:
exclude = ['specular_intensity', 'tangent_shading']
defaultKey(key, val, sub, 'mat', [], globals(), locals())
-
+
return mat
def parseMTex(mat, args, tokens):
@@ -804,7 +810,7 @@
name = args[0]
tex = bpy.data.textures.new(name=name, type=args[1])
loadedData['Texture'][name] = tex
-
+
for (key, val, sub) in tokens:
if key == 'Image':
try:
@@ -838,7 +844,7 @@
n += 1
else:
defaultKey(key, val, sub, "tex", ['use_nodes', 'use_textures', 'contrast'], globals(), locals())
-
+
def parseSSS(mat, args, tokens):
sss = mat.subsurface_scattering
for (key, val, sub) in tokens:
@@ -921,7 +927,7 @@
print( "No such file: %s" % filepath.encode('utf-8','strict') )
return None
-
+
def parseImage(args, tokens):
global todo
imgName = args[0]
@@ -946,7 +952,7 @@
# createObject(type, name, data, datName):
# setObjectAndData(args, typ):
#
-
+
def parseObject(args, tokens):
if verbosity > 2:
print( "Parsing object %s" % args )
@@ -960,7 +966,7 @@
linkObject(ob, None)
else:
try:
- data = loadedData[typ.capitalize()][datName]
+ data = loadedData[typ.capitalize()][datName]
except:
MyError("Failed to find data: %s %s %s" % (name, typ, datName))
return
@@ -989,7 +995,7 @@
parseDefault(ob.field, sub, {}, [])
else:
defaultKey(key, val, sub, "ob", ['type', 'data'], globals(), locals())
-
+
if bpy.context.object == ob:
if ob.type == 'MESH':
bpy.ops.object.shade_smooth()
@@ -998,13 +1004,13 @@
return
def createObject(typ, name, data, datName):
- # print( "Creating object %s %s %s" % (typ, name, data) )
+ # print( "Creating object %s %s %s" % (typ, name, data) )
ob = bpy.data.objects.new(name, data)
if data:
loadedData[typ.capitalize()][datName] = data
loadedData['Object'][name] = ob
return ob
-
+
def linkObject(ob, data):
#print("Data", data, ob.data)
if data and ob.data is None:
@@ -1051,7 +1057,7 @@
hookAssignNth(mod, int(val[1]), True, ob.data.vertices)
else:
MyError("Unknown hook %s" % val)
- else:
+ else:
defaultKey(key, val, sub, 'mod', [], globals(), locals())
return mod
@@ -1173,14 +1179,14 @@
me.from_pydata(verts, edges, [])
me.update()
linkObject(ob, me)
-
+
if faces:
try:
me.polygons
BMeshAware = True
except:
BMeshAware = False
-
+
mats = []
nuvlayers = 0
for (key, val, sub) in tokens:
@@ -1191,14 +1197,14 @@
parseUvTextureBMesh(val, sub, me)
else:
parseUvTextureNoBMesh(val, sub, me)
- elif key == 'MeshColorLayer':
+ elif key == 'MeshColorLayer':
parseVertColorLayer(val, sub, me)
elif key == 'VertexGroup':
parseVertexGroup(ob, me, val, sub)
elif key == 'ShapeKeys':
parseShapeKeys(ob, me, val, sub)
elif key == 'Material':
- try:
+ try:
mat = loadedData['Material'][val[0]]
except:
mat = None
@@ -1219,7 +1225,7 @@
# parseVerts(tokens):
# parseEdges(tokens):
# parseFaces(tokens):
-# parseFaces2(tokens, me):
+# parseFaces2(tokens, me):
#
def parseVerts(tokens):
@@ -1235,8 +1241,8 @@
if key == 'e':
edges.append((int(val[0]), int(val[1])))
return edges
-
-def parseFaces(tokens):
+
+def parseFaces(tokens):
faces = []
for (key, val, sub) in tokens:
if key == 'f':
@@ -1247,7 +1253,7 @@
faces.append(face)
return faces
-def parseFaces2BMesh(tokens, me):
+def parseFaces2BMesh(tokens, me):
n = 0
for (key, val, sub) in tokens:
if key == 'ft':
@@ -1277,7 +1283,7 @@
f.use_smooth = smooth
return
-def parseFaces2NoBMesh(tokens, me):
+def parseFaces2NoBMesh(tokens, me):
n = 0
for (key, val, sub) in tokens:
if key == 'ft':
@@ -1319,7 +1325,7 @@
uvtex = me.uv_textures[-1]
uvtex.name = name
uvloop = me.uv_layers[-1]
- loadedData['MeshTextureFaceLayer'][name] = uvloop
+ loadedData['MeshTextureFaceLayer'][name] = uvloop
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list