[Bf-extensions-cvs] [766887ce] master: Export Unreal Engine Format: Update panel Rename, cleanup, fixes

lijenstina noreply at git.blender.org
Sun Jul 16 15:36:50 CEST 2017


Commit: 766887ce0c1f46dfcf0ca47df27b9f638bb0952e
Author: lijenstina
Date:   Sun Jul 16 15:36:10 2017 +0200
Branches: master
https://developer.blender.org/rBA766887ce0c1f46dfcf0ca47df27b9f638bb0952e

Export Unreal Engine Format: Update panel Rename, cleanup, fixes

Bumped version to 2.7.1
As a part of the task T50726:
Update the Panel rename code to more generic one
Pep8 cleanup
Replace star imports
Consistent property definitions
Update wiki link
move the register of properties and collections
to register function, proper removal on unregister
Refactor the exporter as it assigned the operator
properties from the scene ones
cmp is deprecated in Python 3.x

===================================================================

M	io_export_unreal_psk_psa.py

===================================================================

diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py
index 7ecef29b..ca22ca46 100644
--- a/io_export_unreal_psk_psa.py
+++ b/io_export_unreal_psk_psa.py
@@ -1,4 +1,4 @@
-#====================== BEGIN GPL LICENSE BLOCK ============================
+# ##### BEGIN GPL LICENSE BLOCK #####
 #
 #  This program is free software: you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -14,17 +14,17 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #  All rights reserved.
 #
-#======================= END GPL LICENSE BLOCK =============================
+# ##### END GPL LICENSE BLOCK #####
 
 bl_info = {
     "name": "Export Unreal Engine Format(.psk/.psa)",
     "author": "Darknet/Optimus_P-Fat/Active_Trash/Sinsoft/VendorX/Spoof",
-    "version": (2, 7),
+    "version": (2, 7, 1),
     "blender": (2, 65, 4),
     "location": "File > Export > Skeletal Mesh/Animation Data (.psk/.psa)",
     "description": "Export Skeleletal Mesh/Animation Data",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Import-Export/Unreal_psk_psa",
     "category": "Import-Export",
 }
@@ -47,7 +47,8 @@ bl_info = {
 - This will work on UT3 and it is a stable version that work with vehicle for testing.
 - Main Bone fix no dummy needed to be there.
 - Just bone issues position, rotation, and offset for psk.
-- The armature bone position, rotation, and the offset of the bone is fix. It was to deal with skeleton mesh export for psk.
+- The armature bone position, rotation, and the offset of the bone is fix.
+  It was to deal with skeleton mesh export for psk.
 - Animation is fix for position, offset, rotation bone support one rotation direction when armature build.
 - It will convert your mesh into triangular when exporting to psk file.
 - Did not work with psa export yet.
@@ -78,7 +79,7 @@ Credit to:
 """
 
 
-#===========================================================================
+# ===========================================================================
 """
 NOTES for Jan 2012 refactor (Spoof)
 
@@ -135,7 +136,7 @@ deformer bones (bad for optimising a game character). I had partial success
 writing a parser for the structure, but it was taking too much time and,
 considering the other issues with Rigify, it was abandoned.
 """
-#===========================================================================
+# ===========================================================================
 
 import bmesh
 import os
@@ -143,12 +144,26 @@ import time
 import bpy
 import mathutils
 import math
-import random
 import operator
 import sys
-from bpy.props import *
+from bpy.props import (
+        BoolProperty,
+        CollectionProperty,
+        EnumProperty,
+        FloatProperty,
+        IntProperty,
+        StringProperty,
+        )
+from bpy.types import (
+        Operator,
+        Panel,
+        UIList,
+        PropertyGroup,
+        AddonPreferences,
+        )
 from struct import pack
 
+
 # REFERENCE MATERIAL JUST IN CASE:
 #
 # U = x / sqrt(x^2 + y^2 + z^2)
@@ -157,36 +172,43 @@ from struct import pack
 # Triangles specifed counter clockwise for front face
 #
 # defines for sizeofs
-SIZE_FQUAT              = 16
-SIZE_FVECTOR            = 12
-SIZE_VJOINTPOS          = 44
-SIZE_ANIMINFOBINARY     = 168
-SIZE_VCHUNKHEADER       = 32
-SIZE_VMATERIAL          = 88
-SIZE_VBONE              = 120
-SIZE_FNAMEDBONEBINARY   = 120
-SIZE_VRAWBONEINFLUENCE  = 12
-SIZE_VQUATANIMKEY       = 32
-SIZE_VVERTEX            = 16
-SIZE_VPOINT             = 12
-SIZE_VTRIANGLE          = 12
-
-MaterialName            = []
-
-#===========================================================================
+SIZE_FQUAT = 16
+SIZE_FVECTOR = 12
+SIZE_VJOINTPOS = 44
+SIZE_ANIMINFOBINARY = 168
+SIZE_VCHUNKHEADER = 32
+SIZE_VMATERIAL = 88
+SIZE_VBONE = 120
+SIZE_FNAMEDBONEBINARY = 120
+SIZE_VRAWBONEINFLUENCE = 12
+SIZE_VQUATANIMKEY = 32
+SIZE_VVERTEX = 16
+SIZE_VPOINT = 12
+SIZE_VTRIANGLE = 12
+
+MaterialName = []
+
+
+# Python 3 doesn't have cmp anymore
+def cmp(a, b):
+    return (a > b) - (a < b)
+
+
+# ===========================================================================
 # Custom exception class
-#===========================================================================
-class Error( Exception ):
+# ===========================================================================
+class Error(Exception):
 
     def __init__(self, message):
         self.message = message
 
-#===========================================================================
+
+# ===========================================================================
 # Verbose logging with loop truncation
-#===========================================================================
-def verbose( msg, iteration=-1, max_iterations=4, msg_truncated="..." ):
+# ===========================================================================
+def verbose(msg, iteration=-1, max_iterations=4, msg_truncated="..."):
 
-    if bpy.context.scene.udk_option_verbose == True:
+    if bpy.context.scene.udk_option_verbose is True:
         # limit the number of times a loop can output messages
         if iteration > max_iterations:
             return
@@ -196,26 +218,28 @@ def verbose( msg, iteration=-1, max_iterations=4, msg_truncated="..." ):
 
         print(msg)
 
-#===========================================================================
+
+# ===========================================================================
 # Log header/separator
-#===========================================================================
-def header( msg, justify='LEFT', spacer='_', cols=78 ):
+# ===========================================================================
+def header(msg, justify='LEFT', spacer='_', cols=78):
 
     if justify == 'LEFT':
-        s = '{:{spacer}<{cols}}'.format(msg+" ", spacer=spacer, cols=cols)
+        s = '{:{spacer}<{cols}}'.format(msg + " ", spacer=spacer, cols=cols)
 
     elif justify == 'RIGHT':
-        s = '{:{spacer}>{cols}}'.format(" "+msg, spacer=spacer, cols=cols)
+        s = '{:{spacer}>{cols}}'.format(" " + msg, spacer=spacer, cols=cols)
 
     else:
-        s = '{:{spacer}^{cols}}'.format(" "+msg+" ", spacer=spacer, cols=cols)
+        s = '{:{spacer}^{cols}}'.format(" " + msg + " ", spacer=spacer, cols=cols)
 
     return "\n" + s + "\n"
 
-#===========================================================================
+
+# ===========================================================================
 # Generic Object->Integer mapping
 # the object must be usable as a dictionary key
-#===========================================================================
+# ===========================================================================
 class ObjMap:
 
     def __init__(self):
@@ -236,11 +260,12 @@ class ObjMap:
         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
 # updated UDK (Unreal Engine 3): http://udn.epicgames.com/Three/BinaryFormatSpecifications.html
-#===========================================================================
+# ===========================================================================
 class FQuat:
 
     def __init__(self):
@@ -253,10 +278,10 @@ class FQuat:
         return pack('ffff', self.X, self.Y, self.Z, self.W)
 
     def __cmp__(self, other):
-        return cmp(self.X, other.X) \
-            or cmp(self.Y, other.Y) \
-            or cmp(self.Z, other.Z) \
-            or cmp(self.W, other.W)
+        return cmp(self.X, other.X) or \
+               cmp(self.Y, other.Y) or \
+               cmp(self.Z, other.Z) or \
+               cmp(self.W, other.W)
 
     def __hash__(self):
         return hash(self.X) ^ hash(self.Y) ^ hash(self.Z) ^ hash(self.W)
@@ -264,6 +289,7 @@ class FQuat:
     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):
@@ -275,9 +301,9 @@ class FVector(object):
         return pack('fff', self.X, self.Y, self.Z)
 
     def __cmp__(self, other):
-        return cmp(self.X, other.X) \
-            or cmp(self.Y, other.Y) \
-            or cmp(self.Z, other.Z)
+        return cmp(self.X, other.X) or \
+               cmp(self.Y, other.Y) or \
+               cmp(self.Z, other.Z)
 
     def _key(self):
         return (type(self).__name__, self.X, self.Y, self.Z)
@@ -303,130 +329,146 @@ class FVector(object):
             self.Y - other.Y,
             self.Z - other.Z)
 
+
 class VJointPos:
 
     def __init__(self):
-        self.Orientation    = FQuat()
-        self.Position       = FVector()
-        self.Length         = 0.0
-        self.XSize          = 0.0
-        self.YSize          = 0.0
-        self.ZSize          = 0.0
+        self.Orientation = FQuat()
+        self.Position = FVector()
+        self.Length = 0.0
+        self.XSize = 0.0
+        self.YSize = 0.0
+        self.ZSize = 0.0
 
     def dump(self):
-        return self.Orientation.dump() + self.Position.dump() + pack('4f', self.Length, self.XSize, self.YSize, self.ZSize)
+        return self.Orientation.dump() + self.Position.dump() + \
+               pack('4f', self.Length, self.XSize, self.YSize, self.ZSize)
+
 
 class AnimInfoBinary:
 
     def __init__(self):
-        self.Name           = ""    # length=64
-        self.Group          = ""    # length=64
-        self.TotalBones     = 0
-        self.RootInclude    = 0
+        self.Name = ""      # length=64
+        self.Group = ""     # length=64
+        self.TotalBones = 0
+        self.RootInclude = 0
         self.KeyCompressionStyle = 0
-        self.KeyQuotum      = 0
-        self.KeyPrediction  = 0.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list