Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animation support #31

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
PointerProperty,
FloatProperty,
IntProperty,
BoolProperty,
)

import traceback
Expand Down Expand Up @@ -99,9 +100,66 @@ class RbxAddonPreferences(AddonPreferences):
step=0.01,
description=f"Global scale applied to objects during export for upload.\nDEFAULT: {constants.DEFAULT_EXPORT_SCALE} (Blender Meters are 100:1 to Studio Studs)",
)
bake_anim: BoolProperty(
name="Baked Animation",
description="Export baked keyframe animation",
default=True,
)
bake_anim_use_all_bones: BoolProperty(
name="Key All Bones",
description="Force exporting at least one key of animation for all bones "
"(needed with some target applications, like UE4)",
default=True,
)
bake_anim_use_nla_strips: BoolProperty(
name="NLA Strips",
description="Export each non-muted NLA strip as a separated FBX's AnimStack, if any, "
"instead of global scene animation",
default=True,
)
bake_anim_use_all_actions: BoolProperty(
name="All Actions",
description="Export each action as a separated FBX's AnimStack, instead of global scene animation "
"(note that animated objects will get all actions compatible with them, "
"others will get no animation at all)",
default=True,
)
bake_anim_force_startend_keying: BoolProperty(
name="Force Start/End Keying",
description="Always add a keyframe at start and end of actions for animated channels",
default=True,
)
bake_anim_step: FloatProperty(
name="Sampling Rate",
description="How often to evaluate animated values (in frames)",
min=0.01,
max=100.0,
soft_min=0.1,
soft_max=10.0,
default=1.0,
)
bake_anim_simplify_factor: FloatProperty(
name="Simplify",
description="How much to simplify baked values (0.0 to disable, the higher the more simplified)",
min=0.0,
max=100.0, # No simplification to up to 10% of current magnitude tolerance.
soft_min=0.0,
soft_max=10.0,
default=1.0, # default: min slope: 0.005, max frame step: 10.
)

def draw(self, context):
self.layout.prop(self, "export_scale")
self.layout.prop(self, "bake_anim", text="Bake Animation")
bake_anim_box = self.layout.box()
bake_anim_box.use_property_split = True
bake_anim_box.enabled = self.bake_anim
bake_anim_box.prop(self, "bake_anim_use_all_bones")
bake_anim_box.prop(self, "bake_anim_use_nla_strips")
bake_anim_box.prop(self, "bake_anim_use_all_actions")
bake_anim_box.prop(self, "bake_anim_force_startend_keying")
bake_anim_box.prop(self, "bake_anim_step")
bake_anim_box.prop(self, "bake_anim_simplify_factor")


class RBX_PT_sidebar:
Expand Down Expand Up @@ -133,7 +191,8 @@ def draw(self, context):
rbx = context.window_manager.rbx
if not rbx.is_finished_installing_dependencies:
layout.row().label(
text=f"This plugin requires installation of dependencies the first time it is run.", icon="INFO"
text=f"This plugin requires installation of dependencies the first time it is run.",
icon="INFO",
)

layout.row().operator(
Expand Down
7 changes: 7 additions & 0 deletions lib/export_fbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def export_fbx(scene, view_layer, target_object, exported_file_path, preferences
bpy.ops.export_scene.fbx(
filepath=str(exported_file_path),
global_scale=preferences.export_scale,
bake_anim=preferences.bake_anim,
bake_anim_use_all_bones=preferences.bake_anim_use_all_bones,
bake_anim_use_nla_strips=preferences.bake_anim_use_nla_strips,
bake_anim_use_all_actions=preferences.bake_anim_use_all_actions,
bake_anim_force_startend_keying=preferences.bake_anim_force_startend_keying,
bake_anim_step=preferences.bake_anim_step,
bake_anim_simplify_factor=preferences.bake_anim_simplify_factor,
axis_forward="-Z",
axis_up="Y",
path_mode="COPY",
Expand Down
Loading