@@ -181,15 +181,26 @@ namespace EMStudio
|
||||
ResetEnvironment();
|
||||
}
|
||||
|
||||
AZ::Vector3 AnimViewportRenderer::GetCenter() const
|
||||
AZ::Vector3 AnimViewportRenderer::GetCharacterCenter() const
|
||||
{
|
||||
AZ::Vector3 result = AZ::Vector3::CreateZero();
|
||||
if (!m_actorEntities.empty())
|
||||
{
|
||||
// Find the actor instance and calculate the center from aabb.
|
||||
AZ::Vector3 actorCenter = AZ::Vector3::CreateZero();
|
||||
EMotionFX::Integration::ActorComponent* actorComponent =
|
||||
m_actorEntities[0]->FindComponent<EMotionFX::Integration::ActorComponent>();
|
||||
EMotionFX::ActorInstance* actorInstance = actorComponent->GetActorInstance();
|
||||
if (actorInstance)
|
||||
{
|
||||
actorCenter += actorInstance->GetAabb().GetCenter();
|
||||
}
|
||||
|
||||
// Just return the position of the first entity.
|
||||
AZ::Transform worldTransform;
|
||||
AZ::TransformBus::EventResult(worldTransform, m_actorEntities[0]->GetId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
result = worldTransform.GetTranslation();
|
||||
result += actorCenter;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace EMStudio
|
||||
void Reinit();
|
||||
|
||||
//! Return the center position of the existing objects.
|
||||
AZ::Vector3 GetCenter() const;
|
||||
AZ::Vector3 GetCharacterCenter() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -126,8 +126,7 @@ namespace EMStudio
|
||||
void AnimViewportWidget::SetCameraViewMode([[maybe_unused]]CameraViewMode mode)
|
||||
{
|
||||
// Set the camera view mode.
|
||||
AZ::Vector3 targetPosition = m_renderer->GetCenter();
|
||||
targetPosition.SetZ(targetPosition.GetY() + TargetCenterOffsetZ);
|
||||
const AZ::Vector3 targetPosition = m_renderer->GetCharacterCenter();
|
||||
AZ::Vector3 cameraPosition;
|
||||
switch (mode)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace EMStudio
|
||||
void SetCameraViewMode(CameraViewMode mode);
|
||||
|
||||
static constexpr float CameraDistance = 2.0f;
|
||||
static constexpr float TargetCenterOffsetZ = 1.0f;
|
||||
|
||||
AZStd::unique_ptr<AnimViewportRenderer> m_renderer;
|
||||
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_rotateCamera;
|
||||
|
||||
Reference in New Issue
Block a user