(WIP) (has debug) Fix baked FBX materials

This commit is contained in:
sabrina-shanman 2019-10-24 18:02:19 -07:00
parent e74de214e2
commit fa51ec3daf
2 changed files with 7 additions and 12 deletions

View file

@ -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
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) {
hfm::Shape& shape = partShapes[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) << "partShapes is not the same size as materialIDPerMeshPart ?";
}*/
}
}
// find the clusters with which the mesh is associated

View file

@ -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
draco::Decoder decoder;
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
int& partIndexPlusOne = materialTextureParts[materialTexture];
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();
// Figure out if this is the older way of defining the per-part material for baked FBX
if (dracoMeshNodeVersion >= 2) {
// Define the materialID now
if (materialID < dracoMaterialList.size()) {
part.materialID = QString(dracoMaterialList[materialID].c_str());
}
// Define the materialID for this mesh part index
uint16_t safeMaterialID = materialID < dracoMaterialList.size() ? materialID : 0;
data.extracted.materialIDPerMeshPart.push_back(dracoMaterialList[materialID].c_str());
} else {
// Define the materialID later, based on the order of first appearance of the materials in the _connectionChildMap
data.extracted.partMaterialTextures.append(materialTexture);