#15 OBJ: support relative indeces

open
nobody
None
5
2014-08-24
2012-09-14
Anonymous
No

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:
else
{
//OBJ USES 1 Base ARRAYS!!!!
const int iVal = atoi( pPtr );
int tmp = iVal;
while ( ( tmp = tmp / 10 )!=0 )
++iStep;

// 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;
}
else
{
reportErrorTokenInFace();
}
}

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.

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-09-14
     
    Last edit: Anonymous 2015-12-27
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-09-23

    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.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-10-08

    Files that load "successfully" have wrong coordinates.

     
    Last edit: Anonymous 2015-12-26
  • Nobody/Anonymous

    t22Z5m <a href="http://iuoiqbhooniz.com/">iuoiqbhooniz</a>, [url=http://elmcggyybtjf.com/]elmcggyybtjf[/url], [link=http://uukrnfnaoqvn.com/]uukrnfnaoqvn[/link], http://cycpzeeqbmrv.com/

     
  • Nobody/Anonymous

    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>

     
  • Nobody/Anonymous

    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>

     
  • Nobody/Anonymous

    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>

     
  • Nobody/Anonymous

    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>

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks