Fix merged texture image
The merged texture image of metalness, roughness and ambient occlusion did not get saved in the document class, this commit fixed it.master
parent
1f8f7913a7
commit
7f5a47c074
|
@ -23,8 +23,9 @@ Document::Document() :
|
|||
textureGuideImage(nullptr),
|
||||
textureImage(nullptr),
|
||||
textureBorderImage(nullptr),
|
||||
textureAmbientOcclusionImage(nullptr),
|
||||
textureColorImage(nullptr),
|
||||
textureNormalImage(nullptr),
|
||||
textureMetalnessRoughnessAmbientOcclusionImage(nullptr),
|
||||
rigType(RigType::None),
|
||||
weldEnabled(true),
|
||||
// private
|
||||
|
@ -62,8 +63,10 @@ Document::~Document()
|
|||
delete m_postProcessedOutcome;
|
||||
delete textureGuideImage;
|
||||
delete textureImage;
|
||||
delete textureColorImage;
|
||||
delete textureNormalImage;
|
||||
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
||||
delete textureBorderImage;
|
||||
delete textureAmbientOcclusionImage;
|
||||
delete m_resultTextureMesh;
|
||||
delete m_resultRigWeightMesh;
|
||||
}
|
||||
|
@ -1507,12 +1510,15 @@ void Document::textureReady()
|
|||
delete textureBorderImage;
|
||||
textureBorderImage = m_textureGenerator->takeResultTextureBorderImage();
|
||||
|
||||
delete textureAmbientOcclusionImage;
|
||||
textureAmbientOcclusionImage = nullptr;
|
||||
|
||||
delete textureColorImage;
|
||||
textureColorImage = m_textureGenerator->takeResultTextureColorImage();
|
||||
|
||||
delete textureNormalImage;
|
||||
textureNormalImage = m_textureGenerator->takeResultTextureNormalImage();
|
||||
|
||||
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
||||
textureMetalnessRoughnessAmbientOcclusionImage = m_textureGenerator->takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
||||
|
||||
delete m_resultTextureMesh;
|
||||
m_resultTextureMesh = m_textureGenerator->takeResultMesh();
|
||||
|
||||
|
|
|
@ -449,8 +449,9 @@ public: // need initialize
|
|||
QImage *textureGuideImage;
|
||||
QImage *textureImage;
|
||||
QImage *textureBorderImage;
|
||||
QImage *textureAmbientOcclusionImage;
|
||||
QImage *textureColorImage;
|
||||
QImage *textureNormalImage;
|
||||
QImage *textureMetalnessRoughnessAmbientOcclusionImage;
|
||||
RigType rigType;
|
||||
bool weldEnabled;
|
||||
public:
|
||||
|
|
|
@ -12,16 +12,24 @@
|
|||
ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_document(document),
|
||||
m_previewLabel(nullptr),
|
||||
m_colorPreviewLabel(nullptr),
|
||||
m_spinnerWidget(nullptr)
|
||||
{
|
||||
QHBoxLayout *toolButtonLayout = new QHBoxLayout;
|
||||
toolButtonLayout->setSpacing(0);
|
||||
//toolButtonLayout->setContentsMargins(5, 10, 4, 0);
|
||||
|
||||
m_previewLabel = new QLabel;
|
||||
m_previewLabel->setMinimumSize(128, 128);
|
||||
m_previewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_colorPreviewLabel = new QLabel;
|
||||
m_colorPreviewLabel->setMinimumSize(128, 128);
|
||||
m_colorPreviewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
m_normalPreviewLabel = new QLabel;
|
||||
m_normalPreviewLabel->setMinimumSize(64, 64);
|
||||
m_normalPreviewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
m_metalnessRoughnessAmbientOcclusionPreviewLabel = new QLabel;
|
||||
m_metalnessRoughnessAmbientOcclusionPreviewLabel->setMinimumSize(64, 64);
|
||||
m_metalnessRoughnessAmbientOcclusionPreviewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
//QPushButton *regenerateButton = new QPushButton(QChar(fa::recycle));
|
||||
//initAwesomeButton(regenerateButton);
|
||||
|
@ -54,7 +62,9 @@ ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) :
|
|||
QGridLayout *containerLayout = new QGridLayout;
|
||||
containerLayout->setSpacing(0);
|
||||
containerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
containerLayout->addWidget(m_previewLabel);
|
||||
containerLayout->addWidget(m_colorPreviewLabel, 0, 0);
|
||||
//containerLayout->addWidget(m_normalPreviewLabel, 1, 0);
|
||||
//containerLayout->addWidget(m_metalnessRoughnessAmbientOcclusionPreviewLabel, 2, 0);
|
||||
containerLayout->setRowStretch(0, 1);
|
||||
containerLayout->setColumnStretch(0, 1);
|
||||
|
||||
|
@ -84,7 +94,7 @@ ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) :
|
|||
setMinimumSize(256, 256);
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
m_spinnerWidget = new WaitingSpinnerWidget(m_previewLabel);
|
||||
m_spinnerWidget = new WaitingSpinnerWidget(m_colorPreviewLabel);
|
||||
m_spinnerWidget->setColor(Theme::white);
|
||||
m_spinnerWidget->setInnerRadius(Theme::miniIconFontSize / 4);
|
||||
m_spinnerWidget->setNumberOfLines(12);
|
||||
|
@ -95,23 +105,26 @@ ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) :
|
|||
emit updateTexturePreview();
|
||||
}
|
||||
|
||||
void ExportPreviewWidget::updateTexturePreviewImage(const QImage &image)
|
||||
{
|
||||
m_previewImage = image;
|
||||
resizePreviewImage();
|
||||
checkSpinner();
|
||||
}
|
||||
|
||||
void ExportPreviewWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
resizePreviewImage();
|
||||
resizePreviewImages();
|
||||
}
|
||||
|
||||
void ExportPreviewWidget::resizePreviewImage()
|
||||
void ExportPreviewWidget::resizePreviewImages()
|
||||
{
|
||||
QPixmap pixmap = QPixmap::fromImage(m_previewImage);
|
||||
m_previewLabel->setPixmap(pixmap.scaled(m_previewLabel->width(), m_previewLabel->height(), Qt::KeepAspectRatio));
|
||||
{
|
||||
QPixmap pixmap = QPixmap::fromImage(m_colorImage);
|
||||
m_colorPreviewLabel->setPixmap(pixmap.scaled(m_colorPreviewLabel->width(), m_colorPreviewLabel->height(), Qt::KeepAspectRatio));
|
||||
}
|
||||
{
|
||||
QPixmap pixmap = QPixmap::fromImage(m_normalImage);
|
||||
m_normalPreviewLabel->setPixmap(pixmap.scaled(m_normalPreviewLabel->width(), m_normalPreviewLabel->height(), Qt::KeepAspectRatio));
|
||||
}
|
||||
{
|
||||
QPixmap pixmap = QPixmap::fromImage(m_metalnessRoughnessAmbientOcclusionImage);
|
||||
m_metalnessRoughnessAmbientOcclusionPreviewLabel->setPixmap(pixmap.scaled(m_metalnessRoughnessAmbientOcclusionPreviewLabel->width(), m_metalnessRoughnessAmbientOcclusionPreviewLabel->height(), Qt::KeepAspectRatio));
|
||||
}
|
||||
}
|
||||
|
||||
void ExportPreviewWidget::initAwesomeButton(QPushButton *button)
|
||||
|
@ -147,7 +160,13 @@ void ExportPreviewWidget::checkSpinner()
|
|||
void ExportPreviewWidget::updateTexturePreview()
|
||||
{
|
||||
if (m_document->textureGuideImage)
|
||||
updateTexturePreviewImage(*m_document->textureGuideImage);
|
||||
m_colorImage = *m_document->textureGuideImage;
|
||||
if (m_document->textureNormalImage)
|
||||
m_normalImage = *m_document->textureNormalImage;
|
||||
if (m_document->textureMetalnessRoughnessAmbientOcclusionImage)
|
||||
m_metalnessRoughnessAmbientOcclusionImage = *m_document->textureMetalnessRoughnessAmbientOcclusionImage;
|
||||
m_textureRenderWidget->updateMesh(m_document->takeResultTextureMesh());
|
||||
resizePreviewImages();
|
||||
checkSpinner();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,16 @@ protected:
|
|||
void resizeEvent(QResizeEvent *event);
|
||||
void showEvent(QShowEvent *event);
|
||||
private:
|
||||
void resizePreviewImage();
|
||||
void resizePreviewImages();
|
||||
void initAwesomeButton(QPushButton *button);
|
||||
void updateTexturePreviewImage(const QImage &image);
|
||||
private:
|
||||
Document *m_document;
|
||||
QLabel *m_previewLabel;
|
||||
QImage m_previewImage;
|
||||
QLabel *m_colorPreviewLabel;
|
||||
QLabel *m_normalPreviewLabel;
|
||||
QLabel *m_metalnessRoughnessAmbientOcclusionPreviewLabel;
|
||||
QImage m_colorImage;
|
||||
QImage m_normalImage;
|
||||
QImage m_metalnessRoughnessAmbientOcclusionImage;
|
||||
ModelWidget *m_textureRenderWidget;
|
||||
WaitingSpinnerWidget *m_spinnerWidget;
|
||||
QPushButton *m_saveButton;
|
||||
|
|
|
@ -79,6 +79,13 @@ QImage *TextureGenerator::takeResultTextureNormalImage()
|
|||
return resultTextureNormalImage;
|
||||
}
|
||||
|
||||
QImage *TextureGenerator::takeResultTextureMetalnessRoughnessAmbientOcclusionImage()
|
||||
{
|
||||
QImage *resultTextureMetalnessRoughnessAmbientOcclusionImage = m_resultTextureMetalnessRoughnessAmbientOcclusionImage;
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage = nullptr;
|
||||
return resultTextureMetalnessRoughnessAmbientOcclusionImage;
|
||||
}
|
||||
|
||||
Outcome *TextureGenerator::takeOutcome()
|
||||
{
|
||||
Outcome *outcome = m_outcome;
|
||||
|
@ -213,7 +220,7 @@ void TextureGenerator::generate()
|
|||
m_resultTextureNormalImage->fill(Qt::transparent);
|
||||
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage = new QImage(TextureGenerator::m_textureSize, TextureGenerator::m_textureSize, QImage::Format_ARGB32);
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage->fill(Qt::transparent);
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage->fill(QColor(255, 255, 0));
|
||||
|
||||
m_resultTextureMetalnessImage = new QImage(TextureGenerator::m_textureSize, TextureGenerator::m_textureSize, QImage::Format_ARGB32);
|
||||
m_resultTextureMetalnessImage->fill(Qt::black);
|
||||
|
@ -361,7 +368,7 @@ void TextureGenerator::generate()
|
|||
} else {
|
||||
for (int row = 0; row < m_resultTextureMetalnessRoughnessAmbientOcclusionImage->height(); ++row) {
|
||||
for (int col = 0; col < m_resultTextureMetalnessRoughnessAmbientOcclusionImage->width(); ++col) {
|
||||
QColor color;
|
||||
QColor color(255, 255, 0);
|
||||
if (hasMetalnessMap)
|
||||
color.setBlue(qGray(m_resultTextureMetalnessImage->pixel(col, row)));
|
||||
if (hasRoughnessMap)
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
QImage *takeResultTextureBorderImage();
|
||||
QImage *takeResultTextureColorImage();
|
||||
QImage *takeResultTextureNormalImage();
|
||||
QImage *takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
||||
Outcome *takeOutcome();
|
||||
MeshLoader *takeResultMesh();
|
||||
void addPartColorMap(QUuid partId, const QImage *image);
|
||||
|
|
Loading…
Reference in New Issue