Updates to Goto Position to work with the new camera system (#1212)
* add support for 'GoTo Position' to work with the new camera enabled * small updates to move away from more legacy calls * minor formatting change * ensure values are converted from degrees to radians * revert change to use Enumerate viewport call * remove formatting changes from SandboxIntegration
This commit is contained in:
committed by
GitHub
parent
fedc85f51f
commit
1946561b8d
@@ -3702,8 +3702,8 @@ void CCryEditApp::OnViewCycle2dviewport()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnDisplayGotoPosition()
|
||||
{
|
||||
CGotoPositionDlg dlg;
|
||||
dlg.exec();
|
||||
GotoPositionDialog dialog;
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "GameEngine.h"
|
||||
#include "UndoConfigSpec.h"
|
||||
#include "ViewManager.h"
|
||||
#include "EditorViewportCamera.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
namespace
|
||||
@@ -241,26 +242,15 @@ namespace
|
||||
|
||||
void PySetCurrentViewPosition(float x, float y, float z)
|
||||
{
|
||||
AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface<AzToolsFramework::IEditorCameraController>::Get();
|
||||
AZ_Error("editor", editorCameraController, "IEditorCameraController is not registered.");
|
||||
if (editorCameraController)
|
||||
{
|
||||
editorCameraController->SetCurrentViewPosition(AZ::Vector3{ x, y, z });
|
||||
}
|
||||
SandboxEditor::SetDefaultViewportCameraPosition(AZ::Vector3(x, y, z));
|
||||
}
|
||||
|
||||
void PySetCurrentViewRotation(float x, float y, float z)
|
||||
void PySetCurrentViewRotation(float x, [[maybe_unused]] float y, float z)
|
||||
{
|
||||
AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface<AzToolsFramework::IEditorCameraController>::Get();
|
||||
AZ_Error("editor", editorCameraController, "IEditorCameraController is not registered.");
|
||||
if (editorCameraController)
|
||||
{
|
||||
editorCameraController->SetCurrentViewRotation(AZ::Vector3{ x, y, z });
|
||||
}
|
||||
SandboxEditor::SetDefaultViewportCameraRotation(AZ::DegToRad(x), AZ::DegToRad(z));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void PyStartProcessDetached(const char* process, const char* args)
|
||||
@@ -488,9 +478,9 @@ namespace AzToolsFramework
|
||||
|
||||
addLegacyGeneral(behaviorContext->Method("load_all_plugins", ::Command_LoadPlugins, nullptr, "Loads all available plugins."));
|
||||
addLegacyGeneral(behaviorContext->Method("get_current_view_position", PyGetCurrentViewPosition, nullptr, "Returns the position of the current view as a Vec3."));
|
||||
addLegacyGeneral(behaviorContext->Method("get_current_view_rotation", PyGetCurrentViewRotation, nullptr, "Returns the rotation of the current view as a Vec3 of Euler angles."));
|
||||
addLegacyGeneral(behaviorContext->Method("get_current_view_rotation", PyGetCurrentViewRotation, nullptr, "Returns the rotation of the current view as a Vec3 of Euler angles in degrees."));
|
||||
addLegacyGeneral(behaviorContext->Method("set_current_view_position", PySetCurrentViewPosition, nullptr, "Sets the position of the current view as given x, y, z coordinates."));
|
||||
addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles."));
|
||||
addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles in degrees."));
|
||||
|
||||
addLegacyGeneral(behaviorContext->Method("export_to_engine", CCryEditApp::Command_ExportToEngine, nullptr, "Exports the current level to the engine."));
|
||||
addLegacyGeneral(behaviorContext->Method("set_config_spec", PySetConfigSpec, nullptr, "Sets the system config spec and platform."));
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <EditorViewportCamera.h>
|
||||
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
|
||||
namespace SandboxEditor
|
||||
{
|
||||
void SetDefaultViewportCameraPosition(const AZ::Vector3& position)
|
||||
{
|
||||
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (auto viewportContext = viewportContextManager->GetDefaultViewportContext())
|
||||
{
|
||||
const auto& currentCameraTransform = viewportContext->GetCameraTransform();
|
||||
viewportContext->SetCameraTransform(
|
||||
AZ::Transform::CreateFromQuaternionAndTranslation(currentCameraTransform.GetRotation(), position));
|
||||
}
|
||||
}
|
||||
|
||||
void SetDefaultViewportCameraRotation(const float pitch, const float yaw)
|
||||
{
|
||||
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (auto viewportContext = viewportContextManager->GetDefaultViewportContext())
|
||||
{
|
||||
const auto rotation = AZ::Quaternion::CreateRotationZ(yaw) * AZ::Quaternion::CreateRotationX(pitch);
|
||||
const auto& currentCameraTransform = viewportContext->GetCameraTransform();
|
||||
viewportContext->SetCameraTransform(
|
||||
AZ::Transform::CreateFromQuaternionAndTranslation(rotation, currentCameraTransform.GetTranslation()));
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Transform GetDefaultViewportCameraTransform()
|
||||
{
|
||||
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (auto viewportContext = viewportContextManager->GetDefaultViewportContext())
|
||||
{
|
||||
return viewportContext->GetCameraTransform();
|
||||
}
|
||||
|
||||
AZ_WarningOnce("EditorViewport", false, "Default viewport camera not found");
|
||||
|
||||
return AZ::Transform::CreateIdentity();
|
||||
}
|
||||
} // namespace SandboxEditor
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SandboxAPI.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Transform;
|
||||
class Vector3;
|
||||
} // namespace AZ
|
||||
|
||||
namespace SandboxEditor
|
||||
{
|
||||
//! Set the default viewport camera translation/position.
|
||||
SANDBOX_API void SetDefaultViewportCameraPosition(const AZ::Vector3& position);
|
||||
|
||||
//! Set the default viewport camera orientation/rotation.
|
||||
//! @param pitch Amount of pitch in radians.
|
||||
//! @param yaw Amount of yaw in radians.
|
||||
SANDBOX_API void SetDefaultViewportCameraRotation(float pitch, float yaw);
|
||||
|
||||
//! Get the default viewport camera transform.
|
||||
SANDBOX_API AZ::Transform GetDefaultViewportCameraTransform();
|
||||
} // namespace SandboxEditor
|
||||
@@ -1265,7 +1265,7 @@ void EditorViewportWidget::SetViewportId(int id)
|
||||
AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult;
|
||||
AzFramework::RenderGeometry::IntersectorBus::EventResult(
|
||||
renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(),
|
||||
&AzFramework::RenderGeometry::IntersectorInterface::RayIntersect, ray);
|
||||
&AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, ray);
|
||||
|
||||
// attempt a ray intersection with any visible mesh and return the intersection position if successful
|
||||
if (renderGeometryIntersectionResult)
|
||||
|
||||
@@ -267,14 +267,12 @@ AZ_POP_DISABLE_WARNING
|
||||
m_levelExtension = EditorUtils::LevelFile::GetDefaultFileExtension();
|
||||
m_playerViewTM.SetIdentity();
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
AZ::Interface<IEditorCameraController>::Register(this);
|
||||
}
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4273, "-Wunknown-warning-option")
|
||||
CGameEngine::~CGameEngine()
|
||||
{
|
||||
AZ_POP_DISABLE_WARNING
|
||||
AZ::Interface<IEditorCameraController>::Unregister(this);
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
m_pISystem->GetIMovieSystem()->SetCallback(NULL);
|
||||
|
||||
@@ -349,38 +347,6 @@ static void CmdGotoEditor(IConsoleCmdArgs* pArgs)
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::SetCurrentViewPosition(const AZ::Vector3& position)
|
||||
{
|
||||
CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
if (pRenderViewport)
|
||||
{
|
||||
CUndo undo("Set Current View Position");
|
||||
if (CUndo::IsRecording())
|
||||
{
|
||||
CUndo::Record(new CUndoViewPosition());
|
||||
}
|
||||
Matrix34 tm = pRenderViewport->GetViewTM();
|
||||
tm.SetTranslation(Vec3(position.GetX(), position.GetY(), position.GetZ()));
|
||||
pRenderViewport->SetViewTM(tm);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::SetCurrentViewRotation(const AZ::Vector3& rotation)
|
||||
{
|
||||
CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
if (pRenderViewport)
|
||||
{
|
||||
CUndo undo("Set Current View Rotation");
|
||||
if (CUndo::IsRecording())
|
||||
{
|
||||
CUndo::Record(new CUndoViewRotation());
|
||||
}
|
||||
Matrix34 tm = pRenderViewport->GetViewTM();
|
||||
tm.SetRotationXYZ(Ang3(DEG2RAD(rotation.GetX()), DEG2RAD(rotation.GetY()), DEG2RAD(rotation.GetZ())), tm.GetTranslation());
|
||||
pRenderViewport->SetViewTM(tm);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
bool bPreviewMode,
|
||||
bool bTestMode,
|
||||
|
||||
@@ -32,24 +32,6 @@ struct IInitializeUIInfo;
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! Operates the Editor's camera
|
||||
class IEditorCameraController
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(IEditorCameraController, "{AEF60D3E-10A1-4161-9379-F68C69A5959C}");
|
||||
|
||||
IEditorCameraController() = default;
|
||||
IEditorCameraController(IEditorCameraController&&) = delete;
|
||||
IEditorCameraController& operator=(IEditorCameraController&&) = delete;
|
||||
virtual ~IEditorCameraController() = default;
|
||||
|
||||
virtual void SetCurrentViewPosition([[maybe_unused]] const AZ::Vector3& position) {}
|
||||
virtual void SetCurrentViewRotation([[maybe_unused]] const AZ::Vector3& rotation) {}
|
||||
};
|
||||
}
|
||||
|
||||
class ThreadedOnErrorHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -68,7 +50,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
//! This class serves as a high-level wrapper for CryEngine game.
|
||||
class SANDBOX_API CGameEngine
|
||||
: public IEditorNotifyListener
|
||||
, private AzToolsFramework::IEditorCameraController
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
public:
|
||||
@@ -153,11 +134,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
AZ_PUSH_DISABLE_WARNING(4273, "-Wunknown-warning-option")
|
||||
void SetCurrentViewPosition(const AZ::Vector3& position) override;
|
||||
void SetCurrentViewRotation(const AZ::Vector3& rotation) override;
|
||||
AZ_POP_DISABLE_OVERRIDE_WARNING
|
||||
|
||||
void SetGameMode(bool inGame);
|
||||
void SwitchToInGame();
|
||||
void SwitchToInEditor();
|
||||
|
||||
@@ -1,174 +1,122 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "GotoPositionDlg.h"
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "GotoPositionDlg.h"
|
||||
|
||||
// Editor
|
||||
#include "ViewManager.h"
|
||||
#include "EditorViewportCamera.h"
|
||||
#include "GameEngine.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <AzFramework/Viewport/CameraInput.h>
|
||||
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_GotoPositionDlg.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGotoPositionDlg dialog
|
||||
|
||||
|
||||
CGotoPositionDlg::CGotoPositionDlg(QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
, m_ui(new Ui::GotoPositionDlg)
|
||||
GotoPositionDialog::GotoPositionDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::GotoPositionDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setFixedSize(size());
|
||||
OnInitDialog();
|
||||
|
||||
auto doubleValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
|
||||
auto valueChanged = static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged);
|
||||
auto doubleValueChanged = static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
|
||||
|
||||
connect(m_ui->m_posEdit, &QLineEdit::editingFinished, this, &CGotoPositionDlg::OnChangeEdit);
|
||||
connect(m_ui->m_dymX, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymY, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymZ, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymAngleX, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymAngleY, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymAngleZ, doubleValueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymSegX, valueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymSegY, valueChanged, this, &CGotoPositionDlg::OnUpdateNumbers);
|
||||
connect(m_ui->m_posEdit, &QLineEdit::editingFinished, this, &GotoPositionDialog::OnChangeEdit);
|
||||
connect(m_ui->m_dymX, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymY, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymZ, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymAnglePitch, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers);
|
||||
connect(m_ui->m_dymAngleYaw, doubleValueChanged, this, &GotoPositionDialog::OnUpdateNumbers);
|
||||
}
|
||||
|
||||
CGotoPositionDlg::~CGotoPositionDlg()
|
||||
GotoPositionDialog::~GotoPositionDialog() = default;
|
||||
|
||||
void GotoPositionDialog::OnInitDialog()
|
||||
{
|
||||
}
|
||||
const auto cameraTransform = SandboxEditor::GetDefaultViewportCameraTransform();
|
||||
const auto cameraTranslation = cameraTransform.GetTranslation();
|
||||
const auto cameraRotation = AzFramework::EulerAngles(AZ::Matrix3x3::CreateFromQuaternion(cameraTransform.GetRotation()));
|
||||
const auto pitchDegrees = AZ::RadToDeg(cameraRotation.GetX());
|
||||
const auto yawDegrees = AZ::RadToDeg(cameraRotation.GetZ());
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGotoPositionDlg message handlers
|
||||
// position
|
||||
m_ui->m_dymX->setRange(-64000.0, 64000.0);
|
||||
m_ui->m_dymX->setValue(cameraTranslation.GetX());
|
||||
|
||||
m_ui->m_dymY->setRange(-64000.0, 64000.0);
|
||||
m_ui->m_dymY->setValue(cameraTranslation.GetY());
|
||||
|
||||
void CGotoPositionDlg::OnInitDialog()
|
||||
{
|
||||
Vec3 pos;
|
||||
Ang3 angle;
|
||||
m_ui->m_dymZ->setRange(-64000.0, 64000.0);
|
||||
m_ui->m_dymZ->setValue(cameraTranslation.GetZ());
|
||||
|
||||
CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
if (pRenderViewport)
|
||||
{
|
||||
Matrix34 tm = pRenderViewport->GetViewTM();
|
||||
pos = pRenderViewport->GetViewTM().GetTranslation();
|
||||
angle = RAD2DEG(Ang3::GetAnglesXYZ(tm));
|
||||
}
|
||||
// rotation
|
||||
m_ui->m_dymAnglePitch->setRange(-180.0, 180.0);
|
||||
m_ui->m_dymAnglePitch->setValue(pitchDegrees);
|
||||
|
||||
// CORDS --------------------------------------
|
||||
m_ui->m_dymX->setRange(-64000, 64000);
|
||||
m_ui->m_dymX->setValue(pos.x);
|
||||
m_ui->m_dymAngleYaw->setRange(-180.0, 180.0);
|
||||
m_ui->m_dymAngleYaw->setValue(yawDegrees);
|
||||
|
||||
m_ui->m_dymY->setRange(-64000, 64000);
|
||||
m_ui->m_dymY->setValue(pos.y);
|
||||
|
||||
m_ui->m_dymZ->setRange(-64000, 64000);
|
||||
m_ui->m_dymZ->setValue(pos.z);
|
||||
|
||||
// ANGLES -------------------------------------
|
||||
m_ui->m_dymAngleX->setRange(-180, 180);
|
||||
m_ui->m_dymAngleX->setValue(angle.x);
|
||||
|
||||
m_ui->m_dymAngleY->setRange(-180, 180);
|
||||
m_ui->m_dymAngleY->setValue(angle.y);
|
||||
|
||||
m_ui->m_dymAngleZ->setRange(-180, 180);
|
||||
m_ui->m_dymAngleZ->setValue(angle.z);
|
||||
|
||||
|
||||
m_ui->m_labelSeg->setVisible(false);
|
||||
m_ui->m_labelSegX->setVisible(false);
|
||||
m_ui->m_labelSegY->setVisible(false);
|
||||
m_ui->m_dymSegX->setVisible(false);
|
||||
m_ui->m_dymSegY->setVisible(false);
|
||||
|
||||
// Ensure the goto button is highlighted correctly.
|
||||
// ensure the goto button is highlighted correctly.
|
||||
m_ui->pushButton->setDefault(true);
|
||||
|
||||
OnUpdateNumbers();
|
||||
}
|
||||
|
||||
|
||||
void CGotoPositionDlg::OnChangeEdit()
|
||||
void GotoPositionDialog::OnChangeEdit()
|
||||
{
|
||||
const int lengthInSw = 8;
|
||||
const int strNum = 6;
|
||||
AZStd::vector<float> pos(strNum);
|
||||
const int argCount = 5;
|
||||
AZStd::vector<float> transform(argCount);
|
||||
|
||||
m_sPos = m_ui->m_posEdit->text();
|
||||
const QStringList parts = m_sPos.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts);
|
||||
for (int k = 0; k < strNum && k < parts.count(); ++k)
|
||||
m_transform = m_ui->m_posEdit->text();
|
||||
const QStringList parts = m_transform.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts);
|
||||
for (int i = 0; i < argCount && i < parts.count(); ++i)
|
||||
{
|
||||
pos[k] = parts[k].toDouble();
|
||||
transform[i] = parts[i].toDouble();
|
||||
}
|
||||
|
||||
m_ui->m_dymX->setValue(pos[0]);
|
||||
m_ui->m_dymY->setValue(pos[1]);
|
||||
m_ui->m_dymZ->setValue(pos[2]);
|
||||
m_ui->m_dymAngleX->setValue(pos[3]);
|
||||
m_ui->m_dymAngleY->setValue(pos[4]);
|
||||
m_ui->m_dymAngleZ->setValue(pos[5]);
|
||||
|
||||
if constexpr (strNum == lengthInSw)
|
||||
{
|
||||
if (parts.count() == lengthInSw)
|
||||
{
|
||||
m_ui->m_dymSegX->setValue(static_cast<int>(parts[6].toDouble()));
|
||||
m_ui->m_dymSegY->setValue(static_cast<int>(parts[7].toDouble()));
|
||||
}
|
||||
}
|
||||
m_ui->m_dymX->setValue(transform[0]);
|
||||
m_ui->m_dymY->setValue(transform[1]);
|
||||
m_ui->m_dymZ->setValue(transform[2]);
|
||||
m_ui->m_dymAnglePitch->setValue(transform[3]);
|
||||
m_ui->m_dymAngleYaw->setValue(transform[4]);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGotoPositionDlg::OnUpdateNumbers()
|
||||
void GotoPositionDialog::OnUpdateNumbers()
|
||||
{
|
||||
m_ui->m_posEdit->setText(QString::fromLatin1("%1, %2, %3, %4, %5, %6")
|
||||
.arg(m_ui->m_dymX->value(), 2, 'f', 2).arg(m_ui->m_dymY->value(), 2, 'f', 2).arg(m_ui->m_dymZ->value(), 2, 'f', 2)
|
||||
.arg(m_ui->m_dymAngleX->value(), 2, 'f', 2).arg(m_ui->m_dymAngleY->value(), 2, 'f', 2).arg(m_ui->m_dymAngleZ->value(), 2, 'f', 2));
|
||||
m_ui->m_posEdit->setText(QString::fromLatin1("%1, %2, %3, %4, %5")
|
||||
.arg(m_ui->m_dymX->value(), 2, 'f', 2)
|
||||
.arg(m_ui->m_dymY->value(), 2, 'f', 2)
|
||||
.arg(m_ui->m_dymZ->value(), 2, 'f', 2)
|
||||
.arg(m_ui->m_dymAnglePitch->value(), 2, 'f', 2)
|
||||
.arg(m_ui->m_dymAngleYaw->value(), 2, 'f', 2));
|
||||
}
|
||||
|
||||
|
||||
void CGotoPositionDlg::accept()
|
||||
void GotoPositionDialog::accept()
|
||||
{
|
||||
Vec3 vPos(m_ui->m_dymX->value(), m_ui->m_dymY->value(), m_ui->m_dymZ->value());
|
||||
|
||||
m_ui->m_dymX->setValue(vPos.x);
|
||||
m_ui->m_dymY->setValue(vPos.y);
|
||||
m_ui->m_dymZ->setValue(vPos.z);
|
||||
|
||||
AzToolsFramework::IEditorCameraController* editorCameraController = AZ::Interface<AzToolsFramework::IEditorCameraController>::Get();
|
||||
AZ_Error("editor", editorCameraController, "IEditorCameraCommands is not registered.");
|
||||
if (editorCameraController)
|
||||
{
|
||||
editorCameraController->SetCurrentViewPosition(AZ::Vector3{
|
||||
aznumeric_cast<float>(m_ui->m_dymX->value()),
|
||||
aznumeric_cast<float>(m_ui->m_dymY->value()),
|
||||
aznumeric_cast<float>(m_ui->m_dymZ->value())
|
||||
});
|
||||
editorCameraController->SetCurrentViewRotation(AZ::Vector3{
|
||||
aznumeric_cast<float>(m_ui->m_dymAngleX->value()),
|
||||
aznumeric_cast<float>(m_ui->m_dymAngleY->value()),
|
||||
aznumeric_cast<float>(m_ui->m_dymAngleZ->value())
|
||||
});
|
||||
}
|
||||
SandboxEditor::SetDefaultViewportCameraPosition(AZ::Vector3(
|
||||
aznumeric_cast<float>(m_ui->m_dymX->value()), aznumeric_cast<float>(m_ui->m_dymY->value()),
|
||||
aznumeric_cast<float>(m_ui->m_dymZ->value())));
|
||||
SandboxEditor::SetDefaultViewportCameraRotation(
|
||||
AZ::DegToRad(aznumeric_cast<float>(m_ui->m_dymAnglePitch->value())),
|
||||
AZ::DegToRad(aznumeric_cast<float>(m_ui->m_dymAngleYaw->value())));
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@@ -11,12 +11,7 @@
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H
|
||||
#define CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H
|
||||
|
||||
#pragma once
|
||||
// GotoPositionDlg.h : header file
|
||||
//
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
@@ -24,22 +19,19 @@
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class GotoPositionDlg;
|
||||
class GotoPositionDialog;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGotoPositionDlg dialog
|
||||
|
||||
class CGotoPositionDlg
|
||||
//! GotoPositionDialog for setting camera position and rotation.
|
||||
class GotoPositionDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
// Construction
|
||||
public:
|
||||
CGotoPositionDlg(QWidget* pParent = nullptr); // standard constructor
|
||||
~CGotoPositionDlg();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
explicit GotoPositionDialog(QWidget* parent = nullptr);
|
||||
~GotoPositionDialog();
|
||||
|
||||
protected:
|
||||
void OnInitDialog();
|
||||
void accept() override;
|
||||
@@ -47,12 +39,9 @@ protected:
|
||||
void OnUpdateNumbers();
|
||||
void OnChangeEdit();
|
||||
|
||||
|
||||
public:
|
||||
QString m_sPos;
|
||||
QString m_transform;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::GotoPositionDlg> m_ui;
|
||||
QScopedPointer<Ui::GotoPositionDialog> m_ui;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GOTOPOSITIONDLG_H
|
||||
|
||||
@@ -1,226 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GotoPositionDlg</class>
|
||||
<widget class="QDialog" name="GotoPositionDlg">
|
||||
<class>GotoPositionDialog</class>
|
||||
<widget class="QDialog" name="GotoPositionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>290</width>
|
||||
<height>180</height>
|
||||
<width>182</width>
|
||||
<height>174</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Go to Position</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="3" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Angles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymZ"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymX"/>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="7">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Enter position here:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Z:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Pitch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Yaw:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QDoubleSpinBox" name="m_dymAngleYaw"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymY"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="7">
|
||||
<widget class="QLineEdit" name="m_posEdit">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QDoubleSpinBox" name="m_dymAnglePitch"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0,0,1,0,0,1">
|
||||
<item row="5" column="6" colspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymZ"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymY"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_dymX"/>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QDoubleSpinBox" name="m_dymAngleY"/>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QDoubleSpinBox" name="m_dymAngleX"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Z:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="8">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Enter position here:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="8">
|
||||
<widget class="QLineEdit" name="m_posEdit">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="6">
|
||||
<widget class="QLabel" name="m_labelSegX">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QDoubleSpinBox" name="m_dymAngleZ"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="6">
|
||||
<widget class="QLabel" name="m_labelSegY">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Z:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Angles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6" colspan="2">
|
||||
<widget class="QLabel" name="m_labelSeg">
|
||||
<property name="text">
|
||||
<string>Segments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="7">
|
||||
<widget class="QSpinBox" name="m_dymSegX"/>
|
||||
</item>
|
||||
<item row="4" column="7">
|
||||
<widget class="QSpinBox" name="m_dymSegY"/>
|
||||
</item>
|
||||
</layout>
|
||||
<spacer name="horizontalSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Go To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Go To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_posEdit</tabstop>
|
||||
<tabstop>m_dymX</tabstop>
|
||||
<tabstop>m_dymY</tabstop>
|
||||
<tabstop>m_dymZ</tabstop>
|
||||
<tabstop>m_dymAngleX</tabstop>
|
||||
<tabstop>m_dymAngleY</tabstop>
|
||||
<tabstop>m_dymAngleZ</tabstop>
|
||||
<tabstop>m_dymSegX</tabstop>
|
||||
<tabstop>m_dymSegY</tabstop>
|
||||
<tabstop>m_dymAnglePitch</tabstop>
|
||||
<tabstop>m_dymAngleYaw</tabstop>
|
||||
<tabstop>pushButton_2</tabstop>
|
||||
<tabstop>pushButton</tabstop>
|
||||
</tabstops>
|
||||
@@ -229,7 +169,7 @@
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>GotoPositionDlg</receiver>
|
||||
<receiver>GotoPositionDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@@ -245,7 +185,7 @@
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>GotoPositionDlg</receiver>
|
||||
<receiver>GotoPositionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
||||
@@ -817,6 +817,8 @@ set(FILES
|
||||
EditorViewportWidget.h
|
||||
EditorViewportSettings.cpp
|
||||
EditorViewportSettings.h
|
||||
EditorViewportCamera.cpp
|
||||
EditorViewportCamera.h
|
||||
ViewportManipulatorController.cpp
|
||||
ViewportManipulatorController.h
|
||||
LegacyViewportCameraController.cpp
|
||||
|
||||
Reference in New Issue
Block a user