[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2212] trunk/py/scripts/addons/ io_scene_fbx: patch [#28118] Add XNA requirements to the official FBX exporter
Campbell Barton
ideasman42 at gmail.com
Tue Aug 2 14:36:50 CEST 2011
Revision: 2212
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2212
Author: campbellbarton
Date: 2011-08-02 12:36:49 +0000 (Tue, 02 Aug 2011)
Log Message:
-----------
patch [#28118] Add XNA requirements to the official FBX exporter
from John Brown (jcbdigger)
patch file:
fbx_xna_unified-2011-08-02a_jcbdigger.patch
Option not to export Default Take
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-08-02 10:25:12 UTC (rev 2211)
+++ trunk/py/scripts/addons/io_scene_fbx/__init__.py 2011-08-02 12:36:49 UTC (rev 2212)
@@ -141,6 +141,13 @@
"currently selected action"),
default=True,
)
+ use_default_take = BoolProperty(
+ name="Include Default Take",
+ description=("Export currently assigned object and armature "
+ "animations into a default take from the scene "
+ "start/end frames"),
+ default=False
+ )
use_anim_optimize = BoolProperty(
name="Optimize Keyframes",
description="Remove double keyframes",
@@ -203,6 +210,9 @@
if self.use_mesh_edges:
changed = True
self.use_mesh_edges = False
+ if self.use_default_take:
+ changed = True
+ self.use_default_take = False
if self.object_types & {'CAMERA', 'LAMP', 'EMPTY'}:
changed = True
self.object_types -= {'CAMERA', 'LAMP', 'EMPTY'}
Modified: trunk/py/scripts/addons/io_scene_fbx/export_fbx.py
===================================================================
--- trunk/py/scripts/addons/io_scene_fbx/export_fbx.py 2011-08-02 10:25:12 UTC (rev 2211)
+++ trunk/py/scripts/addons/io_scene_fbx/export_fbx.py 2011-08-02 12:36:49 UTC (rev 2212)
@@ -204,6 +204,7 @@
path_mode='AUTO',
use_mesh_edges=True,
use_rotate_workaround=False,
+ use_default_take=False,
):
import bpy_extras.io_utils
@@ -2482,18 +2483,25 @@
# instead of tagging
tagged_actions = []
+ # get the current action first so we can use it if we only export one action (JCB)
+ for my_arm in ob_arms:
+ if not blenActionDefault:
+ blenActionDefault = my_arm.blenAction
+ if blenActionDefault:
+ break
+
if use_anim_action_all:
tmp_actions = bpy.data.actions[:]
+ elif not use_default_take:
+ if blenActionDefault:
+ # Export the current action (JCB)
+ tmp_actions.append(blenActionDefault)
+ if tmp_actions:
# find which actions are compatible with the armatures
- # blenActions is not yet initialized so do it now.
tmp_act_count = 0
for my_arm in ob_arms:
- # get the default name
- if not blenActionDefault:
- blenActionDefault = my_arm.blenAction
-
arm_bone_names = set([my_bone.blenName for my_bone in my_arm.fbxBones])
for action in tmp_actions:
@@ -2505,7 +2513,8 @@
tagged_actions.append(action.name)
tmp_act_count += 1
- # incase there is no actions applied to armatures
+ # incase there are no actions applied to armatures
+ # for example, when a user deletes the current action.
action_lastcompat = action
if tmp_act_count:
@@ -2515,7 +2524,8 @@
del action_lastcompat
- tmp_actions.insert(0, None) # None is the default action
+ if use_default_take:
+ tmp_actions.insert(0, None) # None is the default action
file.write('''
;Takes and animation section
@@ -2523,7 +2533,7 @@
Takes: {''')
- if blenActionDefault:
+ if blenActionDefault and not use_default_take:
file.write('\n\tCurrent: "%s"' % sane_takename(blenActionDefault))
else:
file.write('\n\tCurrent: "Default Take"')
@@ -2539,15 +2549,15 @@
if blenAction is None:
# Warning, this only accounts for tmp_actions being [None]
- file.write('\n\tTake: "Default Take" {')
+ take_name = "Default Take"
act_start = start
act_end = end
else:
# use existing name
if blenAction == blenActionDefault: # have we already got the name
- file.write('\n\tTake: "%s" {' % sane_name_mapping_take[blenAction.name])
+ take_name = sane_name_mapping_take[blenAction.name]
else:
- file.write('\n\tTake: "%s" {' % sane_takename(blenAction))
+ take_name = sane_takename(blenAction)
act_start, act_end = blenAction.frame_range
act_start = int(act_start)
@@ -2557,10 +2567,10 @@
for my_arm in ob_arms:
if my_arm.blenObject.animation_data and blenAction in my_arm.blenActionList:
my_arm.blenObject.animation_data.action = blenAction
- # print('\t\tSetting Action!', blenAction)
- # scene.update(1)
- file.write('\n\t\tFileName: "Default_Take.tak"') # ??? - not sure why this is needed
+ # Use the action name as the take name and the take filename (JCB)
+ file.write('\n\tTake: "%s" {' % take_name)
+ file.write('\n\t\tFileName: "%s.tak"' % take_name.replace(" ", "_"))
file.write('\n\t\tLocalTime: %i,%i' % (fbx_time(act_start - 1), fbx_time(act_end - 1))) # ??? - not sure why this is needed
file.write('\n\t\tReferenceTime: %i,%i' % (fbx_time(act_start - 1), fbx_time(act_end - 1))) # ??? - not sure why this is needed
More information about the Bf-extensions-cvs
mailing list