Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checkbox to import all animations when importing an OoT skeleton #485

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Nokaubure marked this conversation as resolved.
Show resolved Hide resolved
bpy.ops.object.select_all(action='DESELECT')

armatureObj.select_set(True)

bpy.context.view_layer.objects.active = armatureObj
Nokaubure marked this conversation as resolved.
Show resolved Hide resolved

animation_names = ootGetAnimNames(skeletonData)
animation_names = list(dict.fromkeys(animation_names))
#print(animation_names)
Nokaubure marked this conversation as resolved.
Show resolved Hide resolved
# 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.
Nokaubure marked this conversation as resolved.
Show resolved Hide resolved

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
Loading