diff --git a/source/Irrlicht/CB3DMeshFileLoader.cpp b/source/Irrlicht/CB3DMeshFileLoader.cpp index c473d529..2f18257d 100644 --- a/source/Irrlicht/CB3DMeshFileLoader.cpp +++ b/source/Irrlicht/CB3DMeshFileLoader.cpp @@ -859,7 +859,7 @@ bool CB3DMeshFileLoader::readChunkBRUS() while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats { - // This is what blitz basic calls a brush, like a Irrlicht Material + // This is what blitz basic calls a brush, like an Irrlicht material core::stringc name; readString(name); @@ -933,7 +933,7 @@ bool CB3DMeshFileLoader::readChunkBRUS() } } - //If a preceeding texture slot is empty move the others down: + //If a preceding texture slot is empty move the others down: for (i=num_textures; i>0; --i) { for (u32 j=i-1; jwrite(&i, 4); u32 numIndices = mb->getIndexCount(); - const u16 * const idx = (u16 *) mb->getIndices(); - for (u32 j = 0; j < numIndices; j += 3) + if ( mb->getIndexType() == video::EIT_16BIT ) { - u32 tmp = idx[j] + currentMeshBufferIndex; - file->write(&tmp, sizeof(u32)); + const u16 * const idx = mb->getIndices(); + for (u32 j = 0; j < numIndices; j += 3) + { + u32 tmp = idx[j] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); - tmp = idx[j + 1] + currentMeshBufferIndex; - file->write(&tmp, sizeof(u32)); + tmp = idx[j + 1] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); - tmp = idx[j + 2] + currentMeshBufferIndex; - file->write(&tmp, sizeof(u32)); - } + tmp = idx[j + 2] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); + } + } + else if ( mb->getIndexType() == video::EIT_32BIT ) + { + const u32 * const idx = (const u32*) mb->getIndices(); + for (u32 j = 0; j < numIndices; j += 3) + { + u32 tmp = idx[j] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); + + tmp = idx[j + 1] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); + + tmp = idx[j + 2] + currentMeshBufferIndex; + file->write(&tmp, sizeof(u32)); + } + } writeSizeFrom(file, trisSizeAdress+4, trisSizeAdress); // TRIS chunk size currentMeshBufferIndex += mb->getVertexCount();