Add mtl export with obj
parent
e0621edff1
commit
87b0f70460
|
@ -57,7 +57,7 @@ void ModelMeshBinder::exportMeshAsObj(const QString &filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshBinder::exportMeshAdObjPlusMaterials(const QString &filename)
|
void ModelMeshBinder::exportMeshAsObjPlusMaterials(const QString &filename)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_meshMutex);
|
QMutexLocker lock(&m_meshMutex);
|
||||||
if (m_mesh) {
|
if (m_mesh) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
~ModelMeshBinder();
|
~ModelMeshBinder();
|
||||||
void updateMesh(MeshLoader *mesh);
|
void updateMesh(MeshLoader *mesh);
|
||||||
void exportMeshAsObj(const QString &filename);
|
void exportMeshAsObj(const QString &filename);
|
||||||
void exportMeshAdObjPlusMaterials(const QString &filename);
|
void exportMeshAsObjPlusMaterials(const QString &filename);
|
||||||
void initialize();
|
void initialize();
|
||||||
void paint(ModelShaderProgram *program);
|
void paint(ModelShaderProgram *program);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
|
@ -296,6 +296,6 @@ void ModelWidget::exportMeshAsObj(const QString &filename)
|
||||||
|
|
||||||
void ModelWidget::exportMeshAsObjPlusMaterials(const QString &filename)
|
void ModelWidget::exportMeshAsObjPlusMaterials(const QString &filename)
|
||||||
{
|
{
|
||||||
m_meshBinder.exportMeshAdObjPlusMaterials(filename);
|
m_meshBinder.exportMeshAsObjPlusMaterials(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,13 +250,17 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
|
|
||||||
m_fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
|
|
||||||
m_exportModelAction = new QAction(tr("Wavefront (.obj)..."), this);
|
m_exportAsObjAction = new QAction(tr("Wavefront (.obj)..."), this);
|
||||||
connect(m_exportModelAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportModelResult, Qt::QueuedConnection);
|
connect(m_exportAsObjAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportObjResult, Qt::QueuedConnection);
|
||||||
m_exportMenu->addAction(m_exportModelAction);
|
m_exportMenu->addAction(m_exportAsObjAction);
|
||||||
|
|
||||||
|
m_exportAsObjPlusMaterialsAction = new QAction(tr("Wavefront (.obj + .mtl)..."), this);
|
||||||
|
connect(m_exportAsObjPlusMaterialsAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportObjPlusMaterialsResult, Qt::QueuedConnection);
|
||||||
|
m_exportMenu->addAction(m_exportAsObjPlusMaterialsAction);
|
||||||
|
|
||||||
m_exportSkeletonAction = new QAction(tr("GL Transmission Format (.gltf)..."), this);
|
m_exportAsGltfAction = new QAction(tr("GL Transmission Format (.gltf)..."), this);
|
||||||
connect(m_exportSkeletonAction, &QAction::triggered, this, &SkeletonDocumentWindow::showExportPreview, Qt::QueuedConnection);
|
connect(m_exportAsGltfAction, &QAction::triggered, this, &SkeletonDocumentWindow::showExportPreview, Qt::QueuedConnection);
|
||||||
m_exportMenu->addAction(m_exportSkeletonAction);
|
m_exportMenu->addAction(m_exportAsGltfAction);
|
||||||
|
|
||||||
m_fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
|
|
||||||
|
@ -267,8 +271,9 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
m_fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
|
|
||||||
connect(m_fileMenu, &QMenu::aboutToShow, [=]() {
|
connect(m_fileMenu, &QMenu::aboutToShow, [=]() {
|
||||||
m_exportModelAction->setEnabled(m_graphicsWidget->hasItems());
|
m_exportAsObjAction->setEnabled(m_graphicsWidget->hasItems());
|
||||||
m_exportSkeletonAction->setEnabled(m_graphicsWidget->hasItems());
|
m_exportAsObjPlusMaterialsAction->setEnabled(m_graphicsWidget->hasItems());
|
||||||
|
m_exportAsGltfAction->setEnabled(m_graphicsWidget->hasItems());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_editMenu = menuBar()->addMenu(tr("Edit"));
|
m_editMenu = menuBar()->addMenu(tr("Edit"));
|
||||||
|
@ -930,7 +935,7 @@ void SkeletonDocumentWindow::open()
|
||||||
setCurrentFilename(filename);
|
setCurrentFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonDocumentWindow::exportModelResult()
|
void SkeletonDocumentWindow::exportObjResult()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
||||||
tr("Wavefront (*.obj)"));
|
tr("Wavefront (*.obj)"));
|
||||||
|
@ -938,12 +943,22 @@ void SkeletonDocumentWindow::exportModelResult()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
// Must update mesh before export, because there may be an animation clip playing which breaks the original mesh.
|
|
||||||
m_modelRenderWidget->updateMesh(m_document->takeResultMesh());
|
|
||||||
m_modelRenderWidget->exportMeshAsObj(filename);
|
m_modelRenderWidget->exportMeshAsObj(filename);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkeletonDocumentWindow::exportObjPlusMaterialsResult()
|
||||||
|
{
|
||||||
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
||||||
|
tr("Wavefront (*.obj)"));
|
||||||
|
if (filename.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
m_modelRenderWidget->exportMeshAsObjPlusMaterials(filename);
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
|
|
||||||
void SkeletonDocumentWindow::showExportPreview()
|
void SkeletonDocumentWindow::showExportPreview()
|
||||||
{
|
{
|
||||||
if (nullptr == m_exportPreviewWidget) {
|
if (nullptr == m_exportPreviewWidget) {
|
||||||
|
|
|
@ -34,7 +34,8 @@ public slots:
|
||||||
void save();
|
void save();
|
||||||
void saveTo(const QString &saveAsFilename);
|
void saveTo(const QString &saveAsFilename);
|
||||||
void open();
|
void open();
|
||||||
void exportModelResult();
|
void exportObjResult();
|
||||||
|
void exportObjPlusMaterialsResult();
|
||||||
void exportGltfResult();
|
void exportGltfResult();
|
||||||
void showExportPreview();
|
void showExportPreview();
|
||||||
void newWindow();
|
void newWindow();
|
||||||
|
@ -77,8 +78,9 @@ private:
|
||||||
QMenu *m_exportMenu;
|
QMenu *m_exportMenu;
|
||||||
QAction *m_changeTurnaroundAction;
|
QAction *m_changeTurnaroundAction;
|
||||||
|
|
||||||
QAction *m_exportModelAction;
|
QAction *m_exportAsObjAction;
|
||||||
QAction *m_exportSkeletonAction;
|
QAction *m_exportAsObjPlusMaterialsAction;
|
||||||
|
QAction *m_exportAsGltfAction;
|
||||||
|
|
||||||
QMenu *m_editMenu;
|
QMenu *m_editMenu;
|
||||||
QAction *m_addAction;
|
QAction *m_addAction;
|
||||||
|
|
Loading…
Reference in New Issue