Add ability to load actor from the ui

Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
rhhong
2021-09-27 16:27:32 -07:00
parent c463721b52
commit 82bfbd5c98
7 changed files with 170 additions and 60 deletions
@@ -7,6 +7,11 @@
*/
#include <EMStudio/AtomRenderPlugin.h>
#include <EMStudio/AnimViewportRenderer.h>
#include <Integration/Components/ActorComponent.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
#include <EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
#include <QHBoxLayout>
namespace EMStudio
@@ -66,6 +71,11 @@ namespace EMStudio
return EMStudioPlugin::PLUGINTYPE_RENDERING;
}
void AtomRenderPlugin::ReinitRenderer()
{
m_animViewportWidget->GetAnimViewportRenderer()->Reinit();
}
bool AtomRenderPlugin::Init()
{
m_innerWidget = new QWidget();
@@ -75,9 +85,40 @@ namespace EMStudio
verticalLayout->setSizeConstraint(QLayout::SetNoConstraint);
verticalLayout->setSpacing(1);
verticalLayout->setMargin(0);
m_animViewportWidget = new AnimViewportWidget(m_innerWidget);
// Register command callbacks.
m_createActorInstanceCallback = new CreateActorInstanceCallback(false);
EMStudioManager::GetInstance()->GetCommandManager()->RegisterCommandCallback("CreateActorInstance", m_createActorInstanceCallback);
return true;
}
// Command callbacks
bool ReinitAtomRenderPlugin()
{
EMStudioPlugin* plugin = EMStudio::GetPluginManager()->FindActivePlugin(static_cast<uint32>(AtomRenderPlugin::CLASS_ID));
if (!plugin)
{
AZ_Error("AtomRenderPlugin", false, "Cannot execute command callback. Atom render plugin does not exist.");
return false;
}
AtomRenderPlugin* atomRenderPlugin = static_cast<AtomRenderPlugin*>(plugin);
atomRenderPlugin->ReinitRenderer();
return true;
}
bool AtomRenderPlugin::CreateActorInstanceCallback::Execute(
[[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine)
{
return ReinitAtomRenderPlugin();
}
bool AtomRenderPlugin::CreateActorInstanceCallback::Undo(
[[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine)
{
return ReinitAtomRenderPlugin();
}
}