From 3179e949bb0facfa6c2ce1a24ee0eb7ed96bec0c Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Thu, 5 Jul 2012 16:37:13 +0200 Subject: [PATCH] - fbx: set default material when no material layer is assigned to a mesh. --- code/FBXConverter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 74d611d9b..fece464c5 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -354,7 +354,13 @@ private: } const std::vector& mindices = mesh.GetMaterialIndices(); - ConvertMaterialForMesh(out_mesh,model,mesh,mindices.size() ? mindices[0] : 0); + if(mindices.empty()) { + FBXImporter::LogError("no material assigned to mesh, setting default material"); + out_mesh->mMaterialIndex = GetDefaultMaterial(); + } + else { + ConvertMaterialForMesh(out_mesh,model,mesh,mindices[0]); + } return static_cast(meshes.size()); } @@ -542,7 +548,7 @@ private: // locate source materials for this mesh const std::vector& mats = model.GetMaterials(); if (materialIndex >= mats.size()) { - FBXImporter::LogError("material index out of bounds, ignoring"); + FBXImporter::LogError("material index out of bounds, setting default material"); out->mMaterialIndex = GetDefaultMaterial(); return; }