Add rendered model auto rotation

Toggle rotation from menu view
master
Jeremy Hu 2020-01-05 08:08:16 +09:30
parent 66ac0b3b7f
commit 846270fa80
5 changed files with 30 additions and 5 deletions

View File

@ -390,6 +390,10 @@ Tips:
<source>&amp;Help</source>
<translation>(&amp;H)</translation>
</message>
<message>
<source>Toggle Rotation</source>
<translation>/</translation>
</message>
</context>
<context>
<name>ExportPreviewWidget</name>
@ -736,10 +740,6 @@ Tips:
<source>Paste Color</source>
<translation></translation>
</message>
<message>
<source>Remeshed</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Poly</source>
<translation></translation>

View File

@ -727,6 +727,12 @@ DocumentWindow::DocumentWindow() :
});
m_viewMenu->addAction(m_toggleWireframeAction);
m_toggleRotationAction = new QAction(tr("Toggle Rotation"), this);
connect(m_toggleRotationAction, &QAction::triggered, [=]() {
m_modelRenderWidget->toggleRotation();
});
m_viewMenu->addAction(m_toggleRotationAction);
m_toggleUvCheckAction = new QAction(tr("Toggle UV Check"), this);
connect(m_toggleUvCheckAction, &QAction::triggered, [=]() {
m_modelRenderWidget->toggleUvCheck();

View File

@ -168,7 +168,7 @@ private:
QAction *m_resetModelWidgetPosAction;
QAction *m_toggleWireframeAction;
QAction *m_toggleUvCheckAction;
QAction *m_showMotionsListAction;
QAction *m_toggleRotationAction;
QMenu *m_windowMenu;
QAction *m_showPartsListAction;

View File

@ -211,6 +211,22 @@ void ModelWidget::toggleWireframe()
update();
}
void ModelWidget::toggleRotation()
{
if (nullptr != m_rotationTimer) {
delete m_rotationTimer;
m_rotationTimer = nullptr;
} else {
m_rotationTimer = new QTimer(this);
m_rotationTimer->setInterval(42);
m_rotationTimer->setSingleShot(false);
connect(m_rotationTimer, &QTimer::timeout, this, [&]() {
setYRotation(m_yRot - 8);
});
m_rotationTimer->start();
}
}
void ModelWidget::toggleUvCheck()
{
if (m_meshBinder.isCheckUvEnabled())

View File

@ -8,6 +8,7 @@
#include <QMutex>
#include <QRubberBand>
#include <QVector2D>
#include <QTimer>
#include "meshloader.h"
#include "modelshaderprogram.h"
#include "modelmeshbinder.h"
@ -36,6 +37,7 @@ public:
void updateMesh(MeshLoader *mesh);
void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions);
void toggleWireframe();
void toggleRotation();
void toggleUvCheck();
void enableMove(bool enabled);
void enableZoom(bool enabled);
@ -93,6 +95,7 @@ private:
QPoint m_moveStartPos;
QRect m_moveStartGeometry;
int m_modelInitialHeight = 0;
QTimer *m_rotationTimer = nullptr;
std::pair<QVector3D, QVector3D> screenPositionToMouseRay(const QPoint &screenPosition);
};