Created
February 24, 2019 01:31
-
-
Save RH2/076f41ea60366f31a728d03bb678b1f3 to your computer and use it in GitHub Desktop.
work in progress ue4 export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ue4export header version 0.1 | |
#last tested with b-v2.79 ue4export-v0.2.1 | |
import bpy | |
import datetime | |
S_time = datetime.datetime.now() | |
print("---RUNNING-UE4 ::: "+str(S_time)+"---") | |
ActionList=['M4_ADS_RELOAD'] | |
#ActionList=[ | |
#'M4_ADS_RELOAD', | |
#'M4_ADS_FIRE', | |
#'M4_ADS_Transition', | |
#'M4_hipFire', | |
#'M4_hipFire2', | |
#'M4_hipFire3', | |
#'M4_hipFire4', | |
#'M4_PoseLib', | |
#'M4_putAway'] | |
ObjectList=[ | |
'ARMS', | |
'AR_RIG', | |
'HELPER'] | |
#context | |
original_context = bpy.context.area.type | |
#Remove all animation data (Clean Slate) | |
for rig in ObjectList: | |
rigObj = bpy.data.objects[rig] | |
rigObj.animation_data_clear() | |
#bpy.data.objects[rig].animation_data_clear() | |
#Export one action set at a time | |
for focusedAction in ActionList: #focused action is a string "jump" | |
for rig in ObjectList: | |
rigObj = bpy.data.objects[rig] | |
for action in bpy.data.objects[rig].exportActionList: | |
action.use = False | |
if action.name == focusedAction: | |
action.use = True | |
rigObj.animation_data_clear() | |
rigObj.animation_data_create() | |
actiondata = bpy.data.actions[focusedAction] | |
if actiondata.users>1: | |
newAction = bpy.data.actions[focusedAction].copy() | |
newAction.name = focusedAction+' copy'+rig | |
actiondata=newAction | |
rigObj.animation_data.action = actiondata | |
####Create NLA strips | |
track = rigObj.animation_data.nla_tracks.new() | |
newStrip = track.strips.new(actiondata.name, actiondata.frame_range[0], actiondata) | |
print(newStrip) | |
print("-----------------------------------------------------------------------------------------------------------") | |
rigObj.animation_data.action = None | |
bpy.context.area.type = "NLA_EDITOR" | |
bpy.ops.nla.actionclip_add(action=focusedAction) | |
#bpy.ops.nla.select_all_toggle(invert=False) | |
#bpy.ops.nla.make_single_user() | |
bpy.ops.anim.channels_clean_empty() | |
#bpy.context.space_data.mode= "ACTION" | |
#bpy.ops.action.push_down() | |
#bpy.context.area.type = "NLA_EDITOR" | |
#bpy.ops.nla.select_all_toggle(invert=False) | |
#bpy.ops.nla.action_pushdown(channel_index=-1) #Push action down onto the top of the NLA stack as a new strip | |
#line47 RuntimeError: Error: No active AnimData block to use (select a data-block expander first or set the appropriate flags on an AnimData block) | |
#bpy.ops.nla.make_single_user() #ensure that each action is only used once in the set of strips selected | |
#bpy.ops.nla.actionclip_add(action='') #add an action-clip strip referencing an action to the active track | |
#bpy.ops.nla.action_pushdown(channel_index=-1) #Push action down onto the top of the NLA stack as a new strip | |
#bpy.ops.nla.make_single_user() #ensure that each action is only used once in the set of strips selected | |
#bpy.ops.nla.meta_add() #add new meta-strips incorporating the selected strips | |
#bpy.ops.nla.meta_remove() #Separate out the strips held by the selected meta-strips | |
#bpy.ops.nla.select_all_toggle(invert=False) #Select all or deselect all. | |
bpy.ops.object.exportforunreal() | |
bpy.context.area.type = original_context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment