Implemented Animation Clip asset and animation controller #410
|
@ -60,6 +60,7 @@ enum class AssetType : AssetTypeMeta
|
||||||
AUDIO_BANK,
|
AUDIO_BANK,
|
||||||
ANIM_CONTAINER,
|
ANIM_CONTAINER,
|
||||||
ANIM_CLIP,
|
ANIM_CLIP,
|
||||||
|
ANIM_CONTROLLER,
|
||||||
MAX_COUNT
|
MAX_COUNT
|
||||||
};
|
};
|
||||||
constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) };
|
constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) };
|
||||||
|
@ -82,6 +83,7 @@ constexpr std::string_view SCENE_FOLDER{ "/Scenes/" };
|
||||||
constexpr std::string_view PREFAB_FOLDER{ "/Prefabs/" };
|
constexpr std::string_view PREFAB_FOLDER{ "/Prefabs/" };
|
||||||
constexpr std::string_view MATERIAL_FOLDER{ "/Materials/" };
|
constexpr std::string_view MATERIAL_FOLDER{ "/Materials/" };
|
||||||
constexpr std::string_view ANIM_CLIP_FOLDER{ "/Animations/" };
|
constexpr std::string_view ANIM_CLIP_FOLDER{ "/Animations/" };
|
||||||
|
constexpr std::string_view ANIM_CONTROLLER_FOLDER{ "/Animation Controllers/" };
|
||||||
|
|
||||||
|
|
||||||
// ASSET EXTENSIONS
|
// ASSET EXTENSIONS
|
||||||
|
@ -99,6 +101,7 @@ constexpr std::string_view MATERIAL_EXTENSION {".shmat"};
|
||||||
constexpr std::string_view TEXTURE_EXTENSION {".shtex"};
|
constexpr std::string_view TEXTURE_EXTENSION {".shtex"};
|
||||||
constexpr std::string_view MODEL_EXTENSION{ ".shmodel" };
|
constexpr std::string_view MODEL_EXTENSION{ ".shmodel" };
|
||||||
constexpr std::string_view ANIM_CONTAINER_EXTENSION{ ".shanimcontainer" };
|
constexpr std::string_view ANIM_CONTAINER_EXTENSION{ ".shanimcontainer" };
|
||||||
|
constexpr std::string_view ANIM_CONTROLLER_EXTENSION{ ".shanimcontroller" };
|
||||||
constexpr std::string_view FILLER_EXTENSION{"dummy"};
|
constexpr std::string_view FILLER_EXTENSION{"dummy"};
|
||||||
|
|
||||||
constexpr std::string_view EXTENSIONS[] = {
|
constexpr std::string_view EXTENSIONS[] = {
|
||||||
|
@ -115,6 +118,7 @@ constexpr std::string_view EXTENSIONS[] = {
|
||||||
FONT_EXTENSION,
|
FONT_EXTENSION,
|
||||||
AUDIO_BANK_EXTENSION,
|
AUDIO_BANK_EXTENSION,
|
||||||
ANIM_CONTAINER_EXTENSION,
|
ANIM_CONTAINER_EXTENSION,
|
||||||
|
ANIM_CONTROLLER_EXTENSION,
|
||||||
FILLER_EXTENSION
|
FILLER_EXTENSION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -640,9 +640,13 @@ namespace SHADE
|
||||||
if (ImGui::CollapsingHeader(componentType.get_name().data()))
|
if (ImGui::CollapsingHeader(componentType.get_name().data()))
|
||||||
{
|
{
|
||||||
DrawContextMenu(component);
|
DrawContextMenu(component);
|
||||||
|
|
||||||
|
/* Animation Rig */
|
||||||
Handle<SHRig> const& rig = component->GetRig();
|
Handle<SHRig> const& rig = component->GetRig();
|
||||||
const auto RIG_NAME = rig ? SHResourceManager::GetAssetName<SHRig>(rig).value_or("") : "";
|
const auto RIG_NAME = rig ? SHResourceManager::GetAssetName<SHRig>(rig).value_or("") : "";
|
||||||
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Rig", RIG_NAME, [component]()
|
SHEditorWidgets::DragDropReadOnlyField<AssetID>
|
||||||
|
(
|
||||||
|
"Rig", RIG_NAME, [component]()
|
||||||
{
|
{
|
||||||
Handle<SHRig> const& rig = component->GetRig();
|
Handle<SHRig> const& rig = component->GetRig();
|
||||||
return SHResourceManager::GetAssetID<SHRig>(rig).value_or(0);
|
return SHResourceManager::GetAssetID<SHRig>(rig).value_or(0);
|
||||||
|
@ -651,12 +655,14 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
if (SHAssetManager::GetType(id) != AssetType::MODEL)
|
if (SHAssetManager::GetType(id) != AssetType::MODEL)
|
||||||
{
|
{
|
||||||
SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!")
|
SHLOG_WARNING("Attempted to assign non mesh rig asset to Animator Rig property!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
component->SetRig(SHResourceManager::LoadOrGet<SHRig>(id));
|
component->SetRig(SHResourceManager::LoadOrGet<SHRig>(id));
|
||||||
SHResourceManager::FinaliseChanges();
|
SHResourceManager::FinaliseChanges();
|
||||||
}, SHDragDrop::DRAG_RESOURCE);
|
},
|
||||||
|
SHDragDrop::DRAG_RESOURCE
|
||||||
|
);
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
{
|
{
|
||||||
if (Handle<SHRig> const& rig = component->GetRig())
|
if (Handle<SHRig> const& rig = component->GetRig())
|
||||||
|
@ -665,6 +671,37 @@ namespace SHADE
|
||||||
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Animation Controller */
|
||||||
|
Handle<SHAnimationController> animController = component->GetAnimationController();
|
||||||
|
const auto AC_NAME = animController ? SHResourceManager::GetAssetName<SHAnimationController>(animController).value_or("") : "";
|
||||||
|
SHEditorWidgets::DragDropReadOnlyField<AssetID>
|
||||||
|
(
|
||||||
|
"Animation Controller", AC_NAME, [component]()
|
||||||
|
{
|
||||||
|
Handle<SHAnimationController> ac = component->GetAnimationController();
|
||||||
|
return SHResourceManager::GetAssetID<SHAnimationController>(ac).value_or(0);
|
||||||
|
},
|
||||||
|
[component](AssetID const& id)
|
||||||
|
{
|
||||||
|
if (SHAssetManager::GetType(id) != AssetType::ANIM_CONTROLLER)
|
||||||
|
{
|
||||||
|
SHLOG_WARNING("Attempted to assign non animation controller asset to Animator Animation Controller property!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
component->SetAnimationController(SHResourceManager::LoadOrGet<SHAnimationController>(id));
|
||||||
|
SHResourceManager::FinaliseChanges();
|
||||||
|
},
|
||||||
|
SHDragDrop::DRAG_RESOURCE
|
||||||
|
);
|
||||||
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
|
{
|
||||||
|
if (Handle<SHAnimationController> ac = component->GetAnimationController())
|
||||||
|
{
|
||||||
|
AssetID assetID = SHResourceManager::GetAssetID<SHAnimationController>(ac).value_or(0);
|
||||||
|
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue