Export metallic, roughness and ambient occlusion map to fbx file
parent
017c970fb0
commit
ebe97adcde
|
@ -26,6 +26,9 @@ Document::Document() :
|
||||||
textureColorImage(nullptr),
|
textureColorImage(nullptr),
|
||||||
textureNormalImage(nullptr),
|
textureNormalImage(nullptr),
|
||||||
textureMetalnessRoughnessAmbientOcclusionImage(nullptr),
|
textureMetalnessRoughnessAmbientOcclusionImage(nullptr),
|
||||||
|
textureMetalnessImage(nullptr),
|
||||||
|
textureRoughnessImage(nullptr),
|
||||||
|
textureAmbientOcclusionImage(nullptr),
|
||||||
rigType(RigType::None),
|
rigType(RigType::None),
|
||||||
weldEnabled(true),
|
weldEnabled(true),
|
||||||
// private
|
// private
|
||||||
|
@ -66,6 +69,9 @@ Document::~Document()
|
||||||
delete textureColorImage;
|
delete textureColorImage;
|
||||||
delete textureNormalImage;
|
delete textureNormalImage;
|
||||||
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
||||||
|
delete textureMetalnessImage;
|
||||||
|
delete textureRoughnessImage;
|
||||||
|
delete textureAmbientOcclusionImage;
|
||||||
delete textureBorderImage;
|
delete textureBorderImage;
|
||||||
delete m_resultTextureMesh;
|
delete m_resultTextureMesh;
|
||||||
delete m_resultRigWeightMesh;
|
delete m_resultRigWeightMesh;
|
||||||
|
@ -1523,6 +1529,15 @@ void Document::textureReady()
|
||||||
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
delete textureMetalnessRoughnessAmbientOcclusionImage;
|
||||||
textureMetalnessRoughnessAmbientOcclusionImage = m_textureGenerator->takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
textureMetalnessRoughnessAmbientOcclusionImage = m_textureGenerator->takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
||||||
|
|
||||||
|
delete textureMetalnessImage;
|
||||||
|
textureMetalnessImage = m_textureGenerator->takeResultTextureMetalnessImage();
|
||||||
|
|
||||||
|
delete textureRoughnessImage;
|
||||||
|
textureRoughnessImage = m_textureGenerator->takeResultTextureRoughnessImage();
|
||||||
|
|
||||||
|
delete textureAmbientOcclusionImage;
|
||||||
|
textureAmbientOcclusionImage = m_textureGenerator->takeResultTextureAmbientOcclusionImage();
|
||||||
|
|
||||||
delete m_resultTextureMesh;
|
delete m_resultTextureMesh;
|
||||||
m_resultTextureMesh = m_textureGenerator->takeResultMesh();
|
m_resultTextureMesh = m_textureGenerator->takeResultMesh();
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,9 @@ public: // need initialize
|
||||||
QImage *textureColorImage;
|
QImage *textureColorImage;
|
||||||
QImage *textureNormalImage;
|
QImage *textureNormalImage;
|
||||||
QImage *textureMetalnessRoughnessAmbientOcclusionImage;
|
QImage *textureMetalnessRoughnessAmbientOcclusionImage;
|
||||||
|
QImage *textureMetalnessImage;
|
||||||
|
QImage *textureRoughnessImage;
|
||||||
|
QImage *textureAmbientOcclusionImage;
|
||||||
RigType rigType;
|
RigType rigType;
|
||||||
bool weldEnabled;
|
bool weldEnabled;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1270,7 +1270,11 @@ void DocumentWindow::exportFbxResult()
|
||||||
exportMotions.push_back({motion->name, motion->jointNodeTrees});
|
exportMotions.push_back({motion->name, motion->jointNodeTrees});
|
||||||
}
|
}
|
||||||
FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename,
|
FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename,
|
||||||
m_document->textureImage, m_document->textureNormalImage, m_document->textureMetalnessRoughnessAmbientOcclusionImage,
|
m_document->textureImage,
|
||||||
|
m_document->textureNormalImage,
|
||||||
|
m_document->textureMetalnessImage,
|
||||||
|
m_document->textureRoughnessImage,
|
||||||
|
m_document->textureAmbientOcclusionImage,
|
||||||
exportMotions.empty() ? nullptr : &exportMotions);
|
exportMotions.empty() ? nullptr : &exportMotions);
|
||||||
fbxFileWriter.save();
|
fbxFileWriter.save();
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
|
@ -2206,7 +2206,9 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
QImage *textureImage,
|
QImage *textureImage,
|
||||||
QImage *normalImage,
|
QImage *normalImage,
|
||||||
QImage *ormImage,
|
QImage *metalnessImage,
|
||||||
|
QImage *roughnessImage,
|
||||||
|
QImage *ambientOcclusionImage,
|
||||||
const std::vector<std::pair<QString, std::vector<std::pair<float, JointNodeTree>>>> *motions) :
|
const std::vector<std::pair<QString, std::vector<std::pair<float, JointNodeTree>>>> *motions) :
|
||||||
m_filename(filename),
|
m_filename(filename),
|
||||||
m_baseName(QFileInfo(m_filename).baseName())
|
m_baseName(QFileInfo(m_filename).baseName())
|
||||||
|
@ -2922,7 +2924,7 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome,
|
||||||
p.addProperty("float");
|
p.addProperty("float");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty((float)0.000000);
|
p.addProperty(metalnessImage ? (float)1.000000 : (float)0.000000);
|
||||||
properties.addChild(p);
|
properties.addChild(p);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -2950,7 +2952,7 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome,
|
||||||
p.addProperty("float");
|
p.addProperty("float");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty((float)0.000000);
|
p.addProperty(roughnessImage ? (float)1.000000 : (float)0.000000);
|
||||||
properties.addChild(p);
|
properties.addChild(p);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -3029,7 +3031,7 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome,
|
||||||
p.addProperty("float");
|
p.addProperty("float");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty("");
|
p.addProperty("");
|
||||||
p.addProperty((float)0.000000);
|
p.addProperty(ambientOcclusionImage ? (float)1.000000 : (float)0.000000);
|
||||||
properties.addChild(p);
|
properties.addChild(p);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -3577,6 +3579,27 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome,
|
||||||
m_baseName + "_normal.png",
|
m_baseName + "_normal.png",
|
||||||
"Maya|TEX_normal_map");
|
"Maya|TEX_normal_map");
|
||||||
}
|
}
|
||||||
|
if (nullptr != metalnessImage) {
|
||||||
|
addTexture(metalnessImage,
|
||||||
|
std::vector<uint8_t>({'V','i','d','e','o',0,1,'M','e','t','a','l','l','i','c'}),
|
||||||
|
std::vector<uint8_t>({'T','e','x','t','u','r','e',0,1,'M','e','t','a','l','l','i','c'}),
|
||||||
|
m_baseName + "_metallic.png",
|
||||||
|
"Maya|TEX_metallic_map");
|
||||||
|
}
|
||||||
|
if (nullptr != roughnessImage) {
|
||||||
|
addTexture(roughnessImage,
|
||||||
|
std::vector<uint8_t>({'V','i','d','e','o',0,1,'R','o','u','g','h','n','e','s','s'}),
|
||||||
|
std::vector<uint8_t>({'T','e','x','t','u','r','e',0,1,'R','o','u','g','h','n','e','s','s'}),
|
||||||
|
m_baseName + "_roughness.png",
|
||||||
|
"Maya|TEX_roughness_map");
|
||||||
|
}
|
||||||
|
if (nullptr != ambientOcclusionImage) {
|
||||||
|
addTexture(ambientOcclusionImage,
|
||||||
|
std::vector<uint8_t>({'V','i','d','e','o',0,1,'A','o'}),
|
||||||
|
std::vector<uint8_t>({'T','e','x','t','u','r','e',0,1,'A','o'}),
|
||||||
|
m_baseName + "_ao.png",
|
||||||
|
"Maya|TEX_ao_map");
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (nullptr != textureImage) {
|
if (nullptr != textureImage) {
|
||||||
addTexture(textureImage,
|
addTexture(textureImage,
|
||||||
|
|
|
@ -19,7 +19,9 @@ public:
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
QImage *textureImage=nullptr,
|
QImage *textureImage=nullptr,
|
||||||
QImage *normalImage=nullptr,
|
QImage *normalImage=nullptr,
|
||||||
QImage *ormImage=nullptr,
|
QImage *metalnessImage=nullptr,
|
||||||
|
QImage *roughnessImage=nullptr,
|
||||||
|
QImage *ambientOcclusionImage=nullptr,
|
||||||
const std::vector<std::pair<QString, std::vector<std::pair<float, JointNodeTree>>>> *motions=nullptr);
|
const std::vector<std::pair<QString, std::vector<std::pair<float, JointNodeTree>>>> *motions=nullptr);
|
||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,27 @@ QImage *TextureGenerator::takeResultTextureMetalnessRoughnessAmbientOcclusionIma
|
||||||
return resultTextureMetalnessRoughnessAmbientOcclusionImage;
|
return resultTextureMetalnessRoughnessAmbientOcclusionImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QImage *TextureGenerator::takeResultTextureRoughnessImage()
|
||||||
|
{
|
||||||
|
QImage *resultTextureRoughnessImage = m_resultTextureRoughnessImage;
|
||||||
|
m_resultTextureRoughnessImage = nullptr;
|
||||||
|
return resultTextureRoughnessImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage *TextureGenerator::takeResultTextureMetalnessImage()
|
||||||
|
{
|
||||||
|
QImage *resultTextureMetalnessImage = m_resultTextureMetalnessImage;
|
||||||
|
m_resultTextureMetalnessImage = nullptr;
|
||||||
|
return resultTextureMetalnessImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage *TextureGenerator::takeResultTextureAmbientOcclusionImage()
|
||||||
|
{
|
||||||
|
QImage *resultTextureAmbientOcclusionImage = m_resultTextureAmbientOcclusionImage;
|
||||||
|
m_resultTextureAmbientOcclusionImage = nullptr;
|
||||||
|
return resultTextureAmbientOcclusionImage;
|
||||||
|
}
|
||||||
|
|
||||||
Outcome *TextureGenerator::takeOutcome()
|
Outcome *TextureGenerator::takeOutcome()
|
||||||
{
|
{
|
||||||
Outcome *outcome = m_outcome;
|
Outcome *outcome = m_outcome;
|
||||||
|
@ -386,6 +407,18 @@ void TextureGenerator::generate()
|
||||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage->setPixelColor(col, row, color);
|
m_resultTextureMetalnessRoughnessAmbientOcclusionImage->setPixelColor(col, row, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasMetalnessMap) {
|
||||||
|
delete m_resultTextureMetalnessImage;
|
||||||
|
m_resultTextureMetalnessImage = nullptr;
|
||||||
|
}
|
||||||
|
if (!hasRoughnessMap) {
|
||||||
|
delete m_resultTextureRoughnessImage;
|
||||||
|
m_resultTextureRoughnessImage = nullptr;
|
||||||
|
}
|
||||||
|
if (!hasAmbientOcclusionMap) {
|
||||||
|
delete m_resultTextureAmbientOcclusionImage;
|
||||||
|
m_resultTextureAmbientOcclusionImage = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto mergeMetalnessRoughnessAmbientOcclusionEndTime = countTimeConsumed.elapsed();
|
auto mergeMetalnessRoughnessAmbientOcclusionEndTime = countTimeConsumed.elapsed();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
QImage *takeResultTextureColorImage();
|
QImage *takeResultTextureColorImage();
|
||||||
QImage *takeResultTextureNormalImage();
|
QImage *takeResultTextureNormalImage();
|
||||||
QImage *takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
QImage *takeResultTextureMetalnessRoughnessAmbientOcclusionImage();
|
||||||
|
QImage *takeResultTextureRoughnessImage();
|
||||||
|
QImage *takeResultTextureMetalnessImage();
|
||||||
|
QImage *takeResultTextureAmbientOcclusionImage();
|
||||||
Outcome *takeOutcome();
|
Outcome *takeOutcome();
|
||||||
MeshLoader *takeResultMesh();
|
MeshLoader *takeResultMesh();
|
||||||
void addPartColorMap(QUuid partId, const QImage *image);
|
void addPartColorMap(QUuid partId, const QImage *image);
|
||||||
|
|
Loading…
Reference in New Issue