[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1607] trunk/py/scripts/addons: few update. export check log.

John Phan darkneter at gmail.com
Tue Feb 15 17:39:36 CET 2011


Revision: 1607
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1607
Author:   darknet
Date:     2011-02-15 16:39:35 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
few update. export check log.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_export_unreal_psk_psa.py
    trunk/py/scripts/addons/io_import_scene_unreal_psk.py

Modified: trunk/py/scripts/addons/io_export_unreal_psk_psa.py
===================================================================
--- trunk/py/scripts/addons/io_export_unreal_psk_psa.py	2011-02-15 14:15:13 UTC (rev 1606)
+++ trunk/py/scripts/addons/io_export_unreal_psk_psa.py	2011-02-15 16:39:35 UTC (rev 1607)
@@ -19,7 +19,7 @@
     "name": "Export Skeleletal Mesh/Animation Data",
     "author": "Darknet/Optimus_P-Fat/Active_Trash/Sinsoft",
     "version": (2, 0),
-    "blender": (2, 5, 3),
+    "blender": (2, 5, 6),
     "api": 31847,
     "location": "File > Export > Skeletal Mesh/Animation Data (.psk/.psa)",
     "description": "Export Unreal Engine (.psk)",
@@ -879,7 +879,10 @@
         print (" -- Dumping Mesh Points -- LEN:",len(points.dict))
         for point in points.items():
             psk_file.AddPoint(point)
+        if len(points.dict) > 32767:
+           raise RuntimeError("Vertex point reach max limited 32767 in pack data. Your",len(points.dict))
         print (" -- Dumping Mesh Wedge -- LEN:",len(wedges.dict))
+        		
         for wedge in wedges.items():
             psk_file.AddWedge(wedge)
             
@@ -1062,8 +1065,21 @@
         bones = [x for x in current_armature.bones if not x.parent is None]
         #will ingore this part of the ocde
         """
+        if len(current_armature.bones) == 0:
+            raise RuntimeError("Warning add two bones else it will crash the unreal editor.")
+        if len(current_armature.bones) == 1:
+            raise RuntimeError("Warning add one more bone else it will crash the unreal editor.")
+		
+        mainbonecount = 0;
         for current_bone in current_armature.bones: #list the bone. #note this will list all the bones.
             if(current_bone.parent is None):
+                mainbonecount += 1
+        print("Main Bone",mainbonecount)
+        if mainbonecount > 1:
+           #print("Warning there no main bone.")
+           raise RuntimeError("There too many Main bones. Number main bones:",mainbonecount)
+        for current_bone in current_armature.bones: #list the bone. #note this will list all the bones.
+            if(current_bone.parent is None):
                 parse_bone(current_bone, psk_file, psa_file, 0, 0, current_obj.matrix_local, None)
                 break
 
@@ -1524,14 +1540,50 @@
         print(" - Too Armature Meshes!")
         print(" - Select One Armature Object Only!")
         barmature = False
+    bMeshScale = True
+    bMeshCenter = True
+    if blender_meshes[0] !=None:
+        if blender_meshes[0].scale.x == 1 and blender_meshes[0].scale.y == 1 and blender_meshes[0].scale.z == 1:
+            #print("Okay")
+            bMeshScale = True
+        else:
+            print("Error, Mesh Object not scale right should be (1,1,1).")
+            bMeshScale = False
+        if blender_meshes[0].location.x == 0 and blender_meshes[0].location.y == 0 and blender_meshes[0].location.z == 0:
+            #print("Okay")
+            bMeshCenter = True
+        else:
+            print("Error, Mesh Object not center.")
+            bMeshCenter = False
+    bArmatureScale = True
+    bArmatureCenter = True
+    if blender_armature[0] !=None:
+        if blender_armature[0].scale.x == 1 and blender_armature[0].scale.y == 1 and blender_armature[0].scale.z == 1:
+            #print("Okay")
+            bArmatureScale = True
+        else:
+            print("Error, Armature Object not scale right should be (1,1,1).")            
+            bArmatureScale = False
+        if blender_armature[0].location.x == 0 and blender_armature[0].location.y == 0 and blender_armature[0].location.z == 0:
+            #print("Okay")
+            bArmatureCenter = True
+        else:
+            print("Error, Armature Object not center.")
+            bArmatureCenter = False
+			
+		
+			
+    #print("location:",blender_armature[0].location.x)
     
-    if     (bmesh == False) or (barmature == False):
+    if (bmesh == False) or (barmature == False) or (bArmatureCenter == False) or (bArmatureScale == False)or (bMeshScale == False) or (bMeshCenter == False):
         exportmessage = "Export Fail! Check Log."
         print("=================================")
         print("= Export Fail!                  =")
         print("=================================")
     else:
         exportmessage = "Export Finish!"
+        #print("blender_armature:",dir(blender_armature[0]))
+        #print(blender_armature[0].scale)
         #need to build a temp bone index for mesh group vertex
         BoneIndexArmature(blender_armature)
 
@@ -1649,6 +1701,11 @@
 bpy.types.Scene.unrealactionexportall = BoolProperty(
     name="All Actions",
     description="This let you export all the actions from current armature that matches bone name in action groups names.",
+    default=False)
+
+bpy.types.Scene.unrealdisplayactionsets = BoolProperty(
+    name="Show Action Set(s)",
+    description="Display Action Sets Information.",
     default=False)    
     
 bpy.types.Scene.unrealexportpsk = BoolProperty(
@@ -1727,6 +1784,44 @@
         layout.prop(rd.render, "fps")
         
         layout.prop(rd, "unrealactionexportall")
+        layout.prop(rd, "unrealdisplayactionsets")
+        #print("unrealdisplayactionsets:",rd.unrealdisplayactionsets)
+        if rd.unrealdisplayactionsets:
+            layout.label(text="Total Action Set(s):" + str(len(bpy.data.actions)))
+		    #armature data
+            amatureobject = None
+            bonenames = [] #bone name of the armature bones list 
+            #layout.label(text="object(s):" + str(len(bpy.data.objects)))
+            
+            for obj in bpy.data.objects:
+                if obj.type == 'ARMATURE' and obj.select == True:
+                    #print(dir(obj))
+                    amatureobject = obj
+                    break
+                elif obj.type == 'ARMATURE':
+                    amatureobject = obj
+        
+            if amatureobject != None:
+                layout.label(text="Armature: " + amatureobject.name)
+                #print("Armature:",amatureobject.name)
+                boxactionset = layout.box()
+                for bone in amatureobject.pose.bones:
+                    bonenames.append(bone.name)
+                actionsetmatchcount = 0	
+                for ActionNLA in bpy.data.actions:
+                    nobone = 0
+                    for group in ActionNLA.groups:	
+                        for abone in bonenames:
+                            #print("name:>>",abone)
+                            if abone == group.name:
+                                nobone += 1
+                                break
+                    if (len(ActionNLA.groups) == len(bonenames)) and (nobone == len(ActionNLA.groups)):
+                        actionsetmatchcount += 1
+                        #print("Action Set match: Pass")
+                        boxactionset.label(text="Action Name: " + ActionNLA.name)
+                layout.label(text="Match Found: " + str(actionsetmatchcount))
+		
         #row = layout.row()
         #row.label(text="Action Set(s)(not build)")
         #for action in  bpy.data.actions:

Modified: trunk/py/scripts/addons/io_import_scene_unreal_psk.py
===================================================================
--- trunk/py/scripts/addons/io_import_scene_unreal_psk.py	2011-02-15 14:15:13 UTC (rev 1606)
+++ trunk/py/scripts/addons/io_import_scene_unreal_psk.py	2011-02-15 16:39:35 UTC (rev 1607)
@@ -361,6 +361,7 @@
                 break
 				
         if bfound == False:
+            '''
             armdata = bpy.data.armatures.new(objectname)
             ob_new = bpy.data.objects.new(meshname, armdata)
             #ob_new = bpy.data.objects.new(meshname, 'ARMATURE')
@@ -381,6 +382,29 @@
                 #print(dir(bone))
                 bpy.ops.object.mode_set(mode='EDIT')
                 newbone = ob_new.data.edit_bones.new(bone.name)
+            '''		
+		
+            
+            armdata = bpy.data.armatures.new(objectname)
+            ob_new = bpy.data.objects.new(meshname, armdata)
+            #ob_new = bpy.data.objects.new(meshname, 'ARMATURE')
+            #ob_new.data = armdata
+            bpy.context.scene.objects.link(ob_new)
+            #bpy.ops.object.mode_set(mode='OBJECT')
+            for i in bpy.context.scene.objects: i.select = False #deselect all objects
+            ob_new.select = True
+            #set current armature to edit the bone
+            bpy.context.scene.objects.active = ob_new
+            #set mode to able to edit the bone
+            bpy.ops.object.mode_set(mode='EDIT')
+			
+            #newbone = ob_new.data.edit_bones.new('test')
+            #newbone.tail.y = 1
+            print("creating bone(s)")
+            for bone in md5_bones:
+                #print(dir(bone))
+                bpy.ops.object.mode_set(mode='EDIT')
+                newbone = ob_new.data.edit_bones.new(bone.name)
                 #parent the bone
                 parentbone = None
                 print("bone name:",bone.name)
@@ -396,8 +420,8 @@
                     newbone.parent = parentbone
                     rotmatrix = bone.bindmat.to_matrix().to_4x4().to_3x3()  # XXX, redundant matrix conversion?
 					
-                    #parent_head = parentbone.head * parentbone.matrix.to_quaternion().inverted()
-                    #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverted()
+                    #parent_head = parentbone.head * parentbone.matrix.to_quaternion().inverse()
+                    #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse()
                     #location=Vector(pos_x,pos_y,pos_z)
                     #set_position = (parent_tail - parent_head) + location
                     #print("tmp head:",set_position)
@@ -414,9 +438,10 @@
                     newbone.tail.y = parentbone.head.y + (pos_y + bonesize * rotmatrix[1][1])
                     newbone.tail.z = parentbone.head.z + (pos_z + bonesize * rotmatrix[1][2])
                 else:
-                    #print("rotmatrix:",dir(bone.bindmat.to_matrix().resize_4x4()))
+                    print("rotmatrix:",dir(bone.bindmat.to_matrix().resize_4x4()))
                     #rotmatrix = bone.bindmat.to_matrix().resize_4x4().to_3x3()  # XXX, redundant matrix conversion?

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list