Implement CKeyframe importer and exporter (#121)

This commit is contained in:
louist103
2024-05-22 09:04:59 -05:00
committed by Garrett Cox
parent d479a7db37
commit a4a4264fc0
20 changed files with 411 additions and 55 deletions
+1 -1
Submodule ZAPDTR updated: 1ac9c36e84...01ed7e87f2
+14
View File
@@ -85,6 +85,7 @@ CrowdControl* CrowdControl::Instance;
#include "2s2h/resource/importer/TextMMFactory.h"
#include "2s2h/resource/importer/BackgroundFactory.h"
#include "2s2h/resource/importer/TextureAnimationFactory.h"
#include "2s2h/resource/importer/KeyFrameFactory.h"
OTRGlobals* OTRGlobals::Instance;
GameInteractor* GameInteractor::Instance;
@@ -159,6 +160,10 @@ OTRGlobals::OTRGlobals() {
LUS::ResourceType::SOH_Background, "Background", std::make_shared<LUS::BackgroundFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::TSH_TexAnim, "TextureAnimation", std::make_shared<LUS::TextureAnimationFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::TSH_CKeyFrameAnim, "KeyFrameAnim", std::make_shared<LUS::KeyFrameAnimFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::TSH_CKeyFrameSkel, "KeyFrameSkel", std::make_shared<LUS::KeyFrameSkelFactory>());
context->GetControlDeck()->SetSinglePlayerMappingMode(true);
@@ -998,6 +1003,15 @@ extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
return (Vtx*)ResourceGetDataByName(path);
}
extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path) {
return (KeyFrameSkeleton*)ResourceGetDataByName(path);
}
extern "C" KeyFrameAnimation* ResourceMgr_LoadKeyFrameAnimByName(const char* path) {
return (KeyFrameAnimation*)ResourceGetDataByName(path);
}
//extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
// SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
// return *sequence;
+3
View File
@@ -93,6 +93,9 @@ char* ResourceMgr_LoadVtxArrayByName(const char* path);
size_t ResourceMgr_GetVtxArraySizeByName(const char* path);
Vtx* ResourceMgr_LoadVtxByName(char* path);
KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path);
KeyFrameAnimation* ResourceMgr_LoadKeyFrameAnimByName(const char* path);
void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size);
void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size);
@@ -0,0 +1,147 @@
#include "2s2h/resource/importer/KeyFrameFactory.h"
#include "2s2h/resource/type/KeyFrame.h"
#include <libultraship/libultraship.h>
#include "spdlog/spdlog.h"
#include "../ZAPDTR/ZAPD/ZCKeyFrame.h"
namespace LUS {
std::shared_ptr<IResource> KeyFrameSkelFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<KeyFrameSkel>(initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<KeyFrameSkelFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load Key Frame skel with version {}", resource->GetInitData()->ResourceVersion);
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void KeyFrameSkelFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
std::shared_ptr<KeyFrameSkel> skel = std::static_pointer_cast<KeyFrameSkel>(resource);
ZKeyframeSkelType skelType;
ResourceVersionFactory::ParseFileBinary(reader, skel);
skel->skelData.limbCount = reader->ReadUByte();
skel->skelData.dListCount = reader->ReadUByte();
skelType = (ZKeyframeSkelType)reader->ReadUByte();
uint8_t numLimbs = reader->ReadUByte();
if (skelType == ZKeyframeSkelType::Normal) {
KeyFrameStandardLimb* limbs = new KeyFrameStandardLimb[numLimbs];
for (uint32_t i = 0; i < numLimbs; i++) {
std::string dlStr = reader->ReadString();
auto dl = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(dlStr.c_str());
limbs[i].dList = nullptr;
if (dl != nullptr) {
limbs[i].dList = dl->GetRawPointer();
}
limbs[i].numChildren = reader->ReadUByte();
limbs[i].flags = reader->ReadUByte();
limbs[i].translation.x = reader->ReadInt16();
limbs[i].translation.y = reader->ReadInt16();
limbs[i].translation.z = reader->ReadInt16();
}
skel->skelData.limbsStandard = limbs;
} else {
KeyFrameFlexLimb* limbs = new KeyFrameFlexLimb[numLimbs];
for (uint32_t i = 0; i < numLimbs; i++) {
std::string dlStr = reader->ReadString();
auto dl = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(dlStr.c_str());
limbs[i].dList = nullptr;
if (dl != nullptr) {
limbs[i].dList = dl->GetRawPointer();
}
limbs[i].numChildren = reader->ReadUByte();
limbs[i].flags = reader->ReadUByte();
limbs[i].callbackIndex = reader->ReadUByte();
}
skel->skelData.limbsFlex = limbs;
}
}
std::shared_ptr<IResource> KeyFrameAnimFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<KeyFrameAnim>(initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<KeyFrameAnimFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load Key Frame skel with version {}", resource->GetInitData()->ResourceVersion);
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void KeyFrameAnimFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
std::shared_ptr<KeyFrameAnim> anim = std::static_pointer_cast<KeyFrameAnim>(resource);
ZKeyframeSkelType skelType;
ResourceVersionFactory::ParseFileBinary(reader, anim);
skelType = (ZKeyframeSkelType)reader->ReadUByte();
uint32_t numBitFlags = reader->ReadUInt32();
if (skelType == ZKeyframeSkelType::Normal) {
anim->animData.bitFlags = new u8[numBitFlags];
for (uint32_t i = 0; i < numBitFlags; i++) {
anim->animData.bitFlags[i] = reader->ReadUByte();
}
} else {
anim->animData.bitFlagsFlex = new u16[numBitFlags];
for (uint32_t i = 0; i < numBitFlags; i++) {
anim->animData.bitFlagsFlex[i] = reader->ReadUInt16();
}
}
uint32_t numKf = reader->ReadUInt32();
anim->animData.keyFrames = new KeyFrame[numKf];
for (uint32_t i = 0; i < numKf; i++) {
anim->animData.keyFrames[i].frame = reader->ReadInt16();
anim->animData.keyFrames[i].value = reader->ReadInt16();
anim->animData.keyFrames[i].velocity = reader->ReadInt16();
}
uint32_t numKfNums = reader->ReadUInt32();
anim->animData.kfNums = new s16[numKfNums];
for (uint32_t i = 0; i < numKfNums; i++) {
anim->animData.kfNums[i] = reader->ReadInt16();
}
uint32_t numPresetValues = reader->ReadUInt32();
anim->animData.presetValues = new s16[numPresetValues];
for (uint32_t i = 0; i < numPresetValues; i++) {
anim->animData.presetValues[i] = reader->ReadInt16();
}
anim->animData.unk_10[0] = reader->ReadUByte();
anim->animData.unk_10[0] = reader->ReadUByte();
anim->animData.duration = reader->ReadUInt16();
}
} // namespace LUS
@@ -0,0 +1,29 @@
#pragma once
#include "Resource.h"
#include "ResourceFactory.h"
namespace LUS {
class KeyFrameSkelFactory : public ResourceFactory {
public:
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
};
class KeyFrameSkelFactoryV0 : public ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
};
class KeyFrameAnimFactory : public ResourceFactory {
public:
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
};
class KeyFrameAnimFactoryV0 : public ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
};
};
+33
View File
@@ -0,0 +1,33 @@
#include "KeyFrame.h"
namespace LUS {
LUS::KeyFrameSkel::~KeyFrameSkel() {
delete[] skelData.limbsFlex;
}
KeyFrameSkeletonData* KeyFrameSkel::GetPointer() {
return &skelData;
}
size_t KeyFrameSkel::GetPointerSize() {
return sizeof(skelData);
}
LUS::KeyFrameAnim::~KeyFrameAnim() {
delete[] animData.bitFlags;
delete[] animData.keyFrames;
delete[] animData.kfNums;
delete[] animData.presetValues;
}
KeyFrameAnimationData* LUS::KeyFrameAnim::GetPointer() {
return &animData;
}
size_t KeyFrameAnim::GetPointerSize() {
return sizeof(animData);
}
}
+87
View File
@@ -0,0 +1,87 @@
#pragma once
#include "Resource.h"
#include <libultraship/libultra/types.h>
namespace LUS {
typedef struct Vec3s {
s16 x;
s16 y;
s16 z;
} Vec3s;
// Keyframe limb?
typedef struct {
/* 0x00 */ void* dList;
/* 0x04 */ u8 numChildren;
/* 0x05 */ u8 flags;
/* 0x06 */ Vec3s translation; // FlexLimbs have translation data in their animations instead
} KeyFrameStandardLimb; // size = 0xC
// Other limb type?
typedef struct {
/* 0x00 */ void* dList;
/* 0x04 */ u8 numChildren;
/* 0x05 */ u8 flags;
/* 0x06 */ u8 callbackIndex; // transform callback index
} KeyFrameFlexLimb; // size = 0x8
typedef struct {
/* 0x00 */ u8 limbCount;
/* 0x01 */ u8 dListCount; // non-zero in object files, number of non-null-dlist limbs? used to know how many
// matrices to alloc for drawing
/* 0x04 */ union {
KeyFrameStandardLimb* limbsStandard;
KeyFrameFlexLimb* limbsFlex;
};
} KeyFrameSkeletonData; // Size = 0x8
typedef struct {
/* 0x00 */ s16 frame;
/* 0x02 */ s16 value;
/* 0x04 */ s16 velocity;
} KeyFrame; // Size = 0x6
typedef struct {
union {
/* 0x00 */ u8* bitFlags; // bitflags indicating whether to do keyframe interpolation or pull from preset values
/* 0x00 */ u16*
bitFlagsFlex; // bitflags indicating whether to do keyframe interpolation or pull from preset values
};
/* 0x04 */ KeyFrame* keyFrames; // keyframes array
/* 0x08 */ s16* kfNums; // number of keyframes for each limb
/* 0x0C */ s16* presetValues; // preset rotation (standard) or scale/rotation/translation (flex) values
/* 0x0C */ char unk_10[0x2];
/* 0x12 */ s16 duration;
} KeyFrameAnimationData; // Size = 0x14
class KeyFrameSkel : public Resource<KeyFrameSkeletonData> {
public:
using Resource::Resource;
KeyFrameSkel() : Resource(std::shared_ptr<ResourceInitData>()) {
}
~KeyFrameSkel();
KeyFrameSkeletonData* GetPointer();
size_t GetPointerSize();
KeyFrameSkeletonData skelData;
};
class KeyFrameAnim : public Resource<KeyFrameAnimationData> {
public:
using Resource::Resource;
KeyFrameAnim() : Resource(std::shared_ptr<ResourceInitData>()) {
}
~KeyFrameAnim();
KeyFrameAnimationData* GetPointer();
size_t GetPointerSize();
KeyFrameAnimationData animData;
};
} // namespace LUS
+9 -12
View File
@@ -970,15 +970,13 @@
<Texture Name="gSwordBeam2Tex" OutName="sword_beam_2" Format="i8" Width="32" Height="64" Offset="0x271E0" />
<DList Name="gSwordBeamDL" Offset="0x27CA0" />
<Blob Name="gameplay_keep_Blob_027DD0" Size="0x32C" Offset="0x27DD0" />
<Blob Name="gameplay_keep_Blob_0281DC" Size="0x14" Offset="0x281DC" />
<KeyFrameAnimation Name="gGameplayKeepKFAnim_281DC" Skel="0x2900C" Offset="0x281DC"/>
<DList Name="gameplay_keep_DL_0282D0" Offset="0x282D0" />
<Texture Name="gameplay_keep_Tex_0283B8" OutName="tex_0283B8" Format="i4" Width="64" Height="64" Offset="0x283B8" />
<Texture Name="gameplay_keep_Tex_028BB8" OutName="tex_028BB8" Format="i8" Width="32" Height="32" Offset="0x28BB8" />
<TextureAnimation Name="gameplay_keep_Matanimheader_028FEC" Offset="0x28FEC" />
<Blob Name="gameplay_keep_Blob_028FFC" Size="0x10" Offset="0x28FFC" />
<Blob Name="gameplay_keep_Blob_02900C" Size="0x14" Offset="0x2900C" />
<KeyFrameSkel Name="gGameplayKeepKFSkel_2900C" LimbType="Flex" Offset="0x2900C"/>
<Animation Name="gameplay_keep_Anim_029140" Offset="0x29140" />
<Texture Name="gameplay_keep_Tex_029150" OutName="tex_029150" Format="i8" Width="32" Height="64" Offset="0x29150" />
<DList Name="gameplay_keep_DL_029990" Offset="0x29990" />
@@ -1334,8 +1332,7 @@
<TextureAnimation Name="gameplay_keep_Matanimheader_06B6A0" Offset="0x6B6A0" />
<TextureAnimation Name="gameplay_keep_Matanimheader_06B730" Offset="0x6B730" />
<Blob Name="gameplay_keep_Blob_06B750" Size="0x3BC" Offset="0x6B750" />
<Blob Name="gameplay_keep_Blob_06BB0C" Size="0x14" Offset="0x6BB0C" />
<KeyFrameAnimation Name="gGameplayKeepKFAnim_6BB0C" Skel="0x6EB70" Offset="0x6BB0C"/>
<DList Name="gameplay_keep_DL_06BFE0" Offset="0x6BFE0" />
<DList Name="gameplay_keep_DL_06C098" Offset="0x6C098" />
@@ -1345,8 +1342,9 @@
<Texture Name="gameplay_keep_Tex_06D350" OutName="tex_06D350" Format="i4" Width="64" Height="64" Offset="0x6D350" />
<Texture Name="gameplay_keep_Tex_06DB50" OutName="tex_06DB50" Format="i4" Width="64" Height="64" Offset="0x6DB50" />
<Texture Name="gameplay_keep_Tex_06E350" OutName="tex_06E350" Format="i4" Width="64" Height="64" Offset="0x6E350" />
<Blob Name="gameplay_keep_Blob_06EB50" Size="0x20" Offset="0x6EB50" />
<Blob Name="gameplay_keep_Blob_06EB70" Size="0x10" Offset="0x6EB70" />
<KeyFrameSkel Name="gGameplayKeepKFSkel_6EB70" LimbType="Flex" Offset="0x6EB70"/>
<Texture Name="gameplay_keep_Tex_06EB80" OutName="tex_06EB80" Format="i4" Width="64" Height="64" Offset="0x6EB80" />
<DList Name="gameplay_keep_DL_06F380" Offset="0x6F380" />
<DList Name="gameplay_keep_DL_06F9F0" Offset="0x6F9F0" />
@@ -1451,8 +1449,7 @@
<DList Name="gameplay_keep_DL_081628" Offset="0x81628" />
<Texture Name="gameplay_keep_Tex_0816C0" OutName="tex_0816C0" Format="rgba16" Width="16" Height="32" Offset="0x816C0" />
<Blob Name="gameplay_keep_Blob_081AC0" Size="0x1A74" Offset="0x81AC0" />
<Blob Name="gameplay_keep_Blob_083534" Size="0x1C" Offset="0x83534" />
<KeyFrameAnimation Name="gGameplayKeepKFAnim_83534" Skel="0x85640" Offset="0x83534"/>
<DList Name="gameplay_keep_DL_084790" Offset="0x84790" />
<DList Name="gameplay_keep_DL_0847E0" Offset="0x847E0" />
@@ -1484,8 +1481,8 @@
<DList Name="gameplay_keep_DL_0853B0" Offset="0x853B0" />
<DList Name="gameplay_keep_DL_085418" Offset="0x85418" />
<DList Name="gameplay_keep_DL_085490" Offset="0x85490" />
<Blob Name="gameplay_keep_Blob_085510" Size="0x130" Offset="0x85510" />
<Blob Name="gameplay_keep_Blob_085640" Size="0x10" Offset="0x85640" />
<KeyFrameSkel Name="gGameplayKeepKFSkel_85640" LimbType="Flex" Offset="0x85640"/>
<!-- Zora Elegy of Emptiness Shell -->
<DList Name="gElegyShellZoraDL" Offset="0x89070" /> <!-- Original name is "pzs_zo_model" -->
+4 -3
View File
@@ -11,8 +11,10 @@
<Texture Name="gOpenMouthMoonFarSideTex" OutName="open_mouth_moon_far_side" Format="ci4" Width="64" Height="64" Offset="0x3CE8" />
<Texture Name="gOpenMouthMoonFaceTex" OutName="open_mouth_moon_face" Format="ci4" Width="64" Height="64" Offset="0x44E8" />
<Texture Name="gOpenMouthMoonTeethTex" OutName="open_mouth_moon_teeth" Format="rgba16" Width="64" Height="32" Offset="0x4CE8" />
<!-- <Blob Name="object_fall2_Blob_005CE8" Size="0x20C" Offset="0x5CE8" /> -->
<Blob Name="object_fall2_Blob_005EF4" Size="0x1C" Offset="0x5EF4" /> <!-- Original name might be "moon_start_anm"; needs c_keyframe docs to know if it's this one or the one below. -->
<KeyFrameAnimation Name="gFall2FKAnim_5EF4" Skel="0x8898" Offset="0x5EF4"/>
<KeyFrameSkel Name="gFall2KFSkel_8898" LimbType="Flex" Offset="0x8898"/>
<Array Name="object_fall2_Vtx_005F10" Count="239" Offset="0x5F10">
<Vtx />
</Array>
@@ -29,6 +31,5 @@
<Texture Name="object_fall2_Tex_007838" OutName="tex_007838" Format="i4" Width="64" Height="64" Offset="0x7838" />
<Texture Name="object_fall2_Tex_008038" OutName="tex_008038" Format="i4" Width="64" Height="64" Offset="0x8038" />
<TextureAnimation Name="object_fall2_Matanimheader_008840" Offset="0x8840" />
<Blob Name="object_fall2_Blob_008898" Size="0x8" Offset="0x8898" /> <!-- Original name might be "moon_start_anm"; needs c_keyframe docs to know if it's this one or the one above. -->
</File>
</Root>
+7 -5
View File
@@ -1,8 +1,8 @@
<Root>
<File Name="object_moonend" Segment="6">
<Blob Name="object_moonend_Blob_000000" Size="0x1214" Offset="0x0" />
<Blob Name="object_moonend_Blob_001214" Size="0x1C" Offset="0x1214" />
<!--<Blob Name="object_moonend_Blob_000000" Size="0x1214" Offset="0x0" />
<Blob Name="object_moonend_Blob_001214" Size="0x1C" Offset="0x1214" />-->
<KeyFrameAnimation Name="gMoonendKFAnim_1214" Skel="0xB5A0" Offset="0x1214"/>
<DList Name="object_moonend_DL_0055F0" Offset="0x55F0" />
<DList Name="object_moonend_DL_0061F8" Offset="0x61F8" />
<DList Name="object_moonend_DL_006460" Offset="0x6460" />
@@ -22,8 +22,10 @@
<Texture Name="object_moonend_Tex_00A530" OutName="tex_00A530" Format="i8" Width="64" Height="64" Offset="0xA530" />
<TextureAnimation Name="object_moonend_Matanimheader_00B540" Offset="0xB540" />
<Blob Name="object_moonend_Blob_00B550" Size="0x50" Offset="0xB550" />
<Blob Name="object_moonend_Blob_00B5A0" Size="0x170" Offset="0xB5A0" />
<KeyFrameSkel Name="gMoonendKFSkel_B5A0" LimbType="Flex" Offset="0xB5A0"/>
<!--<Blob Name="object_moonend_Blob_00B550" Size="0x50" Offset="0xB550" />
<Blob Name="object_moonend_Blob_00B5A0" Size="0x170" Offset="0xB5A0" />-->
<DList Name="object_moonend_DL_00CCF0" Offset="0xCCF0" />
<DList Name="object_moonend_DL_00CF58" Offset="0xCF58" />
+2 -6
View File
@@ -1,8 +1,6 @@
<Root>
<File Name="object_syoten" Segment="6">
<Blob Name="object_syoten_Blob_000000" Size="0x23C" Offset="0x0" />
<Blob Name="object_syoten_Blob_00023C" Size="0x14" Offset="0x23C" />
<KeyFrameAnimation Name="gSyotenKFAnim_023C" Skel="0x1328" Offset="0x023C"/>
<DList Name="object_syoten_DL_000450" Offset="0x450" />
<DList Name="object_syoten_DL_000518" Offset="0x518" />
<DList Name="object_syoten_DL_0005E0" Offset="0x5E0" />
@@ -15,9 +13,7 @@
<Texture Name="object_syoten_Tex_000E90" OutName="tex_000E90" Format="i8" Width="32" Height="32" Offset="0xE90" />
<TextureAnimation Name="object_syoten_Matanimheader_001298" Offset="0x1298" />
<!-- <Blob Name="object_syoten_Blob_0012A0" Size="0x88" Offset="0x12A0" /> -->
<Blob Name="object_syoten_Blob_001328" Size="0x8" Offset="0x1328" />
<KeyFrameSkel Name="gSyotenKFSkel_1328" LimbType="Flex" Offset="0x1328"/>
<DList Name="object_syoten_DL_001370" Offset="0x1370" />
<TextureAnimation Name="object_syoten_Matanimheader_001448" Offset="0x1448" />
<DList Name="object_syoten_DL_001730" Offset="0x1730" />
+56 -11
View File
@@ -1,4 +1,5 @@
#include "global.h"
#include "BenPort.h"
#define FMOD(x, mod) ((x) - ((s32)((x) * (1.0f / (mod))) * (f32)(mod)))
@@ -124,8 +125,18 @@ void Keyframe_InitFlex(KFSkelAnimeFlex* kfSkelAnime, KeyFrameSkeleton* skeleton,
Vec3s* jointTable, Vec3s* morphTable, UnkKeyframeCallback* callbacks) {
Keyframe_ResetFlex(kfSkelAnime);
FrameCtrl_Init(&kfSkelAnime->frameCtrl);
kfSkelAnime->skeleton = (KeyFrameSkeleton*)Lib_SegmentedToVirtual(skeleton);
kfSkelAnime->animation = (KeyFrameAnimation*)Lib_SegmentedToVirtual(animation);
KeyFrameSkeleton* skel = skeleton;
KeyFrameAnimation* anim = animation;
if (ResourceMgr_OTRSigCheck(skel)) {
skel = (KeyFrameSkeleton*)ResourceMgr_LoadKeyFrameSkelByName(skeleton);
}
if (ResourceMgr_OTRSigCheck(anim)) {
anim = (KeyFrameSkeleton*)ResourceMgr_LoadKeyFrameSkelByName(animation);
}
kfSkelAnime->skeleton = skel;
kfSkelAnime->animation = anim;
kfSkelAnime->jointTable = jointTable;
kfSkelAnime->morphTable = morphTable;
kfSkelAnime->callbacks = callbacks;
@@ -178,17 +189,29 @@ void Keyframe_FlexChangeAnim(KFSkelAnimeFlex* kfSkelAnime, KeyFrameSkeleton* ske
f32 startTime, f32 endTime, f32 t, f32 speed, f32 morphFrames, s32 animMode) {
kfSkelAnime->morphFrames = morphFrames;
if (kfSkelAnime->skeleton != skeleton) {
kfSkelAnime->skeleton = (KeyFrameSkeleton*)Lib_SegmentedToVirtual(skeleton);
if (ResourceMgr_OTRSigCheck(skeleton)) {
skeleton = ResourceMgr_LoadKeyFrameSkelByName(skeleton);
}
kfSkelAnime->animation = (KeyFrameAnimation*)Lib_SegmentedToVirtual(animation);
if (kfSkelAnime->skeleton != skeleton) {
kfSkelAnime->skeleton = skeleton;
}
if (ResourceMgr_OTRSigCheck(animation)) {
animation = ResourceMgr_LoadKeyFrameAnimByName(animation);
}
kfSkelAnime->animation = animation;
FrameCtrl_SetProperties(&kfSkelAnime->frameCtrl, startTime, endTime, kfSkelAnime->animation->duration, t, speed,
animMode);
}
void Keyframe_FlexChangeAnimQuick(KFSkelAnimeFlex* kfSkelAnime, KeyFrameAnimation* animation) {
kfSkelAnime->animation = (KeyFrameAnimation*)Lib_SegmentedToVirtual(animation);
if (ResourceMgr_OTRSigCheck(animation)) {
animation = ResourceMgr_LoadKeyFrameAnimByName(animation);
}
kfSkelAnime->animation = animation;
kfSkelAnime->frameCtrl.duration = kfSkelAnime->animation->duration;
}
@@ -538,8 +561,17 @@ void Keyframe_InitStandard(KFSkelAnime* kfSkelAnime, KeyFrameSkeleton* skeleton,
Vec3s* jointTable, Vec3s* morphTable) {
Keyframe_ResetStandard(kfSkelAnime);
FrameCtrl_Init(&kfSkelAnime->frameCtrl);
kfSkelAnime->skeleton = (KeyFrameSkeleton*)Lib_SegmentedToVirtual(skeleton);
kfSkelAnime->animation = (KeyFrameAnimation*)Lib_SegmentedToVirtual(animation);
if (ResourceMgr_OTRSigCheck(animation)) {
animation = ResourceMgr_LoadKeyFrameAnimByName(animation);
}
if (ResourceMgr_OTRSigCheck(skeleton)) {
skeleton = ResourceMgr_LoadKeyFrameSkelByName(skeleton);
}
kfSkelAnime->skeleton = skeleton;
kfSkelAnime->animation = animation;
kfSkelAnime->jointTable = jointTable;
kfSkelAnime->morphTable = morphTable;
}
@@ -595,8 +627,17 @@ void Keyframe_StandardChangeAnim(KFSkelAnime* kfSkelAnime, KeyFrameSkeleton* ske
f32 startTime, f32 endTime, f32 t, f32 speed, f32 morphFrames, s32 animMode,
Vec3s* rotOffsetsTable) {
kfSkelAnime->morphFrames = morphFrames;
kfSkelAnime->skeleton = (KeyFrameSkeleton*)Lib_SegmentedToVirtual(skeleton);
kfSkelAnime->animation = (KeyFrameAnimation*)Lib_SegmentedToVirtual(animation);
if (ResourceMgr_OTRSigCheck(animation)) {
animation = ResourceMgr_LoadKeyFrameAnimByName(animation);
}
if (ResourceMgr_OTRSigCheck(skeleton)) {
skeleton = ResourceMgr_LoadKeyFrameSkelByName(skeleton);
}
kfSkelAnime->skeleton = skeleton;
kfSkelAnime->animation = animation;
FrameCtrl_SetProperties(&kfSkelAnime->frameCtrl, startTime, endTime, kfSkelAnime->animation->duration, t, speed,
animMode);
@@ -604,7 +645,11 @@ void Keyframe_StandardChangeAnim(KFSkelAnime* kfSkelAnime, KeyFrameSkeleton* ske
}
void Keyframe_StandardChangeAnimQuick(KFSkelAnime* kfSkelAnime, KeyFrameAnimation* animation) {
kfSkelAnime->animation = Lib_SegmentedToVirtual(animation);
if (ResourceMgr_OTRSigCheck(animation)) {
animation = ResourceMgr_LoadKeyFrameAnimByName(animation);
}
kfSkelAnime->animation = animation;
kfSkelAnime->frameCtrl.duration = kfSkelAnime->animation->duration;
}
@@ -46,10 +46,10 @@ void DemoMoonend_Init(Actor* thisx, PlayState* play) {
this->actionFunc = func_80C17B60;
} else {
Actor_SetScale(&this->actor, 0.095f);
Keyframe_InitFlex(&this->skeletonInfo, (void*)object_moonend_Blob_00B5A0, (void*)object_moonend_Blob_001214,
Keyframe_InitFlex(&this->skeletonInfo, gMoonendKFSkel_B5A0, gMoonendKFAnim_1214,
this->jointTable,
this->morphTable, NULL);
Keyframe_FlexPlayOnce(&this->skeletonInfo, (void*)object_moonend_Blob_001214);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gMoonendKFAnim_1214);
this->cueType = CS_CMD_ACTOR_CUE_560;
this->actionFunc = func_80C17C48;
this->actor.home.rot.z = 0;
@@ -111,13 +111,13 @@ void func_80C17C48(DemoMoonend* this, PlayState* play) {
switch (this->cueId) {
case 1:
this->actor.draw = DemoMoonend_Draw;
Keyframe_FlexPlayOnce(&this->skeletonInfo, (void*)object_moonend_Blob_001214);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gMoonendKFAnim_1214);
this->skeletonInfo.frameCtrl.speed = 0.0f;
break;
case 2:
this->actor.draw = DemoMoonend_Draw;
Keyframe_FlexPlayOnce(&this->skeletonInfo, (void*)object_moonend_Blob_001214);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gMoonendKFAnim_1214);
this->skeletonInfo.frameCtrl.speed = 2.0f / 3.0f;
Actor_PlaySfx(&this->actor, NA_SE_EV_MOON_EXPLOSION);
this->actor.home.rot.z = 1;
@@ -73,10 +73,10 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) {
switch (DEMOSYOTEN_GET_F(&this->actor)) {
case DEMOSYOTEN_F_0:
Keyframe_InitFlex(&this->unk_144, (void*)object_syoten_Blob_001328, (void*)object_syoten_Blob_00023C,
Keyframe_InitFlex(&this->unk_144, gSyotenKFSkel_1328, gSyotenKFAnim_023C,
this->unk_174,
this->unk_2A6, NULL);
Keyframe_FlexPlayLoop(&this->unk_144, (void*)object_syoten_Blob_00023C);
Keyframe_FlexPlayLoop(&this->unk_144, gSyotenKFAnim_023C);
this->actor.draw = NULL;
this->actionFunc = func_80C16A74;
this->actor.child =
@@ -5,6 +5,7 @@
*/
#include "z_eff_change.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#define FLAGS (ACTOR_FLAG_10)
@@ -50,9 +51,9 @@ void EffChange_Init(Actor* thisx, PlayState* play) {
EffChange_SetColors(this, EFFCHANGE_GET_COLORS(thisx));
Actor_SetScale(&this->actor, 0.075f);
this->primColors[3] = 0;
Keyframe_InitFlex(&this->skeletonInfo, gameplay_keep_Blob_02900C, gameplay_keep_Blob_0281DC, this->jointTable,
Keyframe_InitFlex(&this->skeletonInfo, gGameplayKeepKFSkel_2900C, gGameplayKeepKFAnim_281DC, this->jointTable,
this->morphTable, NULL);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gameplay_keep_Blob_0281DC);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gGameplayKeepKFAnim_281DC);
this->step = 0;
this->actor.shape.rot.y = 0;
this->skeletonInfo.frameCtrl.speed = (2.0f / 3.0f);
@@ -5,6 +5,7 @@
*/
#include "z_en_fall2.h"
#include "objects/object_fall2/object_fall2.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)
@@ -35,10 +36,10 @@ void EnFall2_Init(Actor* thisx, PlayState* play) {
Actor_SetScale(&this->actor, 1.0f);
this->actionFunc = EnFall2_DoNothing;
Keyframe_InitFlex(&this->skeletonInfo, (void*)object_fall2_Blob_008898, (void*)object_fall2_Blob_005EF4,
Keyframe_InitFlex(&this->skeletonInfo, gFall2KFSkel_8898, gFall2FKAnim_5EF4,
this->unk174, this->unk228,
NULL);
Keyframe_FlexPlayLoop(&this->skeletonInfo, (void*)object_fall2_Blob_005EF4);
Keyframe_FlexPlayLoop(&this->skeletonInfo, (void*)gFall2FKAnim_5EF4);
this->unk2DC = Lib_SegmentedToVirtual((void*)object_fall2_Matanimheader_008840);
Actor_SetScale(&this->actor, 0.02f);
this->actionFunc = EnFall2_HandleCutscene;
@@ -186,17 +186,17 @@ void EnTest_Init(Actor* thisx, PlayState* play2) {
this->surfaceMaterial = SurfaceType_GetMaterial(&play->colCtx, thisx->floorPoly, bgId);
}
Keyframe_InitFlex(&this->skeletonInfo, (void*)gameplay_keep_Blob_06EB70, (void*)gameplay_keep_Blob_06BB0C,
Keyframe_InitFlex(&this->skeletonInfo, gGameplayKeepKFSkel_6EB70, gGameplayKeepKFAnim_6BB0C,
this->unk_178,
this->unk_1C0, NULL);
Keyframe_FlexPlayOnce(&this->skeletonInfo, (void*)gameplay_keep_Blob_06BB0C);
Keyframe_FlexPlayOnce(&this->skeletonInfo, gGameplayKeepKFAnim_6BB0C);
this->skeletonInfo.frameCtrl.curTime = 9.0f;
func_80862B70(this->unk_20C);
}
void EnTest_Destroy(Actor* thisx, PlayState* play) {
EnTest* this = THIS;
Keyframe_DestroyFlex(&this->skeletonInfo);
}
@@ -397,9 +397,9 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) {
this->unk_1E90 = player->actor.scale.x;
this->unk_1E94 = player->actor.scale.z;
Keyframe_InitFlex(&this->unk_18CC, &gameplay_keep_Blob_085640, &gameplay_keep_Blob_083534, this->unk_18FC,
Keyframe_InitFlex(&this->unk_18CC, gGameplayKeepKFSkel_85640, gGameplayKeepKFAnim_83534, this->unk_18FC,
this->unk_1BA8, NULL);
Keyframe_FlexPlayOnce(&this->unk_18CC, &gameplay_keep_Blob_083534);
Keyframe_FlexPlayOnce(&this->unk_18CC, gGameplayKeepKFAnim_83534);
func_80AF0838(this->unk_15C);
func_80AF1730(&this->unk_148);