Add check UV
parent
a6b9ac7bf1
commit
13db7ee97b
|
@ -366,6 +366,10 @@ Tips:
|
|||
<source>Paint brush</source>
|
||||
<translation>画刷</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle UV Check</source>
|
||||
<translation>切换UV检查</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ExportPreviewWidget</name>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<file>resources/hexagon.png</file>
|
||||
<file>resources/heptagon.png</file>
|
||||
<file>resources/userdefined.png</file>
|
||||
<file>resources/checkuv.png</file>
|
||||
<file>shaders/default.vert</file>
|
||||
<file>shaders/default.frag</file>
|
||||
<file>shaders/default.core.vert</file>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
|
@ -652,6 +652,12 @@ DocumentWindow::DocumentWindow() :
|
|||
});
|
||||
m_viewMenu->addAction(m_toggleWireframeAction);
|
||||
|
||||
m_toggleUvCheckAction = new QAction(tr("Toggle UV Check"), this);
|
||||
connect(m_toggleUvCheckAction, &QAction::triggered, [=]() {
|
||||
m_modelRenderWidget->toggleUvCheck();
|
||||
});
|
||||
m_viewMenu->addAction(m_toggleUvCheckAction);
|
||||
|
||||
connect(m_viewMenu, &QMenu::aboutToShow, [=]() {
|
||||
m_resetModelWidgetPosAction->setEnabled(!isModelSitInVisibleArea(m_modelRenderWidget));
|
||||
});
|
||||
|
|
|
@ -154,6 +154,7 @@ private:
|
|||
QMenu *m_viewMenu;
|
||||
QAction *m_resetModelWidgetPosAction;
|
||||
QAction *m_toggleWireframeAction;
|
||||
QAction *m_toggleUvCheckAction;
|
||||
QAction *m_showMotionsListAction;
|
||||
|
||||
QMenu *m_windowMenu;
|
||||
|
|
|
@ -32,6 +32,19 @@ void ModelMeshBinder::updateMesh(MeshLoader *mesh)
|
|||
}
|
||||
}
|
||||
|
||||
void ModelMeshBinder::reloadMesh()
|
||||
{
|
||||
MeshLoader *mesh = nullptr;
|
||||
{
|
||||
QMutexLocker lock(&m_newMeshMutex);
|
||||
if (nullptr == m_mesh)
|
||||
return;
|
||||
mesh = new MeshLoader(*m_mesh);
|
||||
}
|
||||
if (nullptr != mesh)
|
||||
updateMesh(mesh);
|
||||
}
|
||||
|
||||
void ModelMeshBinder::initialize()
|
||||
{
|
||||
m_vaoTriangle.create();
|
||||
|
@ -63,8 +76,16 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
|||
m_hasTexture = nullptr != m_mesh->textureImage();
|
||||
delete m_texture;
|
||||
m_texture = nullptr;
|
||||
if (m_hasTexture)
|
||||
m_texture = new QOpenGLTexture(*m_mesh->textureImage());
|
||||
if (m_hasTexture) {
|
||||
if (m_checkUvEnabled) {
|
||||
static QImage *s_checkUv = nullptr;
|
||||
if (nullptr == s_checkUv)
|
||||
s_checkUv = new QImage(":/resources/checkuv.png");
|
||||
m_texture = new QOpenGLTexture(*s_checkUv);
|
||||
} else {
|
||||
m_texture = new QOpenGLTexture(*m_mesh->textureImage());
|
||||
}
|
||||
}
|
||||
|
||||
m_hasNormalMap = nullptr != m_mesh->normalMapImage();
|
||||
delete m_normalMap;
|
||||
|
@ -253,3 +274,18 @@ bool ModelMeshBinder::isWireframesVisible()
|
|||
{
|
||||
return m_showWireframes;
|
||||
}
|
||||
|
||||
void ModelMeshBinder::enableCheckUv()
|
||||
{
|
||||
m_checkUvEnabled = true;
|
||||
}
|
||||
|
||||
void ModelMeshBinder::disableCheckUv()
|
||||
{
|
||||
m_checkUvEnabled = false;
|
||||
}
|
||||
|
||||
bool ModelMeshBinder::isCheckUvEnabled()
|
||||
{
|
||||
return m_checkUvEnabled;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ public:
|
|||
void showWireframes();
|
||||
void hideWireframes();
|
||||
bool isWireframesVisible();
|
||||
void enableCheckUv();
|
||||
void disableCheckUv();
|
||||
bool isCheckUvEnabled();
|
||||
void reloadMesh();
|
||||
private:
|
||||
MeshLoader *m_mesh = nullptr;
|
||||
MeshLoader *m_newMesh = nullptr;
|
||||
|
@ -37,6 +41,7 @@ private:
|
|||
bool m_hasAmbientOcclusionMap = false;
|
||||
QOpenGLTexture *m_metalnessRoughnessAmbientOcclusionMap = nullptr;
|
||||
bool m_toolEnabled = false;
|
||||
bool m_checkUvEnabled = false;
|
||||
private:
|
||||
QOpenGLVertexArrayObject m_vaoTriangle;
|
||||
QOpenGLBuffer m_vboTriangle;
|
||||
|
|
|
@ -194,7 +194,6 @@ std::pair<QVector3D, QVector3D> ModelWidget::screenPositionToMouseRay(const QPoi
|
|||
auto viewPort = QRect(0, 0, width(), height());
|
||||
auto nearPosition = nearScreen.unproject(modelView, m_projection, viewPort);
|
||||
auto farPosition = farScreen.unproject(modelView, m_projection, viewPort);
|
||||
qDebug() << "near:" << nearPosition << "far:" << farPosition << "x:" << x << "y:" << y;
|
||||
return std::make_pair(nearPosition, farPosition);
|
||||
}
|
||||
|
||||
|
@ -207,6 +206,16 @@ void ModelWidget::toggleWireframe()
|
|||
update();
|
||||
}
|
||||
|
||||
void ModelWidget::toggleUvCheck()
|
||||
{
|
||||
if (m_meshBinder.isCheckUvEnabled())
|
||||
m_meshBinder.disableCheckUv();
|
||||
else
|
||||
m_meshBinder.enableCheckUv();
|
||||
m_meshBinder.reloadMesh();
|
||||
update();
|
||||
}
|
||||
|
||||
bool ModelWidget::inputMousePressEventFromOtherWidget(QMouseEvent *event)
|
||||
{
|
||||
bool shouldStartMove = false;
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
void updateMesh(MeshLoader *mesh);
|
||||
void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions);
|
||||
void toggleWireframe();
|
||||
void toggleUvCheck();
|
||||
void enableMove(bool enabled);
|
||||
void enableZoom(bool enabled);
|
||||
void enableMousePicking(bool enabled);
|
||||
|
|
|
@ -83,7 +83,7 @@ void UvUnwrapper::splitPartitionToIslands(const std::vector<size_t> &group, std:
|
|||
continue;
|
||||
if (segmentByNormal) {
|
||||
if (dotProduct(m_mesh.faceNormals[findOppositeFaceResult->second],
|
||||
m_mesh.faceNormals[index]) < m_segmentDotProductThreshold) {
|
||||
m_mesh.faceNormals[m_segmentPreferMorePieces ? indexInGroup : index]) < m_segmentDotProductThreshold) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ private:
|
|||
float m_segmentDotProductThreshold = 0.00;
|
||||
float m_texelSizePerUnit = 1.0;
|
||||
float m_resultTextureSize = 0;
|
||||
bool m_segmentPreferMorePieces = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue