From 1ea723078590aca11a8fc55ba21799f0ef977f62 Mon Sep 17 00:00:00 2001 From: aoowweenn Date: Sat, 31 Mar 2018 14:06:26 +0800 Subject: [PATCH] Handle materials with texture id < 0 --- code/MMDImporter.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/MMDImporter.cpp b/code/MMDImporter.cpp index 76ad9115c..474586413 100644 --- a/code/MMDImporter.cpp +++ b/code/MMDImporter.cpp @@ -354,8 +354,11 @@ aiMaterial *MMDImporter::CreateMaterial(const pmx::PmxMaterial *pMat, float shininess = pMat->specularlity; mat->AddProperty(&shininess, 1, AI_MATKEY_SHININESS_STRENGTH); - aiString texture_path(pModel->textures[pMat->diffuse_texture_index]); - mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0)); + if(pMat->diffuse_texture_index >= 0) { + aiString texture_path(pModel->textures[pMat->diffuse_texture_index]); + mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0)); + } + int mapping_uvwsrc = 0; mat->AddProperty(&mapping_uvwsrc, 1, AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE, 0));