mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-15 06:40:22 -05:00
playeranimation
This commit is contained in:
parent
e87ade4ebd
commit
60e27edab5
@ -322,8 +322,8 @@ OTRGlobals::OTRGlobals() {
|
|||||||
|
|
||||||
auto loader = context->GetResourceManager()->GetResourceLoader();
|
auto loader = context->GetResourceManager()->GetResourceLoader();
|
||||||
loader->RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryAnimationV0>(), RESOURCE_FORMAT_BINARY, "SOH_Animation", static_cast<uint32_t>(SohResourceType::SOH_Animation), 0);
|
loader->RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryAnimationV0>(), RESOURCE_FORMAT_BINARY, "SOH_Animation", static_cast<uint32_t>(SohResourceType::SOH_Animation), 0);
|
||||||
|
loader->RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryPlayerAnimationV0>(), RESOURCE_FORMAT_BINARY, "SOH_PlayerAnimation", static_cast<uint32_t>(SohResourceType::SOH_PlayerAnimation), 0);
|
||||||
|
|
||||||
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_PlayerAnimation), std::make_shared<LUS::PlayerAnimationFactory>());
|
|
||||||
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_Room), std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
|
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_Room), std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
|
||||||
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_CollisionHeader), std::make_shared<LUS::CollisionHeaderFactory>());
|
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_CollisionHeader), std::make_shared<LUS::CollisionHeaderFactory>());
|
||||||
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_Skeleton), std::make_shared<LUS::SkeletonFactory>());
|
loader->RegisterResourceFactory(static_cast<uint32_t>(SohResourceType::SOH_Skeleton), std::make_shared<LUS::SkeletonFactory>());
|
||||||
|
@ -2,40 +2,26 @@
|
|||||||
#include "soh/resource/type/PlayerAnimation.h"
|
#include "soh/resource/type/PlayerAnimation.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
namespace LUS {
|
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||||
std::shared_ptr<IResource>
|
if (file->InitData->Format != RESOURCE_FORMAT_BINARY) {
|
||||||
PlayerAnimationFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
SPDLOG_ERROR("resource file format does not match factory format.");
|
||||||
auto resource = std::make_shared<PlayerAnimation>(initData);
|
return nullptr;
|
||||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
|
||||||
|
|
||||||
switch (resource->GetInitData()->ResourceVersion) {
|
|
||||||
case 0:
|
|
||||||
factory = std::make_shared<PlayerAnimationFactoryV0>();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (factory == nullptr)
|
if (file->Reader == nullptr) {
|
||||||
{
|
SPDLOG_ERROR("Failed to load resource: File has Reader ({} - {})", file->InitData->Type,
|
||||||
SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->GetInitData()->ResourceVersion);
|
file->InitData->Path);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory->ParseFileBinary(reader, resource);
|
auto playerAnimation = std::make_shared<PlayerAnimation>(file->InitData);
|
||||||
|
|
||||||
return resource;
|
uint32_t numEntries = file->Reader->ReadUInt32();
|
||||||
}
|
|
||||||
|
|
||||||
void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
|
||||||
std::shared_ptr<IResource> resource)
|
|
||||||
{
|
|
||||||
std::shared_ptr<PlayerAnimation> playerAnimation = std::static_pointer_cast<PlayerAnimation>(resource);
|
|
||||||
ResourceVersionFactory::ParseFileBinary(reader, playerAnimation);
|
|
||||||
|
|
||||||
uint32_t numEntries = reader->ReadUInt32();
|
|
||||||
playerAnimation->limbRotData.reserve(numEntries);
|
playerAnimation->limbRotData.reserve(numEntries);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numEntries; i++) {
|
for (uint32_t i = 0; i < numEntries; i++) {
|
||||||
playerAnimation->limbRotData.push_back(reader->ReadInt16());
|
playerAnimation->limbRotData.push_back(file->Reader->ReadInt16());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} // namespace LUS
|
return playerAnimation;
|
||||||
|
};
|
||||||
|
@ -3,15 +3,7 @@
|
|||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "ResourceFactory.h"
|
#include "ResourceFactory.h"
|
||||||
|
|
||||||
namespace LUS {
|
class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactory {
|
||||||
class PlayerAnimationFactory : public ResourceFactory {
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<IResource>
|
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerAnimationFactoryV0 : public ResourceVersionFactory {
|
|
||||||
public:
|
|
||||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
|
||||||
};
|
|
||||||
}; // namespace LUS
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "PlayerAnimation.h"
|
#include "PlayerAnimation.h"
|
||||||
#include <libultraship/libultra/gbi.h>
|
#include <libultraship/libultra/gbi.h>
|
||||||
|
|
||||||
namespace LUS {
|
|
||||||
int16_t* PlayerAnimation::GetPointer() {
|
int16_t* PlayerAnimation::GetPointer() {
|
||||||
return limbRotData.data();
|
return limbRotData.data();
|
||||||
}
|
}
|
||||||
@ -9,4 +8,3 @@ int16_t* PlayerAnimation::GetPointer() {
|
|||||||
size_t PlayerAnimation::GetPointerSize() {
|
size_t PlayerAnimation::GetPointerSize() {
|
||||||
return limbRotData.size() * sizeof(int16_t);
|
return limbRotData.size() * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
} // namespace LUS
|
|
@ -7,8 +7,6 @@
|
|||||||
#include "Vec3f.h"
|
#include "Vec3f.h"
|
||||||
#include "Color3b.h"
|
#include "Color3b.h"
|
||||||
|
|
||||||
namespace LUS {
|
|
||||||
|
|
||||||
class PlayerAnimation : public Resource<int16_t> {
|
class PlayerAnimation : public Resource<int16_t> {
|
||||||
public:
|
public:
|
||||||
using Resource::Resource;
|
using Resource::Resource;
|
||||||
@ -20,4 +18,3 @@ class PlayerAnimation : public Resource<int16_t> {
|
|||||||
|
|
||||||
std::vector<int16_t> limbRotData;
|
std::vector<int16_t> limbRotData;
|
||||||
};
|
};
|
||||||
} // namespace LUS
|
|
Loading…
Reference in New Issue
Block a user