diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index fcceacab..80bb28ff 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -47,6 +47,7 @@ #include "Tools/Logger/SHLogger.h" #include "Tools/SHDebugDraw.h" +#include "Resource/SHResourceManager.h" using namespace SHADE; @@ -170,6 +171,10 @@ namespace Sandbox // Link up SHDebugDraw SHDebugDraw::Init(SHSystemManager::GetSystem()); + + auto clip = SHResourceManager::LoadOrGet(77816045); + auto rig = SHResourceManager::LoadOrGet(77816045); + int i = 0; } void SBApplication::Update(void) diff --git a/SHADE_Engine/src/Animation/SHAnimatorComponent.h b/SHADE_Engine/src/Animation/SHAnimatorComponent.h index d6adfa49..6c525be2 100644 --- a/SHADE_Engine/src/Animation/SHAnimatorComponent.h +++ b/SHADE_Engine/src/Animation/SHAnimatorComponent.h @@ -93,6 +93,12 @@ namespace SHADE /// Reference to a vector of the bone matrices. const std::vector& GetBoneMatrices() const noexcept { return boneMatrices; } /// + /// Retrieve the currently set model rig. + /// + /// Handle to the currently set rig. + Handle GetRig() const noexcept { return rig; } + /// + /// /// Retrieve the currently set animation clip. /// /// Handle to the currently set animation clip. diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 45964930..782f5636 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -22,6 +22,7 @@ #include "Serialization/SHSerializationHelper.hpp" #include "Tools/Utilities/SHClipboardUtilities.h" #include "SHInspectorCommands.h" +#include "Animation/SHAnimatorComponent.h" namespace SHADE { template @@ -574,4 +575,60 @@ namespace SHADE } ImGui::PopID(); } + + template<> + static void DrawComponent(SHAnimatorComponent* component) + { + if (!component) + return; + ImGui::PushID(SHFamilyID::GetID()); + const auto componentType = rttr::type::get(*component); + SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); + ImGui::SameLine(); + if (ImGui::CollapsingHeader(componentType.get_name().data())) + { + DrawContextMenu(component); + Handle const& rig = component->GetRig(); + const auto RIG_NAME = rig ? SHResourceManager::GetAssetName(rig).value_or("") : ""; + SHEditorWidgets::DragDropReadOnlyField("Rig", RIG_NAME, [component]() + { + Handle const& rig = component->GetRig(); + return SHResourceManager::GetAssetID(rig).value_or(0); + }, + [component](AssetID const& id) + { + if (SHAssetManager::GetType(id) != AssetType::MESH) + { + SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!") + return; + } + component->SetRig(SHResourceManager::LoadOrGet(id)); + SHResourceManager::FinaliseChanges(); + }, SHDragDrop::DRAG_RESOURCE); + + Handle const& clip = component->GetCurrentClip(); + const auto CLIP_NAME = rig ? SHResourceManager::GetAssetName(clip).value_or("") : ""; + SHEditorWidgets::DragDropReadOnlyField("Material", CLIP_NAME, + [component]() + { + Handle const& clip = component->GetCurrentClip(); + return SHResourceManager::GetAssetID(clip).value_or(0); + }, + [component](AssetID const& id) + { + if (SHAssetManager::GetType(id) != AssetType::MESH) + { + SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!") + return; + } + component->SetClip(SHResourceManager::LoadOrGet(id)); + }, SHDragDrop::DRAG_RESOURCE); + } + else + { + DrawContextMenu(component); + } + ImGui::PopID(); + } + }