提交 1e313979 编写于 作者: P Pelle Johnsen

Add option in blender exporter to bake keyframe animation

上级 e18b7259
...@@ -434,6 +434,10 @@ def restore_export_settings(properties, settings): ...@@ -434,6 +434,10 @@ def restore_export_settings(properties, settings):
constants.KEYFRAMES, constants.KEYFRAMES,
constants.EXPORT_OPTIONS[constants.KEYFRAMES]) constants.EXPORT_OPTIONS[constants.KEYFRAMES])
properties.option_bake_keyframes = settings.get(
constants.BAKE_KEYFRAMES,
constants.EXPORT_OPTIONS[constants.BAKE_KEYFRAMES])
properties.option_frame_step = settings.get( properties.option_frame_step = settings.get(
constants.FRAME_STEP, constants.FRAME_STEP,
constants.EXPORT_OPTIONS[constants.FRAME_STEP]) constants.EXPORT_OPTIONS[constants.FRAME_STEP])
...@@ -491,6 +495,7 @@ def set_settings(properties): ...@@ -491,6 +495,7 @@ def set_settings(properties):
constants.BLEND_SHAPES: properties.option_blend_shape, constants.BLEND_SHAPES: properties.option_blend_shape,
constants.ANIMATION: properties.option_animation_skeletal, constants.ANIMATION: properties.option_animation_skeletal,
constants.KEYFRAMES: properties.option_keyframes, constants.KEYFRAMES: properties.option_keyframes,
constants.BAKE_KEYFRAMES: properties.option_bake_keyframes,
constants.FRAME_STEP: properties.option_frame_step, constants.FRAME_STEP: properties.option_frame_step,
constants.FRAME_INDEX_AS_TIME: properties.option_frame_index_as_time, constants.FRAME_INDEX_AS_TIME: properties.option_frame_index_as_time,
constants.INFLUENCES_PER_VERTEX: properties.option_influences constants.INFLUENCES_PER_VERTEX: properties.option_influences
...@@ -736,6 +741,11 @@ class ExportThree(bpy.types.Operator, ExportHelper): ...@@ -736,6 +741,11 @@ class ExportThree(bpy.types.Operator, ExportHelper):
description="Export animation (keyframes)", description="Export animation (keyframes)",
default=constants.EXPORT_OPTIONS[constants.KEYFRAMES]) default=constants.EXPORT_OPTIONS[constants.KEYFRAMES])
option_bake_keyframes = BoolProperty(
name="Bake keyframe animation",
description="Bake keyframe animation each frame step",
default=constants.EXPORT_OPTIONS[constants.BAKE_KEYFRAMES])
option_frame_index_as_time = BoolProperty( option_frame_index_as_time = BoolProperty(
name="Frame index as time", name="Frame index as time",
description="Use (original) frame index as frame time", description="Use (original) frame index as frame time",
...@@ -961,6 +971,9 @@ class ExportThree(bpy.types.Operator, ExportHelper): ...@@ -961,6 +971,9 @@ class ExportThree(bpy.types.Operator, ExportHelper):
row = box.row() row = box.row()
row.prop(self.properties, 'option_keyframes') row.prop(self.properties, 'option_keyframes')
row = box.row()
row.prop(self.properties, 'option_bake_keyframes')
row = box.row() row = box.row()
row.prop(self.properties, 'option_influences') row.prop(self.properties, 'option_influences')
......
...@@ -93,6 +93,7 @@ FRAME_INDEX_AS_TIME = 'frameIndexAsTime' ...@@ -93,6 +93,7 @@ FRAME_INDEX_AS_TIME = 'frameIndexAsTime'
ANIMATION = 'animations' ANIMATION = 'animations'
CLIPS="clips" CLIPS="clips"
KEYFRAMES = 'tracks' KEYFRAMES = 'tracks'
BAKE_KEYFRAMES = 'bake_tracks'
MORPH_TARGETS = 'morphTargets' MORPH_TARGETS = 'morphTargets'
MORPH_TARGETS_ANIM = 'morphTargetsAnimation' MORPH_TARGETS_ANIM = 'morphTargetsAnimation'
BLEND_SHAPES = 'blendShapes' BLEND_SHAPES = 'blendShapes'
...@@ -161,6 +162,7 @@ EXPORT_OPTIONS = { ...@@ -161,6 +162,7 @@ EXPORT_OPTIONS = {
MAPS: False, MAPS: False,
ANIMATION: OFF, ANIMATION: OFF,
KEYFRAMES: False, KEYFRAMES: False,
BAKE_KEYFRAMES: False,
BONES: False, BONES: False,
SKINNING: False, SKINNING: False,
MORPH_TARGETS: False, MORPH_TARGETS: False,
......
...@@ -231,6 +231,12 @@ def animated_xform(obj, options): ...@@ -231,6 +231,12 @@ def animated_xform(obj, options):
inverted_fallback = mathutils.Matrix() if use_inverted else None inverted_fallback = mathutils.Matrix() if use_inverted else None
convert_matrix = AXIS_CONVERSION # matrix to convert the exported matrix convert_matrix = AXIS_CONVERSION # matrix to convert the exported matrix
original_frame = context.scene.frame_current original_frame = context.scene.frame_current
if options.get(constants.BAKE_KEYFRAMES):
frame_step = options.get(constants.FRAME_STEP, 1)
logger.info("Baking keyframes, frame_step=%d", frame_step)
times = range(context.scene.frame_start, context.scene.frame_end+1, frame_step)
for time in times: for time in times:
context.scene.frame_set(time, 0.0) context.scene.frame_set(time, 0.0)
if use_inverted: # need to use the inverted, parent matrix might have chance if use_inverted: # need to use the inverted, parent matrix might have chance
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册