mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:59:03 +02:00
(WIP) (has debug) Fix baked FBX materials
This commit is contained in:
parent
e74de214e2
commit
fa51ec3daf
2 changed files with 7 additions and 12 deletions
|
@ -1562,7 +1562,8 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
}
|
}
|
||||||
// For baked models with FBX_DRACO_MESH_VERSION >= 2, get materials from extracted.materialIDPerMeshPart
|
// For baked models with FBX_DRACO_MESH_VERSION >= 2, get materials from extracted.materialIDPerMeshPart
|
||||||
if (!extracted.materialIDPerMeshPart.empty()) {
|
if (!extracted.materialIDPerMeshPart.empty()) {
|
||||||
/* if (partShapes.size() == extracted.materialIDPerMeshPart.size()) {
|
// TODO: Verify this code works as intended by testing baked FBX models, then remove the verification/debug
|
||||||
|
if (partShapes.size() == extracted.materialIDPerMeshPart.size()) {
|
||||||
for (uint32_t i = 0; i < (uint32_t)extracted.materialIDPerMeshPart.size(); ++i) {
|
for (uint32_t i = 0; i < (uint32_t)extracted.materialIDPerMeshPart.size(); ++i) {
|
||||||
hfm::Shape& shape = partShapes[i];
|
hfm::Shape& shape = partShapes[i];
|
||||||
const std::string& materialID = extracted.materialIDPerMeshPart[i];
|
const std::string& materialID = extracted.materialIDPerMeshPart[i];
|
||||||
|
@ -1576,7 +1577,7 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
qCDebug(modelformat) << "mesh.parts[" << p <<"] is " << mesh.parts[p].materialID;
|
qCDebug(modelformat) << "mesh.parts[" << p <<"] is " << mesh.parts[p].materialID;
|
||||||
}
|
}
|
||||||
qCDebug(modelformat) << "partShapes is not the same size as materialIDPerMeshPart ?";
|
qCDebug(modelformat) << "partShapes is not the same size as materialIDPerMeshPart ?";
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the clusters with which the mesh is associated
|
// find the clusters with which the mesh is associated
|
||||||
|
|
|
@ -369,11 +369,6 @@ ExtractedMesh FBXSerializer::extractMesh(const FBXNode& object, unsigned int& me
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dracoMeshNodeVersion >= 2) {
|
|
||||||
// Define the materialIDs now
|
|
||||||
data.extracted.materialIDPerMeshPart = dracoMaterialList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the draco mesh from the FBX and create a draco::Mesh
|
// load the draco mesh from the FBX and create a draco::Mesh
|
||||||
draco::Decoder decoder;
|
draco::Decoder decoder;
|
||||||
draco::DecoderBuffer decodedBuffer;
|
draco::DecoderBuffer decodedBuffer;
|
||||||
|
@ -491,15 +486,14 @@ ExtractedMesh FBXSerializer::extractMesh(const FBXNode& object, unsigned int& me
|
||||||
// grab or setup the HFMMeshPart for the part this face belongs to
|
// grab or setup the HFMMeshPart for the part this face belongs to
|
||||||
int& partIndexPlusOne = materialTextureParts[materialTexture];
|
int& partIndexPlusOne = materialTextureParts[materialTexture];
|
||||||
if (partIndexPlusOne == 0) {
|
if (partIndexPlusOne == 0) {
|
||||||
data.extracted.mesh.parts.resize(data.extracted.mesh.parts.size() + 1);
|
data.extracted.mesh.parts.emplace_back();
|
||||||
HFMMeshPart& part = data.extracted.mesh.parts.back();
|
HFMMeshPart& part = data.extracted.mesh.parts.back();
|
||||||
|
|
||||||
// Figure out if this is the older way of defining the per-part material for baked FBX
|
// Figure out if this is the older way of defining the per-part material for baked FBX
|
||||||
if (dracoMeshNodeVersion >= 2) {
|
if (dracoMeshNodeVersion >= 2) {
|
||||||
// Define the materialID now
|
// Define the materialID for this mesh part index
|
||||||
if (materialID < dracoMaterialList.size()) {
|
uint16_t safeMaterialID = materialID < dracoMaterialList.size() ? materialID : 0;
|
||||||
part.materialID = QString(dracoMaterialList[materialID].c_str());
|
data.extracted.materialIDPerMeshPart.push_back(dracoMaterialList[materialID].c_str());
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Define the materialID later, based on the order of first appearance of the materials in the _connectionChildMap
|
// Define the materialID later, based on the order of first appearance of the materials in the _connectionChildMap
|
||||||
data.extracted.partMaterialTextures.append(materialTexture);
|
data.extracted.partMaterialTextures.append(materialTexture);
|
||||||
|
|
Loading…
Reference in a new issue