Skip to content

Commit

Permalink
feature to import all animations when importing an OoT skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokaubure committed Dec 16, 2024
1 parent 81fd463 commit 3d53e4b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
25 changes: 21 additions & 4 deletions fast64_internal/oot/skeleton/importer/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from ...oot_texture_array import ootReadTextureArrays
from ..constants import ootSkeletonImportDict
from ..properties import OOTSkeletonImportSettings
from ..utility import ootGetLimb, ootGetLimbs, ootGetSkeleton, applySkeletonRestPose

from ..utility import ootGetLimb, ootGetLimbs, ootGetSkeleton, applySkeletonRestPose, ootGetAnimNames
from ...tools.quick_import import quick_import_exec

class OOTDLEntry:
def __init__(self, dlName, limbIndex):
Expand Down Expand Up @@ -264,6 +264,7 @@ def ootImportSkeletonC(basePath: str, importSettings: OOTSkeletonImportSettings)

removeDoubles = importSettings.removeDoubles
importNormals = importSettings.importNormals
importAnimations = importSettings.importAnimations
drawLayer = importSettings.drawLayer

skeletonData = getImportData(filepaths)
Expand All @@ -284,8 +285,7 @@ def ootImportSkeletonC(basePath: str, importSettings: OOTSkeletonImportSettings)
actorScale = ootReadActorScale(basePath, overlayName, isLink)
else:
actorScale = getOOTScale(importSettings.actorScale)

# print(limbList)

isLOD, armatureObj = ootBuildSkeleton(
skeletonName,
overlayName,
Expand Down Expand Up @@ -324,3 +324,20 @@ def ootImportSkeletonC(basePath: str, importSettings: OOTSkeletonImportSettings)
applySkeletonRestPose(restPoseData, armatureObj)
if isLOD:
applySkeletonRestPose(restPoseData, LODArmatureObj)


if importAnimations:

if armatureObj:
bpy.ops.object.select_all(action='DESELECT')

armatureObj.select_set(True)

bpy.context.view_layer.objects.active = armatureObj

animation_names = ootGetAnimNames(skeletonData)
animation_names = list(dict.fromkeys(animation_names))
#print(animation_names)
# Call quick_import_exec for each animation name
for animation_name in animation_names:
quick_import_exec(bpy.context, animation_name)
2 changes: 2 additions & 0 deletions fast64_internal/oot/skeleton/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class OOTSkeletonImportSettings(PropertyGroup):
isCustom: BoolProperty(name="Use Custom Path")
removeDoubles: BoolProperty(name="Remove Doubles On Import", default=True)
importNormals: BoolProperty(name="Import Normals", default=True)
importAnimations: BoolProperty(name="Import Animations", default=False)
drawLayer: EnumProperty(name="Import Draw Layer", items=ootEnumDrawLayers)
actorOverlayName: StringProperty(name="Overlay", default="ovl_En_GeldB")
flipbookUses2DArray: BoolProperty(name="Has 2D Flipbook Array", default=False)
Expand All @@ -128,6 +129,7 @@ def draw_props(self, layout: UILayout):
prop_split(layout, self, "drawLayer", "Import Draw Layer")
layout.prop(self, "removeDoubles")
layout.prop(self, "importNormals")
layout.prop(self, "importAnimations")
layout.prop(self, "isCustom")
if self.isCustom:
prop_split(layout, self, "name", "Skeleton")
Expand Down
7 changes: 7 additions & 0 deletions fast64_internal/oot/skeleton/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def ootGetLimb(skeletonData, limbName, continueOnError):
raise PluginError("Cannot handle skeleton limb named " + limbName + " of type " + limbType)
return matchResult

def ootGetAnimNames(skeleton_data):
#Extracts all animation names that start with 'AnimationHeader' from the given skeleton data.

pattern = r"AnimationHeader\s+(\w+)"
animation_names = re.findall(pattern, skeleton_data)

return animation_names

def getGroupIndexOfVert(vert, armatureObj, obj, rootGroupIndex):
actualGroups = []
Expand Down
8 changes: 8 additions & 0 deletions fast64_internal/oot/tools/quick_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def raise_only_from_object(type: str):
settings.animName = sym_name
settings.folderName = folder_name
bpy.ops.object.oot_import_anim()
elif sym_def_type == "LinkAnimationHeader" and not is_array:
raise_only_from_object(sym_def_type)
settings: OOTAnimImportSettingsProperty = context.scene.fast64.oot.animImportSettings
settings.isCustom = False
settings.isLink = True
settings.animName = sym_name
settings.folderName = folder_name
bpy.ops.object.oot_import_anim()
elif sym_def_type == "CutsceneData" and is_array:
bpy.context.scene.ootCSNumber = importCutsceneData(f"{sym_file_p}", None, sym_name)
else:
Expand Down

0 comments on commit 3d53e4b

Please sign in to comment.