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