[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4006] trunk/py/scripts/addons/ io_export_unreal_psk_psa.py: update menu panel for export.

John Phan darkneter at gmail.com
Mon Nov 26 02:09:09 CET 2012


Revision: 4006
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4006
Author:   darknet
Date:     2012-11-26 01:09:03 +0000 (Mon, 26 Nov 2012)
Log Message:
-----------
update menu panel for export.

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

Modified: trunk/py/scripts/addons/io_export_unreal_psk_psa.py
===================================================================
--- trunk/py/scripts/addons/io_export_unreal_psk_psa.py	2012-11-26 00:59:17 UTC (rev 4005)
+++ trunk/py/scripts/addons/io_export_unreal_psk_psa.py	2012-11-26 01:09:03 UTC (rev 4006)
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "Export Unreal Engine Format(.psk/.psa)",
     "author": "Darknet/Optimus_P-Fat/Active_Trash/Sinsoft/VendorX/Spoof",
-    "version": (2, 5),
+    "version": (2, 6),
     "blender": (2, 6, 3),
     "api": 36079,
     "location": "File > Export > Skeletal Mesh/Animation Data (.psk/.psa)",
@@ -139,7 +139,7 @@
 """
 #===========================================================================
 
-
+import bmesh
 import os
 import time
 import bpy
@@ -148,10 +148,9 @@
 import random
 import operator
 import sys
-
+from bpy.props import *
 from struct import pack
 
-
 # REFERENCE MATERIAL JUST IN CASE:
 # 
 # U = x / sqrt(x^2 + y^2 + z^2)
@@ -185,7 +184,6 @@
 	def __init__(self, message):
 		self.message = message
 
-
 #===========================================================================
 # Verbose logging with loop truncation
 #===========================================================================
@@ -201,7 +199,6 @@
 
 		print(msg)
 	
-
 #===========================================================================
 # Log header/separator
 #===========================================================================
@@ -218,7 +215,6 @@
 	
 	return "\n" + s + "\n"
 
-
 #===========================================================================
 # Generic Object->Integer mapping
 # the object must be usable as a dictionary key
@@ -243,7 +239,6 @@
 		getkey = operator.itemgetter(1)
 		return map(getval, sorted(self.dict.items(), key=getkey))
 
-
 #===========================================================================
 # RG - UNREAL DATA STRUCTS - CONVERTED FROM C STRUCTS GIVEN ON UDN SITE 
 # provided here: http://udn.epicgames.com/Two/BinaryFormatSpecifications.html
@@ -272,7 +267,6 @@
 	def __str__(self):
 		return "[%f,%f,%f,%f](FQuat)" % (self.X, self.Y, self.Z, self.W)
 
-
 class FVector(object):
 
 	def __init__(self, X=0.0, Y=0.0, Z=0.0):
@@ -312,7 +306,6 @@
 			self.Y - other.Y,
 			self.Z - other.Z)
 
-
 class VJointPos:
 
 	def __init__(self):
@@ -326,7 +319,6 @@
 	def dump(self):
 		return self.Orientation.dump() + self.Position.dump() + pack('4f', self.Length, self.XSize, self.YSize, self.ZSize)
 
-
 class AnimInfoBinary:
 
 	def __init__(self):
@@ -346,7 +338,6 @@
 	def dump(self):
 		return pack('64s64siiiifffiii', str.encode(self.Name), str.encode(self.Group), self.TotalBones, self.RootInclude, self.KeyCompressionStyle, self.KeyQuotum, self.KeyPrediction, self.TrackTime, self.AnimRate, self.StartBone, self.FirstRawFrame, self.NumRawFrames)
 
-
 class VChunkHeader:
 
 	def __init__(self, name, type_size):
@@ -358,7 +349,6 @@
 	def dump(self):
 		return pack('20siii', self.ChunkID, self.TypeFlag, self.DataSize, self.DataCount)
 
-
 class VMaterial:
 
 	def __init__(self):
@@ -374,7 +364,6 @@
 		#print("DATA MATERIAL:",self.MaterialName)
 		return pack('64siLiLii', str.encode(self.MaterialName), self.TextureIndex, self.PolyFlags, self.AuxMaterial, self.AuxFlags, self.LodBias, self.LodStyle)
 
-
 class VBone:
 
 	def __init__(self):
@@ -387,7 +376,6 @@
 	def dump(self):
 		return pack('64sLii', str.encode(self.Name), self.Flags, self.NumChildren, self.ParentIndex) + self.BonePos.dump()
 
-
 #same as above - whatever - this is how Epic does it...	 
 class FNamedBoneBinary:
 
@@ -402,7 +390,6 @@
 	def dump(self):
 		return pack('64sLii', str.encode(self.Name), self.Flags, self.NumChildren, self.ParentIndex) + self.BonePos.dump()
 
-
 class VRawBoneInfluence:
 
 	def __init__(self):
@@ -413,7 +400,6 @@
 	def dump(self):
 		return pack('fii', self.Weight, self.PointIndex, self.BoneIndex)
 
-
 class VQuatAnimKey:
 
 	def __init__(self):
@@ -424,7 +410,6 @@
 	def dump(self):
 		return self.Position.dump() + self.Orientation.dump() + pack('f', self.Time)
 
-
 class VVertex(object):
 
 	def __init__(self):
@@ -457,7 +442,6 @@
 			return False
 		return self._key() == other._key()
 
-
 class VPointSimple:
 
 	def __init__(self):
@@ -477,7 +461,6 @@
 			return False
 		return self._key() == other._key()
 
-
 class VPoint(object):
 
 	def __init__(self):
@@ -503,7 +486,6 @@
 			return False
 		return self._key() == other._key() 
 
-
 class VTriangle:
 
 	def __init__(self):
@@ -520,7 +502,6 @@
 # END UNREAL DATA STRUCTS
 #===========================================================================
 
-
 #===========================================================================
 # RG - helper class to handle the normal way the UT files are stored 
 # as sections consisting of a header and then a list of data structures
@@ -540,7 +521,6 @@
 	def UpdateHeader(self):
 		self.Header.DataCount = len(self.Data)
 
-
 #===========================================================================
 # PSK
 #===========================================================================
@@ -619,7 +599,6 @@
 		print( "{:>16} {:}".format( "Bones", len(self.Bones.Data) ) )
 		print( "{:>16} {:}".format( "Influences", len(self.Influences.Data) ) )
 
-
 #===========================================================================
 # PSA
 #
@@ -701,7 +680,6 @@
 		print( "{:>16} {:}".format( "Animations", len(self.Animations.Data) ) )
 		print( "{:>16} {:}".format( "Raw keys", len(self.RawKeys.Data) ) )
 
-
 #===========================================================================
 # Helpers to create bone structs
 #===========================================================================
@@ -751,7 +729,6 @@
 	quat.W  = bquat.w
 	return quat
 
-
 #===========================================================================
 #RG - check to make sure face isnt a line
 #===========================================================================
@@ -766,7 +743,6 @@
 		or mesh.vertices[v2].co == mesh.vertices[v0].co)
 	return False
 
-
 #===========================================================================
 # Smoothing group
 # (renamed to seperate it from VVertex.SmoothGroup)
@@ -819,7 +795,6 @@
 		if not face in self.faces:
 			self.faces.append( face )
 
-
 def determine_edge_sharing( mesh ):
 	
 	edge_sharing_list = dict()
@@ -834,7 +809,6 @@
 	
 	return edge_sharing_list
 
-
 def find_edges( mesh, key ):
 	"""	Temp replacement for mesh.findEdges().
 		This is painfully slow.
@@ -844,7 +818,6 @@
 		if key[0] == v[0] and key[1] == v[1]:
 			return edge.index
 
-
 def add_face_to_smoothgroup( mesh, face, edge_sharing_list, smoothgroup ):
 	
 	if face in smoothgroup.faces:
@@ -871,7 +844,6 @@
 					if shared_face != face:
 						smoothgroup.add_neighbor_face( shared_face )
 
-
 def determine_smoothgroup_for_face( mesh, face, edge_sharing_list, smoothgroup_list ):
 	
 	for group in smoothgroup_list:
@@ -884,7 +856,6 @@
 	if not smoothgroup in smoothgroup_list:
 		smoothgroup_list.append( smoothgroup )
 
-
 def build_neighbors_tree( smoothgroup_list ):
 
 	for group in smoothgroup_list:
@@ -894,7 +865,6 @@
 					group.make_neighbor( neighbor_group )
 					neighbor_group.make_neighbor( group )
 
-
 #===========================================================================
 # parse_smooth_groups
 #===========================================================================
@@ -929,7 +899,6 @@
 	print("Smooth group parsing completed in {:.2f}s".format(time.clock() - t))
 	return smoothgroup_list
 
-
 #===========================================================================
 # http://en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python/Cookbook#Triangulate_NMesh
 # blender 2.50 format using the Operators/command convert the mesh to tri mesh
@@ -1323,7 +1292,6 @@
 		bpy.ops.object.mode_set(mode='OBJECT')	  # OBJECT mode
 		mesh.parent = None						  # unparent to avoid phantom links
 		bpy.context.scene.objects.unlink(mesh)	  # unlink
-		
 
 #===========================================================================
 # Collate bones that belong to the UDK skeletal mesh
@@ -1361,7 +1329,6 @@
 	# this is passed to parse_animation instead of working from keyed bones in the action
 	return udk_bones
 
-
 #===========================================================================
 # bone				current bone
 # bones				bone list
@@ -1430,12 +1397,10 @@
 	for child_bone in bone.children:
 		recurse_bone(child_bone, bones, psk, psa, bone_id, parent_matrix, " "+indent)
 
-
 # FIXME rename? remove?
 class BoneUtil:
 	static_bone_id = 0 # static property to replace global
 
-
 #===========================================================================
 # armature			the armature
 # udk_bones			list of bones to be exported
@@ -1469,7 +1434,19 @@
 		if not len(action.fcurves):
 			print("{} has no keys, skipping".format(action.name))
 			continue
-		
+		'''
+		if bpy.context.scene.udk_option_selectanimations:
+			print("Action Set is selected!")
+			bready = False
+			for actionlist in bpy.context.scene.udkas_list:
+				if actionlist.name == action.name and actionlist.bmatch == True and actionlist.bexport == True:
+					bready = True
+					print("Added Action Set:",action.name)
+					break
+			if bready == False:#don't export it
+				print("Skipping Action Set:",action.name)
+				continue
+		'''
 		# apply action to armature and update scene
 		armature.animation_data.action = action
 		context.scene.update()
@@ -1568,7 +1545,6 @@
 	armature.animation_data.action = restoreAction
 	context.scene.frame_set(restoreFrame)
 
-
 #===========================================================================
 # Collate actions to be exported
 # Modify this to filter for one, some or all actions. For now use all.
@@ -1579,13 +1555,22 @@
 	actions_to_export = []
 	
 	for action in bpy.data.actions:
-		
+		if bpy.context.scene.udk_option_selectanimations:
+			print("Action Set is selected!")
+			bready = False
+			for actionlist in bpy.context.scene.udkas_list:
+				if actionlist.name == action.name and actionlist.bmatch == True and actionlist.bexport == True:
+					bready = True
+					print("Added Action Set:",action.name)
+					break
+			if bready == False:#don't export it
+				print("Skipping Action Set:",action.name)
+				continue
 		verbose(" + {}".format(action.name))
 		actions_to_export.append(action)
 	
 	return actions_to_export
 
-
 #===========================================================================
 # Locate the target armature and mesh for export

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list