Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#15 OBJ: support relative indeces


The current implementation doesn't support relative indices and generates a "invalid vector<t> subscript" error when loading a mesh with a -10 index(or possible others, I haven't tried).

Changing the else clause at code/ObjFileParser.cpp(307) to the following seems to fix it, but I can't get my hands on any solid test data:
//OBJ USES 1 Base ARRAYS!!!!
const int iVal = atoi( pPtr );
int tmp = iVal;
while ( ( tmp = tmp / 10 )!=0 )

// fix for negative values
if( iVal < 0 ) ++iStep;

if ( iVal != 0 )
// Store parsed index
if ( 0 == iPos )
const int index = iVal < 0 ? m_pModel->m_Vertices.size() + iVal : iVal-1;
pIndices->push_back( index );
else if ( 1 == iPos )
const int index = iVal < 0 ? m_pModel->m_TextureCoord.size() + iVal : iVal-1;
pTexID->push_back( index );
else if ( 2 == iPos )
const int index = iVal < 0 ? m_pModel->m_Normals.size() + iVal : iVal-1;
pNormalID->push_back( index );
hasNormal = true;

Attached is the handgun obj from http://www.turbosquid.com/3d-models/newhere-s-weapon-obj-free/556764 that has negative/relative indices, but this model seems to have invalid vertex data as well.


  • Anonymous

    the vertex data of the attached model is fine, assimp viwer has problem displaying it since it's really small, scaling the model before or after fixes this issue.


  • Anonymous

    Files that load "successfully" have wrong coordinates.

    Last edit: Anonymous 2015-04-10
  • t22Z5m <a href="http://iuoiqbhooniz.com/">iuoiqbhooniz</a>, [url=http://elmcggyybtjf.com/]elmcggyybtjf[/url], [link=http://uukrnfnaoqvn.com/]uukrnfnaoqvn[/link], http://cycpzeeqbmrv.com/

  • The outfits come in a variety of different ginghams and they are named according to the gingham itself, for example there is pale pink which is the fairy tales and then there''s the bright pink which is the garden roses.. ergo baby carrier http://www.ergobabycarrier4u.com/ <a href="http://www.ergobabycarrier4u.com/" title="ergo baby carrier">ergo baby carrier</a>

  • The cover is a little boring, but the one I got from the library was a little beat up, so I felt it had a little more character to it because it was beat up. I add a normal cover for your entertainment. Candy. <a href="http://www.buildingsources.co.uk/morris-singer-art-founders/?commentstab=1" title="http://www.buildingsources.co.uk/morris-singer-art-founders/?commentstab=1">http://www.buildingsources.co.uk/morris-singer-art-founders/?commentstab=1</a>

  • SourceForge.net: Open Asset Import Library: Detail: 3567811 - OBJ: support relative indeces <a href="http://mexiaoyuan.cn/sc/forum.php?mod=viewthread&tid=5615969" title="http://mexiaoyuan.cn/sc/forum.php?mod=viewthread&tid=5615969">http://mexiaoyuan.cn/sc/forum.php?mod=viewthread&tid=5615969</a>

  • SourceForge.net: Open Asset Import Library: Detail: 3567811 - OBJ: support relative indeces <a href="http://blog.tweetsmarter.com/twitter-spam/how-bad-twitter-links-apps-can-trick-you/" title="http://blog.tweetsmarter.com/twitter-spam/how-bad-twitter-links-apps-can-trick-you/">http://blog.tweetsmarter.com/twitter-spam/how-bad-twitter-links-apps-can-trick-you/</a>