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-02 16:36:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-02 16:36:49 +0400
commitcc104d3a1d99088bf0dfecee89a399ab6035df7f (patch)
treef0151251c0fe7404c8f8df6a770429d08b400ec2 /io_scene_fbx
parent888e3c02872d5d33b93356ddf98808e71c85ca83 (diff)
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
Diffstat (limited to 'io_scene_fbx')
-rw-r--r--io_scene_fbx/__init__.py10
-rw-r--r--io_scene_fbx/export_fbx.py38
2 files changed, 34 insertions, 14 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index c5d4c675..d901fe88 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -141,6 +141,13 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
"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 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
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'}
diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py
index 9932c09e..d3e35f64 100644
--- a/io_scene_fbx/export_fbx.py
+++ b/io_scene_fbx/export_fbx.py
@@ -204,6 +204,7 @@ def save_single(operator, scene, filepath="",
path_mode='AUTO',
use_mesh_edges=True,
use_rotate_workaround=False,
+ use_default_take=False,
):
import bpy_extras.io_utils
@@ -2482,18 +2483,25 @@ Connections: {''')
# 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 @@ Connections: {''')
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 @@ Connections: {''')
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 @@ Connections: {''')
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 @@ Takes: {''')
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 @@ Takes: {''')
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