Browse Source

Merge pull request #219 from DoobesURU/ObjectSDLAnimation

Add plAgeGlobalAnim support
pull/235/head
Adam Johnson 4 years ago committed by GitHub
parent
commit
d48b83d2f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      korman/exporter/animation.py
  2. 58
      korman/properties/modifiers/anim.py
  3. 6
      korman/ui/modifiers/anim.py

31
korman/exporter/animation.py

@ -72,7 +72,8 @@ class AnimationConverter:
# There is a race condition in the client with animation loading. It expects for modifiers # There is a race condition in the client with animation loading. It expects for modifiers
# to be listed on the SceneObject in a specific order. D'OH! So, always use these funcs. # to be listed on the SceneObject in a specific order. D'OH! So, always use these funcs.
agmod, agmaster = self.get_anigraph_objects(bo, so) agmod, agmaster = self.get_anigraph_objects(bo, so)
atcanim = self._mgr.find_create_object(plATCAnim, so=so) anim_mod = bo.plasma_modifiers.animation
atcanim = self._mgr.find_create_object(anim_mod.anim_type, so=so)
# Add the animation data to the ATC # Add the animation data to the ATC
for i in applicators: for i in applicators:
@ -89,21 +90,23 @@ class AnimationConverter:
if i is not None: if i is not None:
yield i.frame_range[index] yield i.frame_range[index]
atcanim.name = "(Entire Animation)" atcanim.name = "(Entire Animation)"
sdl_name = anim_mod.obj_sdl_anim
atcanim.start = self._convert_frame_time(min(get_ranges(obj_action, data_action, index=0))) atcanim.start = self._convert_frame_time(min(get_ranges(obj_action, data_action, index=0)))
atcanim.end = self._convert_frame_time(max(get_ranges(obj_action, data_action, index=1))) atcanim.end = self._convert_frame_time(max(get_ranges(obj_action, data_action, index=1)))
if isinstance(atcanim, plAgeGlobalAnim):
# Marker points atcanim.globalVarName = anim_mod.obj_sdl_anim
if obj_action is not None: if isinstance(atcanim, plATCAnim):
for marker in obj_action.pose_markers: # Marker points
atcanim.setMarker(marker.name, self._convert_frame_time(marker.frame)) if obj_action is not None:
for marker in obj_action.pose_markers:
# Fixme? Not sure if we really need to expose this... atcanim.setMarker(marker.name, self._convert_frame_time(marker.frame))
atcanim.easeInMin = 1.0 # Fixme? Not sure if we really need to expose this...
atcanim.easeInMax = 1.0 atcanim.easeInMin = 1.0
atcanim.easeInLength = 1.0 atcanim.easeInMax = 1.0
atcanim.easeOutMin = 1.0 atcanim.easeInLength = 1.0
atcanim.easeOutMax = 1.0 atcanim.easeOutMin = 1.0
atcanim.easeOutLength = 1.0 atcanim.easeOutMax = 1.0
atcanim.easeOutLength = 1.0
def _convert_camera_animation(self, bo, so, obj_fcurves, data_fcurves): def _convert_camera_animation(self, bo, so, obj_fcurves, data_fcurves):
if data_fcurves: if data_fcurves:

58
korman/properties/modifiers/anim.py

@ -60,37 +60,45 @@ class PlasmaAnimationModifier(ActionModifier, PlasmaModifierProperties):
description="Marker indicating where the default loop begins") description="Marker indicating where the default loop begins")
loop_end = StringProperty(name="Loop End", loop_end = StringProperty(name="Loop End",
description="Marker indicating where the default loop ends") description="Marker indicating where the default loop ends")
obj_sdl_anim = StringProperty(name="SDL Animation",
description="Name of the SDL variable to use for this animation",
options=set())
@property
def anim_type(self):
return plAgeGlobalAnim if self.obj_sdl_anim else plATCAnim
def export(self, exporter, bo, so): def export(self, exporter, bo, so):
action = self.blender_action action = self.blender_action
anim_mod = bo.plasma_modifiers.animation
atcanim = exporter.mgr.find_create_object(plATCAnim, so=so) atcanim = exporter.mgr.find_create_object(anim_mod.anim_type, so=so)
atcanim.autoStart = self.auto_start if not isinstance(atcanim, plAgeGlobalAnim):
atcanim.loop = self.loop atcanim.autoStart = self.auto_start
atcanim.loop = self.loop
# Simple start and loop info
if action is not None: # Simple start and loop info for ATC
markers = action.pose_markers if action is not None:
initial_marker = markers.get(self.initial_marker) markers = action.pose_markers
if initial_marker is not None: initial_marker = markers.get(self.initial_marker)
atcanim.initial = _convert_frame_time(initial_marker.frame) if initial_marker is not None:
else: atcanim.initial = _convert_frame_time(initial_marker.frame)
atcanim.initial = -1.0
if self.loop:
loop_start = markers.get(self.loop_start)
if loop_start is not None:
atcanim.loopStart = _convert_frame_time(loop_start.frame)
else: else:
atcanim.initial = -1.0
if self.loop:
loop_start = markers.get(self.loop_start)
if loop_start is not None:
atcanim.loopStart = _convert_frame_time(loop_start.frame)
else:
atcanim.loopStart = atcanim.start
loop_end = markers.get(self.loop_end)
if loop_end is not None:
atcanim.loopEnd = _convert_frame_time(loop_end.frame)
else:
atcanim.loopEnd = atcanim.end
else:
if self.loop:
atcanim.loopStart = atcanim.start atcanim.loopStart = atcanim.start
loop_end = markers.get(self.loop_end)
if loop_end is not None:
atcanim.loopEnd = _convert_frame_time(loop_end.frame)
else:
atcanim.loopEnd = atcanim.end atcanim.loopEnd = atcanim.end
else:
if self.loop:
atcanim.loopStart = atcanim.start
atcanim.loopEnd = atcanim.end
class AnimGroupObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): class AnimGroupObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup):

6
korman/ui/modifiers/anim.py

@ -40,10 +40,12 @@ def animation(modifier, layout, context):
if action: if action:
layout.prop_search(modifier, "initial_marker", action, "pose_markers", icon="PMARKER") layout.prop_search(modifier, "initial_marker", action, "pose_markers", icon="PMARKER")
col = layout.column() col = layout.column()
col.enabled = modifier.loop col.enabled = modifier.loop and not modifier.obj_sdl_anim
col.prop_search(modifier, "loop_start", action, "pose_markers", icon="PMARKER") col.prop_search(modifier, "loop_start", action, "pose_markers", icon="PMARKER")
col.prop_search(modifier, "loop_end", action, "pose_markers", icon="PMARKER") col.prop_search(modifier, "loop_end", action, "pose_markers", icon="PMARKER")
layout.separator()
layout.prop(modifier, "obj_sdl_anim")
def animation_filter(modifier, layout, context): def animation_filter(modifier, layout, context):
split = layout.split() split = layout.split()

Loading…
Cancel
Save