Added inspector for animator component
This commit is contained in:
parent
3d73185926
commit
c0e8c032b9
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
#include "Tools/Logger/SHLogger.h"
|
#include "Tools/Logger/SHLogger.h"
|
||||||
#include "Tools/SHDebugDraw.h"
|
#include "Tools/SHDebugDraw.h"
|
||||||
|
#include "Resource/SHResourceManager.h"
|
||||||
|
|
||||||
using namespace SHADE;
|
using namespace SHADE;
|
||||||
|
|
||||||
|
@ -170,6 +171,10 @@ namespace Sandbox
|
||||||
|
|
||||||
// Link up SHDebugDraw
|
// Link up SHDebugDraw
|
||||||
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
|
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
|
||||||
|
|
||||||
|
auto clip = SHResourceManager::LoadOrGet<SHAnimationClip>(77816045);
|
||||||
|
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
|
||||||
|
int i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBApplication::Update(void)
|
void SBApplication::Update(void)
|
||||||
|
|
|
@ -93,6 +93,12 @@ namespace SHADE
|
||||||
/// <returns>Reference to a vector of the bone matrices.</returns>
|
/// <returns>Reference to a vector of the bone matrices.</returns>
|
||||||
const std::vector<SHMatrix>& GetBoneMatrices() const noexcept { return boneMatrices; }
|
const std::vector<SHMatrix>& GetBoneMatrices() const noexcept { return boneMatrices; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Retrieve the currently set model rig.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Handle to the currently set rig.</returns>
|
||||||
|
Handle<SHRig> GetRig() const noexcept { return rig; }
|
||||||
|
/// <summary>
|
||||||
|
/// <summary>
|
||||||
/// Retrieve the currently set animation clip.
|
/// Retrieve the currently set animation clip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Handle to the currently set animation clip.</returns>
|
/// <returns>Handle to the currently set animation clip.</returns>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "Serialization/SHSerializationHelper.hpp"
|
#include "Serialization/SHSerializationHelper.hpp"
|
||||||
#include "Tools/Utilities/SHClipboardUtilities.h"
|
#include "Tools/Utilities/SHClipboardUtilities.h"
|
||||||
#include "SHInspectorCommands.h"
|
#include "SHInspectorCommands.h"
|
||||||
|
#include "Animation/SHAnimatorComponent.h"
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -574,4 +575,60 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
static void DrawComponent(SHAnimatorComponent* component)
|
||||||
|
{
|
||||||
|
if (!component)
|
||||||
|
return;
|
||||||
|
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHAnimatorComponent>());
|
||||||
|
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<SHRig> const& rig = component->GetRig();
|
||||||
|
const auto RIG_NAME = rig ? SHResourceManager::GetAssetName<SHRig>(rig).value_or("") : "";
|
||||||
|
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Rig", RIG_NAME, [component]()
|
||||||
|
{
|
||||||
|
Handle<SHRig> const& rig = component->GetRig();
|
||||||
|
return SHResourceManager::GetAssetID<SHRig>(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<SHRig>(id));
|
||||||
|
SHResourceManager::FinaliseChanges();
|
||||||
|
}, SHDragDrop::DRAG_RESOURCE);
|
||||||
|
|
||||||
|
Handle<SHAnimationClip> const& clip = component->GetCurrentClip();
|
||||||
|
const auto CLIP_NAME = rig ? SHResourceManager::GetAssetName<SHAnimationClip>(clip).value_or("") : "";
|
||||||
|
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Material", CLIP_NAME,
|
||||||
|
[component]()
|
||||||
|
{
|
||||||
|
Handle<SHAnimationClip> const& clip = component->GetCurrentClip();
|
||||||
|
return SHResourceManager::GetAssetID<SHAnimationClip>(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<SHAnimationClip>(id));
|
||||||
|
}, SHDragDrop::DRAG_RESOURCE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawContextMenu(component);
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue