[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1307] trunk/py/scripts/addons/ io_import_scene_mhx.py: == make human ==

Luca Bonavita mindrones at gmail.com
Thu Dec 23 00:24:36 CET 2010


Revision: 1307
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1307
Author:   mindrones
Date:     2010-12-23 00:24:36 +0100 (Thu, 23 Dec 2010)

Log Message:
-----------
== make human ==

Committing the most recent version of make human on behalf of Thomas Larsson (after the tracker upgrade svn plugin has to be fixed, will be done 
in january).

Also formatted bl_addon_info and changed tabs -> spaces.

Note: this script belongs to extern/, at due time we'll move it there.

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	2010-12-22 22:16:34 UTC (rev 1306)
+++ trunk/py/scripts/addons/io_import_scene_mhx.py	2010-12-22 23:24:36 UTC (rev 1307)
@@ -1,36 +1,38 @@
 """ 
-**Project Name:**	  MakeHuman
+**Project Name:**      MakeHuman
 
 **Product Home Page:** http://www.makehuman.org/
 
-**Code Home Page:**	http://code.google.com/p/makehuman/
+**Code Home Page:**    http://code.google.com/p/makehuman/
 
-**Authors:**		   Thomas Larsson
+**Authors:**           Thomas Larsson
 
-**Copyright(c):**	  MakeHuman Team 2001-2010
+**Copyright(c):**      MakeHuman Team 2001-2010
 
-**Licensing:**		 GPL3 (see also http://sites.google.com/site/makehumandocs/licensing)
+**Licensing:**         GPL3 (see also http://sites.google.com/site/makehumandocs/licensing)
 
 **Coding Standards:**  See http://sites.google.com/site/makehumandocs/developers-guide
 
 Abstract
 MHX (MakeHuman eXchange format) importer for Blender 2.5x.
-Version 1.0
+Version 1.0.3
 
 """
 
 bl_addon_info = {
-	'name': 'Import: MakeHuman (.mhx)',
-	'author': 'Thomas Larsson',
-	'version': '1.0',
-	'blender': (2, 5, 4),
-    "api": 31913,
-	"location": "File > Import",
-	"description": "Import files in the MakeHuman eXchange format (.mhx)",
-	"warning": "",
-	"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/Make_Human",
-	"tracker_url": "https://projects.blender.org/tracker/index.php?func=detail&aid=21872&group_id=153&atid=469",
-	"category": "Import/Export"}
+    'name': 'Import: MakeHuman (.mhx)',
+    'author': 'Thomas Larsson',
+    'version': (1, 0, 3),
+    'blender': (2, 5, 5),
+    'api': 33590,
+    'location': "File > Import",
+    'description': 'Import files in the MakeHuman eXchange format (.mhx)',
+    'warning': '',
+    'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/'\
+        'Scripts/File_I-O/Make_Human',
+    'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
+        'func=detail&aid=21872&group_id=153&atid=469',
+    'category': 'Import/Export'}
 
 """
 Place this file in the .blender/scripts/addons dir
@@ -40,7 +42,8 @@
 
 MAJOR_VERSION = 1
 MINOR_VERSION = 0
-BLENDER_VERSION = (2, 54, 0)
+SUB_VERSION = 3
+BLENDER_VERSION = (2, 55, 1)
 
 #
 #
@@ -51,7 +54,8 @@
 import time
 import mathutils
 from mathutils import *
-import string
+#import geometry
+#import string
 
 MHX249 = False
 Blender24 = False
@@ -78,7 +82,7 @@
 todo = []
 
 #
-#	toggle flags
+#    toggle flags
 #
 
 T_EnforceVersion = 0x01
@@ -104,14 +108,14 @@
 toggle = T_EnforceVersion + T_Replace + T_Mesh + T_Armature + T_Face + T_Shape + T_Proxy + T_Clothes
 
 #
-#	setFlagsAndFloats(rigFlags):
+#    setFlagsAndFloats(rigFlags):
 #
-#	Global floats
+#    Global floats
 #fFingerPanel = 0.0
 #fFingerIK = 0.0
 fNoStretch = 0.0
 
-#	rigLeg and rigArm flags
+#    rigLeg and rigArm flags
 T_Toes = 0x0001
 #T_GoboFoot = 0x0002
 
@@ -130,251 +134,251 @@
 #rigArm = 0
 
 def setFlagsAndFloats():
-	'''
-	global toggle, rigLeg, rigArm
+    '''
+    global toggle, rigLeg, rigArm
 
-	(footRig, fingerRig) = rigFlags
-	rigLeg = 0
-	if footRig == 'Reverse foot': 
-		rigLeg |= T_InvFoot
-		if toggle & T_PoleTar:
-			rigLeg |= T_InvFootPT
-		else:
-			rigLeg |= T_InvFootNoPT
-	elif footRig == 'Gobo': rigLeg |= T_GoboFoot		
+    (footRig, fingerRig) = rigFlags
+    rigLeg = 0
+    if footRig == 'Reverse foot': 
+        rigLeg |= T_InvFoot
+        if toggle & T_PoleTar:
+            rigLeg |= T_InvFootPT
+        else:
+            rigLeg |= T_InvFootNoPT
+    elif footRig == 'Gobo': rigLeg |= T_GoboFoot        
 
-	rigArm = 0
-	if fingerRig == 'Panel': rigArm |= T_FingerPanel
-	elif fingerRig == 'Rotation': rigArm |= T_FingerRot
-	elif fingerRig == 'IK': rigArm |= T_FingerIK
+    rigArm = 0
+    if fingerRig == 'Panel': rigArm |= T_FingerPanel
+    elif fingerRig == 'Rotation': rigArm |= T_FingerRot
+    elif fingerRig == 'IK': rigArm |= T_FingerIK
 
-	toggle |= T_Panel
-	'''
-	global fNoStretch
-	if toggle&T_Stretch: fNoStretch == 0.0
-	else: fNoStretch = 1.0
+    toggle |= T_Panel
+    '''
+    global fNoStretch
+    if toggle&T_Stretch: fNoStretch == 0.0
+    else: fNoStretch = 1.0
 
-	return
+    return
 
 
 #
-#	Dictionaries
+#    Dictionaries
 #
 
 loadedData = {
-	'NONE' : {},
+    'NONE' : {},
 
-	'Object' : {},
-	'Mesh' : {},
-	'Armature' : {},
-	'Lamp' : {},
-	'Camera' : {},
-	'Lattice' : {},
-	'Curve' : {},
-	'Text' : {},
+    'Object' : {},
+    'Mesh' : {},
+    'Armature' : {},
+    'Lamp' : {},
+    'Camera' : {},
+    'Lattice' : {},
+    'Curve' : {},
+    'Text' : {},
 
-	'Material' : {},
-	'Image' : {},
-	'MaterialTextureSlot' : {},
-	'Texture' : {},
-	
-	'Bone' : {},
-	'BoneGroup' : {},
-	'Rigify' : {},
+    'Material' : {},
+    'Image' : {},
+    'MaterialTextureSlot' : {},
+    'Texture' : {},
+    
+    'Bone' : {},
+    'BoneGroup' : {},
+    'Rigify' : {},
 
-	'Action' : {},
-	'Group' : {},
+    'Action' : {},
+    'Group' : {},
 
-	'MeshTextureFaceLayer' : {},
-	'MeshColorLayer' : {},
-	'VertexGroup' : {},
-	'ShapeKey' : {},
-	'ParticleSystem' : {},
+    'MeshTextureFaceLayer' : {},
+    'MeshColorLayer' : {},
+    'VertexGroup' : {},
+    'ShapeKey' : {},
+    'ParticleSystem' : {},
 
-	'ObjectConstraints' : {},
-	'ObjectModifiers' : {},
-	'MaterialSlot' : {},
+    'ObjectConstraints' : {},
+    'ObjectModifiers' : {},
+    'MaterialSlot' : {},
 }
 
 Plural = {
-	'Object' : 'objects',
-	'Mesh' : 'meshes',
-	'Lattice' : 'lattices',
-	'Curve' : 'curves',
-	'Text' : 'texts',
-	'Group' : 'groups',
-	'Empty' : 'empties',
-	'Armature' : 'armatures',
-	'Bone' : 'bones',
-	'BoneGroup' : 'bone_groups',
-	'Pose' : 'poses',
-	'PoseBone' : 'pose_bones',
-	'Material' : 'materials',
-	'Texture' : 'textures',
-	'Image' : 'images',
-	'Camera' : 'cameras',
-	'Lamp' : 'lamps',
-	'World' : 'worlds',
+    'Object' : 'objects',
+    'Mesh' : 'meshes',
+    'Lattice' : 'lattices',
+    'Curve' : 'curves',
+    'Text' : 'texts',
+    'Group' : 'groups',
+    'Empty' : 'empties',
+    'Armature' : 'armatures',
+    'Bone' : 'bones',
+    'BoneGroup' : 'bone_groups',
+    'Pose' : 'poses',
+    'PoseBone' : 'pose_bones',
+    'Material' : 'materials',
+    'Texture' : 'textures',
+    'Image' : 'images',
+    'Camera' : 'cameras',
+    'Lamp' : 'lamps',
+    'World' : 'worlds',
 }
 
 #
-#	checkBlenderVersion()
+#    checkBlenderVersion()
 #
 
 def checkBlenderVersion():
-	print("Found Blender", bpy.app.version)
-	(A, B, C) = bpy.app.version
-	(a, b, c) = BLENDER_VERSION
-	if a <= A: return
-	if b <= B: return
-	if c <= C: return
-	msg = (
+    print("Found Blender", bpy.app.version)
+    (A, B, C) = bpy.app.version
+    (a, b, c) = BLENDER_VERSION
+    if a <= A: return
+    if b <= B: return
+    if c <= C: return
+    msg = (
 "This version of the MHX importer only works with Blender (%d, %d, %d) or later. " % (a, b, c) +
 "Download a more recent Blender from www.blender.org or www.graphicall.org.\n"
-	)
-	raise NameError(msg)
-	return
+    )
+    raise NameError(msg)
+    return
 
 #
-#	readMhxFile(filePath, scale):
+#    readMhxFile(filePath, scale):
 #
 
 def readMhxFile(filePath, scale):
-	global todo, nErrors, theScale, defaultScale, One, toggle
+    global todo, nErrors, theScale, defaultScale, One, toggle
 
-	checkBlenderVersion()	
-	
-	theScale = scale
-	defaultScale = scale
-	One = 1.0/theScale
+    checkBlenderVersion()    
+    
+    theScale = scale
+    defaultScale = scale
+    One = 1.0/theScale
 
-	fileName = os.path.expanduser(filePath)
-	(shortName, ext) = os.path.splitext(fileName)
-	if ext.lower() != ".mhx":
-		print("Error: Not a mhx file: " + fileName)
-		return
-	print( "Opening MHX file "+ fileName )
-	time1 = time.clock()
+    fileName = os.path.expanduser(filePath)
+    (shortName, ext) = os.path.splitext(fileName)
+    if ext.lower() != ".mhx":
+        print("Error: Not a mhx file: " + fileName)
+        return
+    print( "Opening MHX file "+ fileName )
+    time1 = time.clock()
 
-	ignore = False
-	stack = []
-	tokens = []
-	key = "toplevel"
-	level = 0
-	nErrors = 0
-	comment = 0
-	nesting = 0
+    ignore = False
+    stack = []
+    tokens = []
+    key = "toplevel"
+    level = 0
+    nErrors = 0
+    comment = 0
+    nesting = 0
 
-	setFlagsAndFloats()
+    setFlagsAndFloats()
 
-	file= open(fileName, "rU")
-	print( "Tokenizing" )
-	lineNo = 0
-	for line in file: 
-		# print(line)
-		lineSplit= line.split()
-		lineNo += 1
-		if len(lineSplit) == 0:
-			pass
-		elif lineSplit[0][0] == '#':
-			if lineSplit[0] == '#if':
-				if comment == nesting:
-					try:
-						res = eval(lineSplit[1])
-					except:
-						res = False
-					if res:
-						comment += 1
-				nesting += 1
-			elif lineSplit[0] == '#else':
-				if comment == nesting-1:
-					comment += 1
-				elif comment == nesting:
-					comment -= 1
-			elif lineSplit[0] == '#endif':
-				if comment == nesting:
-					comment -= 1
-				nesting -= 1
-		elif comment < nesting:
-			pass
-		elif lineSplit[0] == 'end':
-			try:
-				sub = tokens
-				tokens = stack.pop()
-				if tokens:
-					tokens[-1][2] = sub
-				level -= 1
-			except:
-				print( "Tokenizer error at or before line %d" % lineNo )
-				print( line )
-				dummy = stack.pop()
-		elif lineSplit[-1] == ';':
-			if lineSplit[0] == '\\':
-				key = lineSplit[1]
-				tokens.append([key,lineSplit[2:-1],[]])
-			else:
-				key = lineSplit[0]
-				tokens.append([key,lineSplit[1:-1],[]])
-		else:
-			key = lineSplit[0]
-			tokens.append([key,lineSplit[1:],[]])
-			stack.append(tokens)
-			level += 1
-			tokens = []
-	file.close()
+    file= open(fileName, "rU")
+    print( "Tokenizing" )
+    lineNo = 0
+    for line in file: 
+        # print(line)
+        lineSplit= line.split()
+        lineNo += 1
+        if len(lineSplit) == 0:
+            pass
+        elif lineSplit[0][0] == '#':
+            if lineSplit[0] == '#if':
+                if comment == nesting:
+                    try:
+                        res = eval(lineSplit[1])
+                    except:
+                        res = False
+                    if res:
+                        comment += 1
+                nesting += 1
+            elif lineSplit[0] == '#else':
+                if comment == nesting-1:
+                    comment += 1
+                elif comment == nesting:
+                    comment -= 1
+            elif lineSplit[0] == '#endif':
+                if comment == nesting:
+                    comment -= 1
+                nesting -= 1
+        elif comment < nesting:
+            pass

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list