[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1833] trunk/py/scripts/addons/ io_scene_fbx: fix for FBX export not referencing smoothing information, spotted by Robin Deitch (robindeitch).
Campbell Barton
ideasman42 at gmail.com
Fri Apr 15 06:51:33 CEST 2011
Revision: 1833
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1833
Author: campbellbarton
Date: 2011-04-15 04:51:32 +0000 (Fri, 15 Apr 2011)
Log Message:
-----------
fix for FBX export not referencing smoothing information, spotted by Robin Deitch (robindeitch).
Added option for smoothing export - Face/Edge/Off.
Modified Paths:
--------------
trunk/py/scripts/addons/io_scene_fbx/__init__.py
trunk/py/scripts/addons/io_scene_fbx/export_fbx.py
Modified: trunk/py/scripts/addons/io_scene_fbx/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_scene_fbx/__init__.py 2011-04-15 00:07:49 UTC (rev 1832)
+++ trunk/py/scripts/addons/io_scene_fbx/__init__.py 2011-04-15 04:51:32 UTC (rev 1833)
@@ -59,16 +59,41 @@
use_selection = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=True)
# EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
- TX_SCALE = FloatProperty(name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
- TX_XROT90 = BoolProperty(name="Rot X90", description="Rotate all objects 90 degrees about the X axis", default=True)
- TX_YROT90 = BoolProperty(name="Rot Y90", description="Rotate all objects 90 degrees about the Y axis", default=False)
- TX_ZROT90 = BoolProperty(name="Rot Z90", description="Rotate all objects 90 degrees about the Z axis", default=False)
- EXP_EMPTY = BoolProperty(name="Empties", description="Export empty objects", default=True)
- EXP_CAMERA = BoolProperty(name="Cameras", description="Export camera objects", default=True)
- EXP_LAMP = BoolProperty(name="Lamps", description="Export lamp objects", default=True)
- EXP_ARMATURE = BoolProperty(name="Armatures", description="Export armature objects", default=True)
- EXP_MESH = BoolProperty(name="Meshes", description="Export mesh objects", default=True)
- EXP_MESH_APPLY_MOD = BoolProperty(name="Modifiers", description="Apply modifiers to mesh objects", default=True)
+ global_scale = FloatProperty(name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
+
+ global_rotate = EnumProperty(
+ name="Rotate",
+ options={'ENUM_FLAG'},
+ items=(('X_90', "X 90", ""),
+ ('Y_90', "Y 90", ""),
+ ('Z_90', "Z 90", ""),
+ ),
+ default={'X_90'},
+ description="Global rotation to apply to the exported scene",
+ )
+
+ object_types = EnumProperty(
+ name="Object Types",
+ options={'ENUM_FLAG'},
+ items=(('EMPTY', "Empty", ""),
+ ('CAMERA', "Camera", ""),
+ ('ARMATURE', "Armature", ""),
+ ('MESH', "Mesh", ""),
+ ),
+ default={'EMPTY', 'CAMERA', 'ARMATURE', 'MESH'},
+ )
+
+ mesh_apply_modifiers = BoolProperty(name="Modifiers", description="Apply modifiers to mesh objects", default=True)
+
+ mesh_smooth_type = EnumProperty(
+ name="Smoothing",
+ items=(('OFF', "Off", "Don't write smoothing"),
+ ('FACE', "Face", "Write face smoothing"),
+ ('EDGE', "Edge", "Write edge smoothing"),
+ ),
+ default='FACE',
+ )
+
# EXP_MESH_HQ_NORMALS = BoolProperty(name="HQ Normals", description="Generate high quality normals", default=True)
# armature animation
ANIM_ENABLE = BoolProperty(name="Enable Animation", description="Export keyframe animation", default=True)
@@ -77,12 +102,13 @@
# ANIM_ACTION_ALL = BoolProperty(name="Current Action", description="Use actions currently applied to the armatures (use scene start/end frame)", default=True)
ANIM_ACTION_ALL = BoolProperty(name="All Actions", description="Use all actions for armatures, if false, use current action", default=False)
- batch_mode = EnumProperty(items=(
- ('OFF', "Off", "Active scene to file"),
- ('SCENE', "Scene", "Each scene as a file"),
- ('GROUP', "Group", "Each group as a file"),
- ),
- name="Batch Mode")
+ batch_mode = EnumProperty(
+ name="Batch Mode",
+ items=(('OFF', "Off", "Active scene to file"),
+ ('SCENE', "Scene", "Each scene as a file"),
+ ('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'})
@@ -104,15 +130,15 @@
mtx4_z90n = Matrix.Rotation(-math.pi / 2.0, 4, 'Z')
GLOBAL_MATRIX = Matrix()
- GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.TX_SCALE
- if self.TX_XROT90:
+ GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.global_scale
+ if 'X_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_x90n * GLOBAL_MATRIX
- if self.TX_YROT90:
+ if 'Y_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_y90n * GLOBAL_MATRIX
- if self.TX_ZROT90:
+ if 'Z_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX
- keywords = self.as_keywords(ignore=("TX_XROT90", "TX_YROT90", "TX_ZROT90", "TX_SCALE", "check_existing", "filter_glob"))
+ keywords = self.as_keywords(ignore=("global_rotate", "global_scale", "check_existing", "filter_glob"))
keywords["GLOBAL_MATRIX"] = GLOBAL_MATRIX
from . import export_fbx
Modified: trunk/py/scripts/addons/io_scene_fbx/export_fbx.py
===================================================================
--- trunk/py/scripts/addons/io_scene_fbx/export_fbx.py 2011-04-15 00:07:49 UTC (rev 1832)
+++ trunk/py/scripts/addons/io_scene_fbx/export_fbx.py 2011-04-15 04:51:32 UTC (rev 1833)
@@ -204,12 +204,9 @@
def save_single(operator, scene, filepath="",
GLOBAL_MATRIX=None,
context_objects=None,
- EXP_MESH=True,
- EXP_MESH_APPLY_MOD=True,
- EXP_ARMATURE=True,
- EXP_LAMP=True,
- EXP_CAMERA=True,
- EXP_EMPTY=True,
+ object_types={'EMPTY', 'CAMERA', 'ARMATURE', 'MESH'},
+ mesh_apply_modifiers=True,
+ mesh_smooth_type='FACE',
ANIM_ENABLE=True,
ANIM_OPTIMIZE=True,
ANIM_OPTIMIZE_PRECISSION=6,
@@ -228,7 +225,7 @@
# Use this for working out paths relative to the export location
base_src = os.path.dirname(bpy.data.filepath)
- base_dst = os.path.dirname(filepath)
+ base_dst = os.path.dirname(filepath)
# collect images to copy
copy_set = set()
@@ -1395,7 +1392,8 @@
file.write('\n\t\t}')
# Write Face Smoothing
- file.write('''
+ if mesh_smooth_type == 'FACE':
+ file.write('''
LayerElementSmoothing: 0 {
Version: 102
Name: ""
@@ -1403,22 +1401,23 @@
ReferenceInformationType: "Direct"
Smoothing: ''')
- i = -1
- for f in me_faces:
- if i == -1:
- file.write('%i' % f.use_smooth)
- i = 0
- else:
- if i == 54:
- file.write('\n\t\t\t ')
+ i = -1
+ for f in me_faces:
+ if i == -1:
+ file.write('%i' % f.use_smooth)
i = 0
- file.write(',%i' % f.use_smooth)
- i += 1
+ else:
+ if i == 54:
+ file.write('\n\t\t\t ')
+ i = 0
+ file.write(',%i' % f.use_smooth)
+ i += 1
- file.write('\n\t\t}')
+ file.write('\n\t\t}')
- # Write Edge Smoothing
- file.write('''
+ elif mesh_smooth_type == 'EDGE':
+ # Write Edge Smoothing
+ file.write('''
LayerElementSmoothing: 0 {
Version: 101
Name: ""
@@ -1426,19 +1425,23 @@
ReferenceInformationType: "Direct"
Smoothing: ''')
- i = -1
- for ed in me_edges:
- if i == -1:
- file.write('%i' % (ed.use_edge_sharp))
- i = 0
- else:
- if i == 54:
- file.write('\n\t\t\t ')
+ i = -1
+ for ed in me_edges:
+ if i == -1:
+ file.write('%i' % (ed.use_edge_sharp))
i = 0
- file.write(',%i' % (ed.use_edge_sharp))
- i += 1
+ else:
+ if i == 54:
+ file.write('\n\t\t\t ')
+ i = 0
+ file.write(',%i' % (ed.use_edge_sharp))
+ i += 1
- file.write('\n\t\t}')
+ file.write('\n\t\t}')
+ elif mesh_smooth_type == 'OFF':
+ pass
+ else:
+ raise Exception("invalid mesh_smooth_type: %r" % mesh_smooth_type)
# Write VertexColor Layers
# note, no programs seem to use this info :/
@@ -1664,6 +1667,14 @@
TypedIndex: 0
}''')
+ # Smoothing info
+ if mesh_smooth_type != 'OFF':
+ file.write('''
+ LayerElement: {
+ Type: "LayerElementSmoothing"
+ TypedIndex: 0
+ }''')
+
# Always write this
if do_textures:
file.write('''
@@ -1767,7 +1778,7 @@
## XXX
- if EXP_ARMATURE:
+ if 'ARMATURE' in object_types:
# This is needed so applying modifiers dosnt apply the armature deformation, its also needed
# ...so mesh objects return their rest worldspace matrix when bone-parents are exported as weighted meshes.
# set every armature to its rest, backup the original values so we done mess up the scene
@@ -1799,21 +1810,21 @@
# for ob, mtx in BPyObject.getDerivedObjects(ob_base):
tmp_ob_type = ob.type
if tmp_ob_type == 'CAMERA':
- if EXP_CAMERA:
+ if 'CAMERA' in object_types:
ob_cameras.append(my_object_generic(ob, mtx))
elif tmp_ob_type == 'LAMP':
- if EXP_LAMP:
+ if 'LAMP' in object_types:
ob_lights.append(my_object_generic(ob, mtx))
elif tmp_ob_type == 'ARMATURE':
- if EXP_ARMATURE:
+ if 'ARMATURE' in object_types:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list