diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp index 89050cc643..4db69cf8d9 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include #include @@ -145,6 +147,18 @@ namespace EMStudio m_modelEntity->CreateComponent(azrtti_typeid()); 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()); + 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( + "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); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h index 85538fd568..eb590f8d71 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h @@ -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; diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/Character2.layout b/Gems/EMotionFX/Assets/Editor/Layouts/Character2.layout new file mode 100644 index 0000000000..a97581727f Binary files /dev/null and b/Gems/EMotionFX/Assets/Editor/Layouts/Character2.layout differ diff --git a/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h b/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h index 6000873db1..325191af81 100644 --- a/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h +++ b/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h @@ -16,7 +16,7 @@ #include #include #include - +#include 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 actorAsset) = 0; + // virtual AZ::Data::Asset GetAsset() const = 0; + static const size_t s_invalidJointIndex = std::numeric_limits::max(); };