Handle materials with texture id < 0

pull/1863/head
aoowweenn 2018-03-31 14:06:26 +08:00
parent 04d70dc76d
commit 1ea7230785
1 changed files with 5 additions and 2 deletions

View File

@ -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));