Add rendered model color toggle
parent
846270fa80
commit
7ade61ab65
|
@ -330,10 +330,6 @@ Tips:
|
|||
<source>Toggle UV Check</source>
|
||||
<translation>切换UV检查</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle rotation</source>
|
||||
<translation>旋转视角</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Colorize</source>
|
||||
<translation>着色</translation>
|
||||
|
@ -394,6 +390,14 @@ Tips:
|
|||
<source>Toggle Rotation</source>
|
||||
<translation>打开/关闭自动旋转</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle viewport</source>
|
||||
<translation>切换视图</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggle Color</source>
|
||||
<translation>打开/关闭颜色</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ExportPreviewWidget</name>
|
||||
|
|
|
@ -179,7 +179,7 @@ DocumentWindow::DocumentWindow() :
|
|||
Theme::initAwesomeButton(zoomOutButton);
|
||||
|
||||
m_rotationButton = new QPushButton(QChar(fa::caretsquareoup));
|
||||
m_rotationButton->setToolTip(tr("Toggle rotation"));
|
||||
m_rotationButton->setToolTip(tr("Toggle viewport"));
|
||||
Theme::initAwesomeButton(m_rotationButton);
|
||||
updateRotationButtonState();
|
||||
|
||||
|
@ -733,6 +733,23 @@ DocumentWindow::DocumentWindow() :
|
|||
});
|
||||
m_viewMenu->addAction(m_toggleRotationAction);
|
||||
|
||||
m_toggleColorAction = new QAction(tr("Toggle Color"), this);
|
||||
connect(m_toggleColorAction, &QAction::triggered, [&]() {
|
||||
m_modelRemoveColor = !m_modelRemoveColor;
|
||||
MeshLoader *mesh = nullptr;
|
||||
if (m_document->isMeshGenerating() &&
|
||||
m_document->isPostProcessing() &&
|
||||
m_document->isTextureGenerating()) {
|
||||
mesh = m_document->takeResultMesh();
|
||||
} else {
|
||||
mesh = m_document->takeResultTextureMesh();
|
||||
}
|
||||
if (m_modelRemoveColor && mesh)
|
||||
mesh->removeColor();
|
||||
m_modelRenderWidget->updateMesh(mesh);
|
||||
});
|
||||
m_viewMenu->addAction(m_toggleColorAction);
|
||||
|
||||
m_toggleUvCheckAction = new QAction(tr("Toggle UV Check"), this);
|
||||
connect(m_toggleUvCheckAction, &QAction::triggered, [=]() {
|
||||
m_modelRenderWidget->toggleUvCheck();
|
||||
|
@ -1080,6 +1097,8 @@ DocumentWindow::DocumentWindow() :
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (m_modelRemoveColor && resultTextureMesh)
|
||||
resultTextureMesh->removeColor();
|
||||
m_modelRenderWidget->updateMesh(resultTextureMesh);
|
||||
});
|
||||
|
||||
|
@ -1087,6 +1106,8 @@ DocumentWindow::DocumentWindow() :
|
|||
auto resultMesh = m_document->takeResultMesh();
|
||||
if (nullptr != resultMesh)
|
||||
m_currentUpdatedMeshId = resultMesh->meshId();
|
||||
if (m_modelRemoveColor && resultMesh)
|
||||
resultMesh->removeColor();
|
||||
m_modelRenderWidget->updateMesh(resultMesh);
|
||||
});
|
||||
|
||||
|
|
|
@ -169,6 +169,8 @@ private:
|
|||
QAction *m_toggleWireframeAction;
|
||||
QAction *m_toggleUvCheckAction;
|
||||
QAction *m_toggleRotationAction;
|
||||
QAction *m_toggleColorAction;
|
||||
bool m_modelRemoveColor = false;
|
||||
|
||||
QMenu *m_windowMenu;
|
||||
QAction *m_showPartsListAction;
|
||||
|
|
|
@ -57,6 +57,29 @@ MeshLoader::MeshLoader(const MeshLoader &mesh) :
|
|||
this->m_meshId = mesh.meshId();
|
||||
}
|
||||
|
||||
void MeshLoader::removeColor()
|
||||
{
|
||||
delete this->m_textureImage;
|
||||
this->m_textureImage = nullptr;
|
||||
|
||||
delete this->m_normalMapImage;
|
||||
this->m_normalMapImage = nullptr;
|
||||
|
||||
delete this->m_metalnessRoughnessAmbientOcclusionImage;
|
||||
this->m_metalnessRoughnessAmbientOcclusionImage = nullptr;
|
||||
|
||||
this->m_hasMetalnessInImage = false;
|
||||
this->m_hasRoughnessInImage = false;
|
||||
this->m_hasAmbientOcclusionInImage = false;
|
||||
|
||||
for (int i = 0; i < this->m_triangleVertexCount; ++i) {
|
||||
auto &vertex = this->m_triangleVertices[i];
|
||||
vertex.colorR = 1.0;
|
||||
vertex.colorG = 1.0;
|
||||
vertex.colorB = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
MeshLoader::MeshLoader(ShaderVertex *triangleVertices, int vertexNum, ShaderVertex *edgeVertices, int edgeVertexCount) :
|
||||
m_triangleVertices(triangleVertices),
|
||||
m_triangleVertexCount(vertexNum),
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
void updateTriangleVertices(ShaderVertex *triangleVertices, int triangleVertexCount);
|
||||
quint64 meshId() const;
|
||||
void setMeshId(quint64 id);
|
||||
void removeColor();
|
||||
private:
|
||||
ShaderVertex *m_triangleVertices = nullptr;
|
||||
int m_triangleVertexCount = 0;
|
||||
|
|
Loading…
Reference in New Issue