Skip to content

Commit

Permalink
Preparations for the new animation export options
Browse files Browse the repository at this point in the history
  • Loading branch information
bartteunis committed Jul 24, 2021
1 parent aceed11 commit 52287d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
7 changes: 0 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ class ExportSMF(Operator, ExportHelper):
)

# "Advanced" export settings
export_nla_tracks : BoolProperty(
name="Export NLA Tracks",
description="Whether to export multiple animations on all NLA tracks that are linked to this model (Experimental)",
default=False,
)

anim_export_mode : EnumProperty(
name="What to export",
description="How to export animations",
Expand Down Expand Up @@ -170,7 +164,6 @@ def draw(self, context):
sfile = context.space_data
operator = sfile.active_operator

layout.prop(operator, 'export_nla_tracks')
layout.label(text="General")
layout.prop(operator, 'anim_export_mode')
layout.prop(operator, 'anim_length_mode')
Expand Down
38 changes: 26 additions & 12 deletions smf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def smf_bindmap(bones):
def export_smf(operator, context,
filepath,
export_textures,
export_nla_tracks,
export_type,
anim_export_mode,
anim_length_mode,
Expand All @@ -97,7 +96,6 @@ def export_smf(operator, context,
"""

# Figure out what we're going to export
# TODO Extend this to 'MESH'-like objects? (text, curves, surfaces, ...)
object_list = context.selected_objects
#model_list = [o for o in object_list if o.type=='MESH']
model_list = [o for o in object_list if o.type in meshlike_types]
Expand All @@ -112,15 +110,25 @@ def export_smf(operator, context,
rig = rig_object.data
anim_data = rig_object.animation_data
if anim_data:
if export_nla_tracks:
if anim_export_mode == 'LNK':
# Unique actions linked to NLA tracks
tracks = anim_data.nla_tracks
if tracks:
for track in tracks:
for strip in track.strips:
animations.add(strip.action)
else:
elif anim_export_mode == 'CUR':
# Currently assigned action
if anim_data.action:
animations.add(anim_data.action)
elif anim_export_mode == 'TRA':
# Every track separately
pass
elif anim_export_mode == 'SCN':
# Final result of NLA tracks on scene
pass
else:
pass

# Initalize variables that we need across chunks
bindmap = {}
Expand Down Expand Up @@ -186,7 +194,7 @@ def export_smf(operator, context,
texture_bytes.extend(bytearray(img.name + "\0",'utf-8')) # Texture name
texture_bytes.extend(pack('HH',*img.size)) # Texture size (w,h)

print(img.name, img.size[:])
#print(img.name, img.size[:])

for cpo in img.size:
if floor(log2(cpo)) != log2(cpo):
Expand Down Expand Up @@ -439,20 +447,26 @@ def write_animation_data(name, scene, byte_data, rig_object, keyframe_times, fra

# Write all animations (i.e. actions)
# TODO
"""
if a:
if anim_export_mode == 'CUR':
# Current action
# Loop through current action's values
# Use action length to determine number of frames
pass
elif anim_export_mode == 'LNK':
# Linked actions
# Find all unique actions and export them same as in "current" setting
pass
elif b:
elif anim_export_mode == 'TRA':
# NLA tracks
#
pass
elif c:
# Linked actions
elif anim_export_mode == 'SCN':
# Full NLA animation
# Use current scene, leave NLA track mutes/solos as is
pass
else:
# Full NLA animation
# Invalid option
pass
"""

animation_bytes.extend(pack('B', len(animations)))
for anim in animations:
Expand Down

0 comments on commit 52287d0

Please # to comment.