Added skeleton creation

This commit is contained in:
Antoine Pilote
2023-09-05 20:28:33 -04:00
parent 33e04e9216
commit e125bf5fdb
6 changed files with 125 additions and 6 deletions

View File

@@ -24,6 +24,7 @@
#include "src/Scene/Components/WrenScriptComponent.h"
#include "src/Scene/Components/BSPBrushComponent.h"
#include "src/Scene/Components/InterfaceComponent.h"
#include "src/Scene/Components/SkinnedModelComponent.h"
#include <fstream>
#include <future>
@@ -448,4 +449,31 @@ namespace Nuake
return true;
}
void Scene::CreateSkeleton(Entity& entity)
{
// We cannot create a component if the entity doesn't have a skinned model
if (!entity.HasComponent<SkinnedModelComponent>())
{
const std::string msg = "Cannot create a skeleton on entity: " + std::to_string(entity.GetID());
Logger::Log(msg);
return;
}
SkinnedModelComponent& component = entity.GetComponent<SkinnedModelComponent>();
for (Ref<SkinnedMesh>& model : component.ModelResource->GetMeshes())
{
auto& bones = model->GetBones();
if (bones.size() > 0)
{
for (auto& bone : bones)
{
auto& parentComponent = entity.GetComponent<ParentComponent>();
Entity boneEntity = CreateEntity(bone.Name);
entity.AddChild(boneEntity);
}
}
}
}
}