Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-08-01 16:52:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-01 16:52:09 +0400
commitaf88ccbfee8149971096a8af7e9af191548de819 (patch)
treef37b0525dc1a93d22baea676e917833480f6169c /io_scene_fbx
parentb40f3249428fe2dd3b829d6249cef7b730a91a83 (diff)
rename operator properties and make __init__ file pep8-80 compliant.
Diffstat (limited to 'io_scene_fbx')
-rw-r--r--io_scene_fbx/__init__.py129
-rw-r--r--io_scene_fbx/export_fbx.py34
2 files changed, 110 insertions, 53 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 8e3c6a23..60208db0 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
-# <pep8 compliant>
+# <pep8-80 compliant>
bl_info = {
"name": "Autodesk FBX format",
@@ -24,7 +24,8 @@ bl_info = {
"blender": (2, 5, 8),
"api": 38691,
"location": "File > Import-Export",
- "description": "Export FBX meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
+ "description": ("Export FBX meshes, UV's, vertex colors, materials, "
+ "textures, cameras, lamps and actions"),
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
"Scripts/Import-Export/Autodesk_FBX",
@@ -32,7 +33,7 @@ bl_info = {
"support": 'OFFICIAL',
"category": "Import-Export"}
-# To support reload properly, try to access a package var, if it's there, reload everything
+
if "bpy" in locals():
import imp
if "export_fbx" in locals():
@@ -61,10 +62,19 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
- use_selection = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=False)
- # XNA does not support scaled armatures (JCB)
- global_scale = FloatProperty(name="Scale", description="Scale all data. Some importers do not support scaled armatures!", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
-
+ use_selection = BoolProperty(
+ name="Selected Objects",
+ description="Export selected objects on visible layers",
+ default=False,
+ )
+ global_scale = FloatProperty(
+ name="Scale",
+ description=("Scale all data. "
+ "Some importers do not support scaled armatures!"),
+ min=0.01, max=1000.0,
+ soft_min=0.01, soft_max=1000.0,
+ default=1.0,
+ )
axis_forward = EnumProperty(
name="Forward",
items=(('X', "X Forward", ""),
@@ -76,7 +86,6 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
),
default='-Z',
)
-
axis_up = EnumProperty(
name="Up",
items=(('X', "X Up", ""),
@@ -101,8 +110,11 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH'},
)
- mesh_apply_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to mesh objects", default=True)
-
+ use_mesh_modifiers = BoolProperty(
+ name="Apply Modifiers",
+ description="Apply modifiers to mesh objects",
+ default=True,
+ )
mesh_smooth_type = EnumProperty(
name="Smoothing",
items=(('OFF', "Off", "Don't write smoothing"),
@@ -112,22 +124,45 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
default='FACE',
)
- # XNA does not use the edge information (JCB)
- use_edges = BoolProperty(name="Include Edges", description="Edges may not be necessary and can cause errors with some importers!", default=False)
-# EXP_MESH_HQ_NORMALS = BoolProperty(name="HQ Normals", description="Generate high quality normals", default=True)
- # armature animation
- ANIM_ENABLE = BoolProperty(name="Include Animation", description="Export keyframe animation", default=True)
- ANIM_ACTION_ALL = BoolProperty(name="All Actions", description="Export all actions for armatures or just the currently selected action", default=True)
- ANIM_OPTIMIZE = BoolProperty(name="Optimize Keyframes", description="Remove double keyframes", default=True)
- ANIM_OPTIMIZE_PRECISSION = FloatProperty(name="Precision", description="Tolerence for comparing double keyframes (higher for greater accuracy)", min=1, max=16, soft_min=1, soft_max=16, default=6.0)
- # XNA needs different names for each take having the first one always called Default_Take is unhelpful (JCB)
- # XNA usually errors if the textures are not in the same folder as the FBX file (JCB)
- # XNA - validation to avoid incompatible settings. I will understand if this is not kept in the generic version. (JCB)
- # It would be nice to have this for XNA, UDK, Unity and Sunburn if others could provide the details. (JCB)
- xna_validate = BoolProperty(name="XNA Strict Options", description="Make sure options are compatible with Microsoft XNA", default=False)
- # The armature rotation does not work for XNA and setting the global matrix to identity is not sufficient on its own (JCB)
- use_rotate_workaround = BoolProperty(name="XNA Rotate Fix", description="Disable global rotation, for XNA compatibility", default=False)
-
+ use_mesh_edges = BoolProperty(
+ name="Include Edges",
+ description="Edges may not be necessary causes errors with XNA",
+ default=False,
+ )
+ use_anim = BoolProperty(
+ name="Include Animation",
+ description="Export keyframe animation",
+ default=True,
+ )
+ use_anim_action_all = BoolProperty(
+ name="All Actions",
+ description=("Export all actions for armatures or just the "
+ "currently selected action"),
+ default=True,
+ )
+ use_anim_optimize = BoolProperty(
+ name="Optimize Keyframes",
+ description="Remove double keyframes",
+ default=True,
+ )
+ anim_optimize_precission = FloatProperty(
+ name="Precision",
+ description=("Tolerence for comparing double keyframes "
+ "(higher for greater accuracy)"),
+ min=1, max=16,
+ soft_min=1, soft_max=16,
+ default=6.0,
+ )
+ xna_validate = BoolProperty(
+ name="XNA Strict Options",
+ description="Make sure options are compatible with Microsoft XNA",
+ default=False,
+ )
+ use_rotate_workaround = BoolProperty(
+ name="XNA Rotate Fix",
+ description="Disable global rotation, for XNA compatibility",
+ default=False,
+ )
batch_mode = EnumProperty(
name="Batch Mode",
items=(('OFF', "Off", "Active scene to file"),
@@ -135,9 +170,16 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
('GROUP', "Group", "Each group as a file"),
),
)
-
- BATCH_OWN_DIR = BoolProperty(name="Own Dir", description="Create a dir for each exported file", default=True)
- use_metadata = BoolProperty(name="Use Metadata", default=True, options={'HIDDEN'})
+ use_batch_own_dir = BoolProperty(
+ name="Own Dir",
+ description="Create a dir for each exported file",
+ default=True,
+ )
+ use_metadata = BoolProperty(
+ name="Use Metadata",
+ default=True,
+ options={'HIDDEN'},
+ )
path_mode = path_reference_mode
@@ -153,10 +195,10 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
changed = True
self.global_scale = 1.0
self.mesh_smooth_type = 'OFF'
- if self.ANIM_OPTIMIZE or self.use_edges:
+ if self.ANIM_OPTIMIZE or self.use_mesh_edges:
changed = True
self.ANIM_OPTIMIZE = False
- self.use_edges = False
+ self.use_mesh_edges = False
if self.object_types & {'CAMERA', 'LAMP', 'EMPTY'}:
changed = True
self.object_types -= {'CAMERA', 'LAMP', 'EMPTY'}
@@ -168,7 +210,9 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
def check(self, context):
is_xna_change = self._validate_xna_options()
- is_axis_change = axis_conversion_ensure(self, "axis_forward", "axis_up")
+ is_axis_change = axis_conversion_ensure(self,
+ "axis_forward",
+ "axis_up")
if is_xna_change or is_axis_change:
return True
else:
@@ -179,13 +223,26 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
if not self.filepath:
raise Exception("filepath not set")
- # Armature rotation causes a mess in XNA there are also other changes in the main script to avoid rotation (JCB)
global_matrix = Matrix()
- global_matrix[0][0] = global_matrix[1][1] = global_matrix[2][2] = self.global_scale
+
+ global_matrix[0][0] = \
+ global_matrix[1][1] = \
+ global_matrix[2][2] = self.global_scale
+
if not self.use_rotate_workaround:
- global_matrix = global_matrix * axis_conversion(to_forward=self.axis_forward, to_up=self.axis_up).to_4x4()
+ global_matrix = (global_matrix *
+ axis_conversion(to_forward=self.axis_forward,
+ to_up=self.axis_up,
+ ).to_4x4())
+
+ keywords = self.as_keywords(ignore=("axis_forward",
+ "axis_up",
+ "global_scale",
+ "check_existing",
+ "filter_glob",
+ "xna_validate",
+ ))
- keywords = self.as_keywords(ignore=("axis_forward", "axis_up", "global_scale", "check_existing", "filter_glob", "xna_validate"))
keywords["global_matrix"] = global_matrix
from . import export_fbx
diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py
index ce64ebee..9932c09e 100644
--- a/io_scene_fbx/export_fbx.py
+++ b/io_scene_fbx/export_fbx.py
@@ -194,15 +194,15 @@ def save_single(operator, scene, filepath="",
global_matrix=None,
context_objects=None,
object_types={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH'},
- mesh_apply_modifiers=True,
+ use_mesh_modifiers=True,
mesh_smooth_type='FACE',
- ANIM_ENABLE=True,
- ANIM_OPTIMIZE=True,
- ANIM_OPTIMIZE_PRECISSION=6,
- ANIM_ACTION_ALL=False,
+ use_anim=True,
+ use_anim_optimize=True,
+ anim_optimize_precission=6,
+ use_anim_action_all=False,
use_metadata=True,
path_mode='AUTO',
- use_edges=True,
+ use_mesh_edges=True,
use_rotate_workaround=False,
):
@@ -1326,7 +1326,7 @@ def save_single(operator, scene, filepath="",
# convert into lists once.
me_vertices = me.vertices[:]
- me_edges = me.edges[:] if use_edges else ()
+ me_edges = me.edges[:] if use_mesh_edges else ()
me_faces = me.faces[:]
poseMatrix = write_object_props(my_mesh.blenObject, None, my_mesh.parRelMatrix())[3]
@@ -1869,7 +1869,7 @@ def save_single(operator, scene, filepath="",
origData = False
else:
# Mesh Type!
- if mesh_apply_modifiers:
+ if use_mesh_modifiers:
me = ob.to_mesh(scene, True, 'PREVIEW')
# print ob, me, me.getVertGroupNames()
@@ -1891,7 +1891,7 @@ def save_single(operator, scene, filepath="",
# del tmp_colbits
if me:
-# # This WILL modify meshes in blender if mesh_apply_modifiers is disabled.
+# # This WILL modify meshes in blender if use_mesh_modifiers is disabled.
# # so strictly this is bad. but only in rare cases would it have negative results
# # say with dupliverts the objects would rotate a bit differently
# if EXP_MESH_HQ_NORMALS:
@@ -2462,17 +2462,17 @@ Connections: {''')
start, end = end, start
# comment the following line, otherwise we dont get the pose
- # if start==end: ANIM_ENABLE = False
+ # if start==end: use_anim = False
# animations for these object types
ob_anim_lists = ob_bones, ob_meshes, ob_null, ob_cameras, ob_lights, ob_arms
- if ANIM_ENABLE and [tmp for tmp in ob_anim_lists if tmp]:
+ if use_anim and [tmp for tmp in ob_anim_lists if tmp]:
frame_orig = scene.frame_current
- if ANIM_OPTIMIZE:
- ANIM_OPTIMIZE_PRECISSION_FLOAT = 0.1 ** ANIM_OPTIMIZE_PRECISSION
+ if use_anim_optimize:
+ ANIM_OPTIMIZE_PRECISSION_FLOAT = 0.1 ** anim_optimize_precission
# default action, when no actions are avaioable
tmp_actions = []
@@ -2482,7 +2482,7 @@ Connections: {''')
# instead of tagging
tagged_actions = []
- if ANIM_ACTION_ALL:
+ if use_anim_action_all:
tmp_actions = bpy.data.actions[:]
# find which actions are compatible with the armatures
@@ -2635,7 +2635,7 @@ Takes: {''')
file.write('\n\t\t\t\t\t\tDefault: %.15f' % context_bone_anim_vecs[0][i])
file.write('\n\t\t\t\t\t\tKeyVer: 4005')
- if not ANIM_OPTIMIZE:
+ if not use_anim_optimize:
# Just write all frames, simple but in-eficient
file.write('\n\t\t\t\t\t\tKeyCount: %i' % (1 + act_end - act_start))
file.write('\n\t\t\t\t\t\tKey: ')
@@ -2820,7 +2820,7 @@ def save(operator, context,
filepath="",
use_selection=True,
batch_mode='OFF',
- BATCH_OWN_DIR=False,
+ use_batch_own_dir=False,
**kwargs
):
@@ -2858,7 +2858,7 @@ def save(operator, context,
for data in data_seq: # scene or group
newname = prefix + bpy.path.clean_name(data.name)
- if BATCH_OWN_DIR:
+ if use_batch_own_dir:
new_fbxpath = fbxpath + newname + os.sep
# path may already exist
# TODO - might exist but be a file. unlikely but should probably account for it.