render an actor

Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
rhhong
2021-09-21 09:51:27 -07:00
parent d185338978
commit b7900bf646
4 changed files with 28 additions and 1 deletions
@@ -9,6 +9,8 @@
#include <AzFramework/Entity/GameEntityContextBus.h>
#include <AzFramework/Components/TransformComponent.h>
#include <Integration/Assets/ActorAsset.h>
#include <Integration/ActorComponentBus.h>
#include <Atom/RPI.Public/Scene.h>
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
@@ -145,6 +147,18 @@ namespace EMStudio
m_modelEntity->CreateComponent(azrtti_typeid<AzFramework::TransformComponent>());
m_modelEntity->Activate();
// Create an actor.
// TODO: Support multiple actors.
AzFramework::EntityContextRequestBus::EventResult(
m_actorEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "ViewportModel");
AZ_Assert(m_actorEntity != nullptr, "Failed to create model entity.");
static constexpr const char* const ActorComponentTypeId = "{BDC97E7F-A054-448B-A26F-EA2B5D78E377}";
m_actorEntity->CreateComponent(ActorComponentTypeId);
m_actorEntity->CreateComponent(AZ::Render::MaterialComponentTypeId);
m_actorEntity->CreateComponent(azrtti_typeid<AzFramework::TransformComponent>());
m_actorEntity->Activate();
// Create grid
AzFramework::EntityContextRequestBus::EventResult(
m_gridEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "ViewportGrid");
@@ -177,6 +191,7 @@ namespace EMStudio
DestoryEntity(m_postProcessEntity, entityContextId);
DestoryEntity(m_cameraEntity, entityContextId);
DestoryEntity(m_modelEntity, entityContextId);
DestoryEntity(m_actorEntity, entityContextId);
DestoryEntity(m_gridEntity, entityContextId);
m_entityContext->DestroyContext();
@@ -217,6 +232,13 @@ namespace EMStudio
AZ::Render::MeshComponentRequestBus::Event(
m_modelEntity->GetId(), &AZ::Render::MeshComponentRequestBus::Events::SetModelAsset, modelAsset);
// Reset the actor asset
AZ::TransformBus::Event(m_actorEntity->GetId(), &AZ::TransformBus::Events::SetLocalTM, modelTransform);
auto actorAsset = AZ::RPI::AssetUtils::GetAssetByProductPath<EMotionFX::Integration::ActorAsset>(
"objects/characters/jack/jack.actor", AZ::RPI::AssetUtils::TraceLevel::Assert);
EMotionFX::Integration::ActorComponentRequestBus::Event(
m_actorEntity->GetId(), &EMotionFX::Integration::ActorComponentRequestBus::Events::SetActorAsset, actorAsset);
Camera::Configuration cameraConfig;
Camera::CameraRequestBus::EventResult(
cameraConfig, m_cameraEntity->GetId(), &Camera::CameraRequestBus::Events::GetCameraConfiguration);
@@ -66,6 +66,7 @@ namespace EMStudio
AZ::Entity* m_cameraEntity = nullptr;
AZ::Component* m_cameraComponent = nullptr;
AZ::Entity* m_modelEntity = nullptr;
AZ::Entity* m_actorEntity = nullptr;
AZ::Data::AssetId m_modelAssetId;
AZ::Entity* m_gridEntity = nullptr;
@@ -16,7 +16,7 @@
#include <AzCore/RTTI/TypeInfo.h>
#include <AzFramework/Physics/AnimationConfiguration.h>
#include <AzFramework/Physics/Character.h>
#include <Integration/Assets/ActorAsset.h>
namespace EMotionFX
{
@@ -96,6 +96,10 @@ namespace EMotionFX
/// Returns skinning method used by the actor.
virtual SkinningMethod GetSkinningMethod() const = 0;
// Use this to alter the actor asset.
virtual void SetActorAsset(AZ::Data::Asset<EMotionFX::Integration::ActorAsset> actorAsset) = 0;
// virtual AZ::Data::Asset<const EMotionFX::Integration::ActorAsset> GetAsset() const = 0;
static const size_t s_invalidJointIndex = std::numeric_limits<size_t>::max();
};