Commit 04ed098f authored by hybrid's avatar hybrid

Fix the relative addressing for all types.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@919 dfc29bdd-3216-0410-991c-e03cc46cb475
parent fb1d24d2
...@@ -204,7 +204,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -204,7 +204,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
// read in next vertex's data // read in next vertex's data
u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd); 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 // this function will also convert obj's 1-based index to c++'s 0-based index
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer); retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size());
v.Pos = vertexBuffer[Idx[0]]; v.Pos = vertexBuffer[Idx[0]];
if ( -1 != Idx[1] ) if ( -1 != Idx[1] )
v.TCoords = textureCoordBuffer[Idx[1]]; v.TCoords = textureCoordBuffer[Idx[1]];
...@@ -693,7 +693,7 @@ const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 ...@@ -693,7 +693,7 @@ const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32
} }
bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd, const core::array<core::vector3df>& vbuffer) bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd, u32 vbsize, u32 vtsize, u32 vnsize)
{ {
c8 word[16] = ""; c8 word[16] = "";
const c8* pChar = goFirstWord(pVertexData, pBufEnd); const c8* pChar = goFirstWord(pVertexData, pBufEnd);
...@@ -713,7 +713,21 @@ bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const ...@@ -713,7 +713,21 @@ bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const
word[i] = '\0'; word[i] = '\0';
// if no number was found index will become 0 and later on -1 by decrement // if no number was found index will become 0 and later on -1 by decrement
if (word[0]=='-') if (word[0]=='-')
pIdx[idxType] = vbuffer.size()-core::strtol10(word+1,0); {
pIdx[idxType] = -core::strtol10(word+1,0);
switch (idxType)
{
case 0:
pIdx[idxType] += vbsize;
break;
case 1:
pIdx[idxType] += vtsize;
break;
case 2:
pIdx[idxType] += vnsize;
break;
}
}
else else
pIdx[idxType] = core::strtol10(word,0)-1; pIdx[idxType] = core::strtol10(word,0)-1;
......
...@@ -86,7 +86,7 @@ private: ...@@ -86,7 +86,7 @@ private:
// reads and convert to integer the vertex indices in a line of obj file's face statement // 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 // -1 for the index if it doesn't exist
// indices are changed to 0-based index instead of 1-based from the obj file // indices are changed to 0-based index instead of 1-based from the obj file
bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd, const core::array<core::vector3df>& vbuffer); bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd, u32 vbsize, u32 vtsize, u32 vnsize);
void cleanUp(); void cleanUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment