2015-07-26 21:39:49 +00:00
|
|
|
#include "CWorldEditor.h"
|
|
|
|
#include "ui_CWorldEditor.h"
|
2015-09-01 17:05:48 +00:00
|
|
|
#include "CBasicViewport.h"
|
2015-07-26 21:39:49 +00:00
|
|
|
#include <gtc/matrix_transform.hpp>
|
|
|
|
#include <Core/CDrawUtil.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <QOpenGLContext>
|
|
|
|
#include <QFontMetrics>
|
2015-08-20 01:01:58 +00:00
|
|
|
#include <QComboBox>
|
2015-07-26 21:39:49 +00:00
|
|
|
#include <Core/Log.h>
|
2015-07-29 13:51:59 +00:00
|
|
|
#include "WDraggableSpinBox.h"
|
2015-08-25 01:17:15 +00:00
|
|
|
#include "WVectorEditor.h"
|
2015-09-01 17:05:48 +00:00
|
|
|
#include "undo/UndoCommands.h"
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
#include "WorldEditor/CLayerEditor.h"
|
|
|
|
#include "WorldEditor/WModifyTab.h"
|
|
|
|
#include "WorldEditor/WInstancesTab.h"
|
|
|
|
|
|
|
|
CWorldEditor::CWorldEditor(QWidget *parent) :
|
2015-09-01 17:05:48 +00:00
|
|
|
INodeEditor(parent),
|
2015-07-26 21:39:49 +00:00
|
|
|
ui(new Ui::CWorldEditor)
|
|
|
|
{
|
|
|
|
Log::Write("Creating World Editor");
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
mpArea = nullptr;
|
|
|
|
mpWorld = nullptr;
|
2015-08-20 01:01:58 +00:00
|
|
|
mGizmoHovering = false;
|
|
|
|
mGizmoTransforming = false;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
// Start refresh timer
|
|
|
|
connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(RefreshViewport()));
|
|
|
|
mRefreshTimer.start(0);
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Create blank title bar with some space to allow for dragging the dock
|
|
|
|
QWidget *pOldTitleBar = ui->MainDock->titleBarWidget();
|
|
|
|
|
|
|
|
QWidget *pNewTitleBar = new QWidget(ui->MainDock);
|
|
|
|
QVBoxLayout *pTitleLayout = new QVBoxLayout(pNewTitleBar);
|
|
|
|
pTitleLayout->setSpacing(10);
|
|
|
|
pNewTitleBar->setLayout(pTitleLayout);
|
|
|
|
ui->MainDock->setTitleBarWidget(pNewTitleBar);
|
|
|
|
|
|
|
|
delete pOldTitleBar;
|
|
|
|
|
2015-07-29 13:51:59 +00:00
|
|
|
// Initialize UI stuff
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->SetScene(this, &mScene);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ModifyTabContents->SetEditor(this);
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->InstancesTabContents->SetEditor(this, &mScene);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->MainDock->installEventFilter(this);
|
2015-08-25 01:17:15 +00:00
|
|
|
ui->TransformSpinBox->SetOrientation(Qt::Horizontal);
|
|
|
|
ui->TransformSpinBox->layout()->setContentsMargins(0,0,0,0);
|
2015-07-29 13:51:59 +00:00
|
|
|
ui->CamSpeedSpinBox->SetDefaultValue(1.0);
|
2015-08-20 01:01:58 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
mpTransformCombo->setMinimumWidth(75);
|
|
|
|
ui->MainToolBar->addActions(mGizmoActions);
|
|
|
|
ui->MainToolBar->addWidget(mpTransformCombo);
|
|
|
|
ui->menuEdit->addActions(mUndoActions);
|
2015-08-20 01:01:58 +00:00
|
|
|
|
2015-08-16 04:29:37 +00:00
|
|
|
// Initialize offscreen actions
|
|
|
|
addAction(ui->ActionIncrementGizmo);
|
|
|
|
addAction(ui->ActionDecrementGizmo);
|
|
|
|
|
2015-07-29 13:51:59 +00:00
|
|
|
// Connect signals and slots
|
2015-09-01 17:05:48 +00:00
|
|
|
connect(ui->MainViewport, SIGNAL(GizmoMoved()), this, SLOT(OnGizmoMoved()));
|
2015-08-25 01:17:15 +00:00
|
|
|
connect(ui->TransformSpinBox, SIGNAL(ValueChanged(CVector3f)), this, SLOT(OnTransformSpinBoxModified(CVector3f)));
|
2015-09-01 17:05:48 +00:00
|
|
|
connect(ui->TransformSpinBox, SIGNAL(EditingDone(CVector3f)), this, SLOT(OnTransformSpinBoxEdited(CVector3f)));
|
2015-07-29 13:51:59 +00:00
|
|
|
connect(ui->CamSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnCameraSpeedChange(double)));
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CWorldEditor::~CWorldEditor()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CWorldEditor::eventFilter(QObject *pObj, QEvent *pEvent)
|
|
|
|
{
|
|
|
|
if (pObj == ui->MainDock)
|
|
|
|
{
|
|
|
|
if (pEvent->type() == QEvent::Resize)
|
|
|
|
{
|
|
|
|
UpdateSelectionUI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->ResetHover();
|
2015-07-26 21:39:49 +00:00
|
|
|
ClearSelection();
|
|
|
|
ui->ModifyTabContents->ClearUI();
|
|
|
|
ui->ModifyTabContents->ClearCachedEditors();
|
|
|
|
ui->InstancesTabContents->SetMaster(nullptr);
|
|
|
|
ui->InstancesTabContents->SetArea(pArea);
|
|
|
|
|
|
|
|
// Clear old area - hack until better world/area loader is implemented
|
|
|
|
if ((mpArea) && (pArea != mpArea))
|
|
|
|
mpArea->ClearScriptLayers();
|
|
|
|
|
|
|
|
// Load new area
|
|
|
|
mpArea = pArea;
|
|
|
|
mpWorld = pWorld;
|
|
|
|
mAreaToken = CToken(pArea);
|
|
|
|
mWorldToken = CToken(pWorld);
|
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
mScene.SetActiveWorld(pWorld);
|
|
|
|
mScene.SetActiveArea(pArea);
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Snap camera to location of area
|
|
|
|
CTransform4f AreaTransform = pArea->GetTransform();
|
|
|
|
CVector3f AreaPosition(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
|
|
|
|
ui->MainViewport->Camera().Snap(AreaPosition);
|
|
|
|
|
2015-07-28 16:22:08 +00:00
|
|
|
// Default bloom to Fake Bloom for Metroid Prime 3; disable for other games
|
2015-07-26 21:39:49 +00:00
|
|
|
if (mpWorld->Version() == eCorruption)
|
|
|
|
{
|
|
|
|
ui->menuBloom->setEnabled(true);
|
2015-07-28 16:22:08 +00:00
|
|
|
on_ActionFakeBloom_triggered();
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->menuBloom->setEnabled(false);
|
|
|
|
on_ActionNoBloom_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up sidebar tabs
|
|
|
|
CMasterTemplate *pMaster = CMasterTemplate::GetMasterForGame(mpWorld->Version());
|
|
|
|
ui->InstancesTabContents->SetMaster(pMaster);
|
|
|
|
}
|
|
|
|
|
|
|
|
CGameArea* CWorldEditor::ActiveArea()
|
|
|
|
{
|
|
|
|
return mpArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ************ SLOTS ************
|
|
|
|
void CWorldEditor::UpdateCursor()
|
|
|
|
{
|
|
|
|
if (ui->MainViewport->IsCursorVisible())
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
|
|
|
|
|
|
|
if (ui->MainViewport->IsHoveringGizmo())
|
2015-08-17 18:10:42 +00:00
|
|
|
ui->MainViewport->SetCursorState(Qt::SizeAllCursor);
|
2015-09-01 17:05:48 +00:00
|
|
|
else if ((pHoverNode) && (pHoverNode->NodeType() != eStaticNode))
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->MainViewport->SetCursorState(Qt::PointingHandCursor);
|
|
|
|
else
|
|
|
|
ui->MainViewport->SetCursorState(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::UpdateStatusBar()
|
|
|
|
{
|
|
|
|
// Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
|
|
|
|
QString StatusText = "";
|
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
if (!mGizmoHovering)
|
2015-07-26 21:39:49 +00:00
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
if (ui->MainViewport->underMouse())
|
|
|
|
{
|
|
|
|
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
|
|
|
|
|
|
|
if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
|
|
|
|
StatusText = QString::fromStdString(pHoverNode->Name());
|
|
|
|
}
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->statusbar->currentMessage() != StatusText)
|
|
|
|
ui->statusbar->showMessage(StatusText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::UpdateSelectionUI()
|
|
|
|
{
|
|
|
|
// Update sidebar
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->ModifyTabContents->GenerateUI(mSelection);
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Update selection info text
|
|
|
|
QString SelectionText;
|
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
if (mSelection.size() == 1)
|
|
|
|
SelectionText = QString::fromStdString(mSelection.front()->Name());
|
|
|
|
else if (mSelection.size() > 1)
|
|
|
|
SelectionText = QString("%1 objects selected").arg(mSelection.size());
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
QFontMetrics Metrics(ui->SelectionInfoLabel->font());
|
|
|
|
SelectionText = Metrics.elidedText(SelectionText, Qt::ElideRight, ui->SelectionInfoFrame->width() - 10);
|
|
|
|
ui->SelectionInfoLabel->setText(SelectionText);
|
2015-07-29 13:51:59 +00:00
|
|
|
|
2015-08-24 01:02:14 +00:00
|
|
|
// Update gizmo stuff
|
|
|
|
UpdateGizmoUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::UpdateGizmoUI()
|
|
|
|
{
|
|
|
|
// Update transform XYZ spin boxes
|
2015-08-25 01:17:15 +00:00
|
|
|
if (!ui->TransformSpinBox->IsBeingDragged())
|
2015-08-24 01:02:14 +00:00
|
|
|
{
|
2015-08-25 01:17:15 +00:00
|
|
|
CVector3f spinBoxValue = CVector3f::skZero;
|
|
|
|
|
|
|
|
// If the gizmo is transforming, use the total transform amount
|
|
|
|
// Otherwise, use the first selected node transform, or 0 if no selection
|
|
|
|
if (mShowGizmo)
|
2015-08-24 01:02:14 +00:00
|
|
|
{
|
2015-08-25 01:17:15 +00:00
|
|
|
switch (mGizmo.Mode())
|
|
|
|
{
|
|
|
|
case CGizmo::eTranslate:
|
|
|
|
if (mGizmoTransforming && mGizmo.HasTransformed())
|
|
|
|
spinBoxValue = mGizmo.TotalTranslation();
|
2015-09-01 17:05:48 +00:00
|
|
|
else if (!mSelection.empty())
|
|
|
|
spinBoxValue = mSelection.front()->AbsolutePosition();
|
2015-08-25 01:17:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CGizmo::eRotate:
|
|
|
|
if (mGizmoTransforming && mGizmo.HasTransformed())
|
|
|
|
spinBoxValue = mGizmo.TotalRotation();
|
2015-09-01 17:05:48 +00:00
|
|
|
else if (!mSelection.empty())
|
|
|
|
spinBoxValue = mSelection.front()->AbsoluteRotation().ToEuler();
|
2015-08-25 01:17:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CGizmo::eScale:
|
|
|
|
if (mGizmoTransforming && mGizmo.HasTransformed())
|
|
|
|
spinBoxValue = mGizmo.TotalScale();
|
2015-09-01 17:05:48 +00:00
|
|
|
else if (!mSelection.empty())
|
|
|
|
spinBoxValue = mSelection.front()->AbsoluteScale();
|
2015-08-25 01:17:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-08-24 01:02:14 +00:00
|
|
|
}
|
2015-09-01 17:05:48 +00:00
|
|
|
else if (!mSelection.empty()) spinBoxValue = mSelection.front()->AbsolutePosition();
|
2015-08-24 01:02:14 +00:00
|
|
|
|
2015-08-25 01:17:15 +00:00
|
|
|
ui->TransformSpinBox->blockSignals(true);
|
|
|
|
ui->TransformSpinBox->SetValue(spinBoxValue);
|
|
|
|
ui->TransformSpinBox->blockSignals(false);
|
|
|
|
}
|
2015-08-16 04:29:37 +00:00
|
|
|
|
|
|
|
// Update gizmo
|
2015-08-20 01:01:58 +00:00
|
|
|
if (!mGizmoTransforming)
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
// Set gizmo transform
|
|
|
|
if (!mSelection.empty())
|
|
|
|
{
|
|
|
|
mGizmo.SetPosition(mSelection.front()->AbsolutePosition());
|
|
|
|
mGizmo.SetLocalRotation(mSelection.front()->AbsoluteRotation());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-20 01:01:58 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
void CWorldEditor::GizmoModeChanged(CGizmo::EGizmoMode mode)
|
|
|
|
{
|
|
|
|
ui->TransformSpinBox->SetSingleStep( (mode == CGizmo::eRotate ? 1.0 : 0.1) );
|
|
|
|
ui->TransformSpinBox->SetDefaultValue( (mode == CGizmo::eScale ? 1.0 : 0.0) );
|
|
|
|
}
|
2015-08-28 22:57:24 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
// ************ ACTIONS ************
|
|
|
|
void CWorldEditor::RefreshViewport()
|
|
|
|
{
|
|
|
|
if (!mGizmo.IsTransforming())
|
|
|
|
mGizmo.ResetSelectedAxes();
|
2015-08-28 22:57:24 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
// Process input + update UI
|
|
|
|
ui->MainViewport->ProcessInput();
|
|
|
|
UpdateCursor();
|
|
|
|
UpdateStatusBar();
|
|
|
|
UpdateGizmoUI();
|
2015-08-24 01:02:14 +00:00
|
|
|
|
2015-09-01 17:05:48 +00:00
|
|
|
// Render
|
|
|
|
ui->MainViewport->Render();
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 13:51:59 +00:00
|
|
|
void CWorldEditor::OnCameraSpeedChange(double speed)
|
|
|
|
{
|
|
|
|
static const double skDefaultSpeed = 1.0;
|
|
|
|
ui->MainViewport->Camera().SetMoveSpeed(skDefaultSpeed * speed);
|
|
|
|
|
|
|
|
ui->CamSpeedSpinBox->blockSignals(true);
|
|
|
|
ui->CamSpeedSpinBox->setValue(speed);
|
|
|
|
ui->CamSpeedSpinBox->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
2015-08-25 01:17:15 +00:00
|
|
|
void CWorldEditor::OnTransformSpinBoxModified(CVector3f value)
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
if (mSelection.empty()) return;
|
|
|
|
|
2015-08-25 01:17:15 +00:00
|
|
|
switch (mGizmo.Mode())
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
case CGizmo::eTranslate:
|
|
|
|
{
|
|
|
|
CVector3f delta = value - mSelection.front()->AbsolutePosition();
|
|
|
|
mUndoStack.push(new CTranslateNodeCommand(this, mSelection, delta, mTranslateSpace));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CGizmo::eRotate:
|
|
|
|
{
|
|
|
|
CQuaternion delta = CQuaternion::FromEuler(value) * mSelection.front()->AbsoluteRotation().Inverse();
|
|
|
|
mUndoStack.push(new CRotateNodeCommand(this, mSelection, CVector3f::skZero, delta, mRotateSpace));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CGizmo::eScale:
|
|
|
|
{
|
|
|
|
CVector3f delta = value / mSelection.front()->AbsoluteScale();
|
|
|
|
mUndoStack.push(new CScaleNodeCommand(this, mSelection, CVector3f::skZero, delta));
|
|
|
|
break;
|
|
|
|
}
|
2015-08-25 01:17:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RecalculateSelectionBounds();
|
|
|
|
UpdateGizmoUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::OnTransformSpinBoxEdited(CVector3f)
|
|
|
|
{
|
2015-09-01 23:21:10 +00:00
|
|
|
// bit of a hack - the vector editor emits a second "editing done" signal when it loses focus
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->TransformSpinBox->blockSignals(true);
|
2015-09-01 23:21:10 +00:00
|
|
|
ui->MainViewport->setFocus();
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->TransformSpinBox->blockSignals(false);
|
|
|
|
if (mSelection.empty()) return;
|
|
|
|
|
|
|
|
if (mGizmo.Mode() == CGizmo::eTranslate) mUndoStack.push(CTranslateNodeCommand::End());
|
|
|
|
else if (mGizmo.Mode() == CGizmo::eRotate) mUndoStack.push(CRotateNodeCommand::End());
|
|
|
|
else if (mGizmo.Mode() == CGizmo::eScale) mUndoStack.push(CScaleNodeCommand::End());
|
|
|
|
|
2015-08-25 01:17:15 +00:00
|
|
|
UpdateGizmoUI();
|
|
|
|
}
|
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
// These functions are from "Go to slot" in the designer
|
|
|
|
void CWorldEditor::on_ActionDrawWorld_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
mScene.SetWorld(ui->ActionDrawWorld->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDrawCollision_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
mScene.SetCollision(ui->ActionDrawCollision->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDrawObjects_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
mScene.SetObjects(ui->ActionDrawObjects->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDrawLights_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
mScene.SetLights(ui->ActionDrawLights->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDrawSky_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->SetSkyEnabled(ui->ActionDrawSky->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionNoLighting_triggered()
|
|
|
|
{
|
|
|
|
CGraphics::sLightMode = CGraphics::NoLighting;
|
|
|
|
ui->ActionNoLighting->setChecked(true);
|
|
|
|
ui->ActionBasicLighting->setChecked(false);
|
|
|
|
ui->ActionWorldLighting->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionBasicLighting_triggered()
|
|
|
|
{
|
|
|
|
CGraphics::sLightMode = CGraphics::BasicLighting;
|
|
|
|
ui->ActionNoLighting->setChecked(false);
|
|
|
|
ui->ActionBasicLighting->setChecked(true);
|
|
|
|
ui->ActionWorldLighting->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionWorldLighting_triggered()
|
|
|
|
{
|
|
|
|
CGraphics::sLightMode = CGraphics::WorldLighting;
|
|
|
|
ui->ActionNoLighting->setChecked(false);
|
|
|
|
ui->ActionBasicLighting->setChecked(false);
|
|
|
|
ui->ActionWorldLighting->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionNoBloom_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->SetBloom(CRenderer::eNoBloom);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionNoBloom->setChecked(true);
|
|
|
|
ui->ActionBloomMaps->setChecked(false);
|
2015-07-28 16:22:08 +00:00
|
|
|
ui->ActionFakeBloom->setChecked(false);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionBloom->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionBloomMaps_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->SetBloom(CRenderer::eBloomMaps);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionNoBloom->setChecked(false);
|
|
|
|
ui->ActionBloomMaps->setChecked(true);
|
2015-07-28 16:22:08 +00:00
|
|
|
ui->ActionFakeBloom->setChecked(false);
|
|
|
|
ui->ActionBloom->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionFakeBloom_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->SetBloom(CRenderer::eFakeBloom);
|
2015-07-28 16:22:08 +00:00
|
|
|
ui->ActionNoBloom->setChecked(false);
|
|
|
|
ui->ActionBloomMaps->setChecked(false);
|
|
|
|
ui->ActionFakeBloom->setChecked(true);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionBloom->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionBloom_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->SetBloom(CRenderer::eBloom);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionNoBloom->setChecked(false);
|
|
|
|
ui->ActionBloomMaps->setChecked(false);
|
2015-07-28 16:22:08 +00:00
|
|
|
ui->ActionFakeBloom->setChecked(false);
|
2015-07-26 21:39:49 +00:00
|
|
|
ui->ActionBloom->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionZoomOnSelection_triggered()
|
|
|
|
{
|
|
|
|
static const float skDistScale = 2.5f;
|
|
|
|
static const float skAreaDistScale = 0.8f;
|
|
|
|
|
|
|
|
CCamera& Camera = ui->MainViewport->Camera();
|
2015-09-01 17:05:48 +00:00
|
|
|
CVector3f CamDir = Camera.Direction();
|
2015-07-26 21:39:49 +00:00
|
|
|
CVector3f NewPos;
|
|
|
|
|
|
|
|
// Zoom on selection
|
2015-09-01 17:05:48 +00:00
|
|
|
if (mSelection.size() != 0)
|
2015-07-26 21:39:49 +00:00
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
CVector3f Min = mSelectionBounds.Min();
|
|
|
|
CVector3f Max = mSelectionBounds.Max();
|
2015-07-26 21:39:49 +00:00
|
|
|
float Dist = ((Max.x - Min.x) + (Max.y - Min.y) + (Max.z - Min.z)) / 3.f;
|
2015-09-01 17:05:48 +00:00
|
|
|
NewPos = mSelectionBounds.Center() + (CamDir * -(Dist * skDistScale));
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Zoom on area
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CAABox AreaBox = mpArea->AABox();
|
|
|
|
CVector3f Min = AreaBox.Min();
|
|
|
|
CVector3f Max = AreaBox.Max();
|
|
|
|
float Dist = ((Max.x - Min.x) + (Max.y - Min.y) + (Max.z - Min.z)) / 3.f;
|
|
|
|
NewPos = AreaBox.Center() + (CamDir * -(Dist * skAreaDistScale));
|
|
|
|
}
|
|
|
|
|
|
|
|
Camera.SetPosition(NewPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDisableBackfaceCull_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->ToggleBackfaceCull(!ui->ActionDisableBackfaceCull->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDisableAlpha_triggered()
|
|
|
|
{
|
2015-09-01 17:05:48 +00:00
|
|
|
ui->MainViewport->Renderer()->ToggleAlphaDisabled(ui->ActionDisableAlpha->isChecked());
|
2015-07-26 21:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionEditLayers_triggered()
|
|
|
|
{
|
|
|
|
// Launch layer editor
|
|
|
|
CLayerEditor Editor(this);
|
|
|
|
Editor.SetArea(mpArea);
|
|
|
|
Editor.exec();
|
|
|
|
}
|
2015-08-16 04:29:37 +00:00
|
|
|
|
|
|
|
void CWorldEditor::on_ActionIncrementGizmo_triggered()
|
|
|
|
{
|
|
|
|
mGizmo.IncrementSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWorldEditor::on_ActionDecrementGizmo_triggered()
|
|
|
|
{
|
|
|
|
mGizmo.DecrementSize();
|
|
|
|
}
|