FIX: Obj loader failed to read models with strange UV coordinates (see https://sourceforge.net/forum/forum.php?thread_id=2869243&forum_id=817653).

Added the model that was reported as crashing to the regression test suite.


git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@306 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2009-01-19 00:40:48 +00:00
parent d41f570dc0
commit 561943e75c
3 changed files with 6128 additions and 10 deletions

View File

@ -319,17 +319,18 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
pMesh->mNormals = new aiVector3D[ pMesh->mNumVertices ];
// Allocate buffer for texture coordinates
if ( !pModel->m_TextureCoord.empty() )
if ( !pModel->m_TextureCoord.empty() && pObjMesh->m_uiUVCoordinates[0] )
{
for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ )
{
const unsigned int num_uv = pObjMesh->m_uiUVCoordinates[ i ];
if ( num_uv > 0 )
{
pMesh->mNumUVComponents[ i ] = num_uv;
pMesh->mTextureCoords[ i ] = new aiVector3D[ num_uv ];
}
}
// FIXME (@Kimmi): cleanup, I don't see the intention behind this
// for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ )
// {
// const unsigned int num_uv = pObjMesh->m_uiUVCoordinates[ i ];
// if ( num_uv > 0 )
// {
pMesh->mNumUVComponents[ 0 ] = 2;
pMesh->mTextureCoords[ 0 ] = new aiVector3D[ pMesh->mNumVertices ];
// }
// }
}
// Copy vertices, normals and textures into aiMesh instance

View File

@ -0,0 +1,99 @@
# Max2Mtl Version 4.0 Mar 10th, 2001
#
newmtl Base
Ka 0.2 0.2 0.2
Kd 0.2 0.2 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Door
Ka 0.8 0.6 0.4
Kd 0.8 0.6 0.4
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Floor
Ka 0.9 0.9 0.7
Kd 0.9 0.9 0.7
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Rafter
Ka 0.8 0.5 0.2
Kd 0.8 0.5 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Ridging
Ka 0.4 0.3 0.3
Kd 0.4 0.3 0.3
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Sill
Ka 0.2 0.2 0.2
Kd 0.2 0.2 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Site
Ka 0.5 0.7 0.4
Kd 0.5 0.7 0.4
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Roof
Ka 0.9 0.9 0.6
Kd 0.9 0.9 0.6
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Terraindæk
Ka 0.4 0.3 0.3
Kd 0.4 0.3 0.3
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Wall-inner
Ka 0.8 0.7 0.5
Kd 0.8 0.7 0.5
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Wall-out
Ka 0.5 0.0 0.0
Kd 0.5 0.0 0.0
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Windows
Ka 0.6 0.7 0.8
Kd 0.6 0.7 0.8
Ks 0.9 0.9 0.9
d 0.5
Ns 0.0
illum 2
#
# EOF

File diff suppressed because it is too large Load Diff