From b7900bf646a9c74b1ce1382d4dd4db0beaf6b411 Mon Sep 17 00:00:00 2001 From: rhhong Date: Tue, 21 Sep 2021 09:51:27 -0700 Subject: [PATCH] render an actor Signed-off-by: rhhong --- .../Tools/EMStudio/AnimViewportRenderer.cpp | 22 ++++++++++++++++++ .../Tools/EMStudio/AnimViewportRenderer.h | 1 + .../Assets/Editor/Layouts/Character2.layout | Bin 0 -> 5388 bytes .../Include/Integration/ActorComponentBus.h | 6 ++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Gems/EMotionFX/Assets/Editor/Layouts/Character2.layout 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 0000000000000000000000000000000000000000..a97581727fce4261825b056591394bf56be2044d GIT binary patch literal 5388 zcmc&&U1%It6h7Ha(^?RV4cHgUDxxAp=HB@Sg`_HJOOh7bDuPhA$(k;jov_(dtkTd2 zt*w+65g`wvAc#VRs?p~@_$FdsguVz3DEOo(;!D=V@4GX1li8Y(hqQCToqOlbIp==o zyXV}Q>@%ZBMuuKEbnK{z^rBIQW+yA!t7u0nDdB#;N96Js7k^rs6T#5POIId;<2{A_ z;JY$MJu4j2kE>EYf6k}+S2Klc_pY3w{$Xp-)myz!v-usJ=YJTx`L{29^Cadf=hFVy zrTcz2INH5C>DTJp=bvSI*3GHydyM|&Z2s=uH>z#KVf~8SW1e4MSy-gM#iecL-rC!K z*R?Ot^7;Oo3yY7FEXWGPnfuzcM3aX1ZjssUY$_cgaN)bGa zB@?yEa5I^mo{{2sP}+|Jr9&^!j<3T4@?kV-PM@qCtu`lXtr;mQA3R5eq4Gm7@}(Fa zhFY!a_{phS11uEBgNu>~a6km1uY4&Y9}XtKByp$Vy$pisvwGj z0_tL@l}vSgJrwZ$pj51*F!J1ZK)G7SfrAf;0XGaB3`6olxn18;d+wt5-4{jr#xOA7 zUjJfXzf<{C+Pv#o!sTf>E;X5wL|RhEwShuv$*fG6yBYMaK%?@%e_9;TNO%|CO7Fwj z6*&DH;|ugIvVB>k+%{`%Yh!9JZ}H?2en7XOASF&i`cS>{gPA5WGo5M6cdOb2{4oBb z7?EQ#EC*yv0=$QOfMB1FB8+`e^bRRsN_&Ky4mP(EVNyzqxV*fIivSMh0C3qD03z@Z zi6<`Z1~BJhPGcN^BRxSu^};ttQQNGmOzP!?>NL>saL5bUpklg+ZRF7)%i(BMlL;hn^`BiU;d* z4F+#mYf#pA3e>%WcBHet$M>M|(!eykj}0@s|F9C6C=TVh%2NHpji`nUx%rvp$cHeu)bC%!qL1D$IHoP5Mg* z`!3OBXJd`_U<)_UWwM_7YE@|&?ivOsqe$qcPcrY #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(); };