Fix relative indices in obj files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@826 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-08-08 13:19:28 +00:00
parent 00cab3e6ec
commit 21efe402ba
2 changed files with 4 additions and 4 deletions

View File

@ -201,7 +201,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
// read in next vertex's data
u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd);
// this function will also convert obj's 1-based index to c++'s 0-based index
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1);
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size());
if ( -1 != Idx[0] )
{
v.Pos = vertexBuffer[Idx[0]];
@ -720,7 +720,7 @@ const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32
}
bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd)
bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd, u32 bufferSize)
{
c8 word[16] = "";
const c8* pChar = goFirstWord(pVertexData, pBufEnd);
@ -742,7 +742,7 @@ bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const
// if no number was found index will become 0 and later on -1 by decrement
index = atoi( word );
if (index<0)
index += pIdx[idxType];
index += bufferSize;
else
--index;
pIdx[idxType] = index;

View File

@ -96,7 +96,7 @@ private:
// reads and convert to integer the vertex indices in a line of obj file's face statement
// -1 for the index if it doesn't exist
// indices are changed to 0-based index instead of 1-based from the obj file
bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd);
bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd, u32 bufferSize);
void cleanUp();