From 28e092673fb7d9dd913e17f65a672eaccf6c6d8a Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 20 Apr 2022 17:56:40 +0000 Subject: [PATCH] b3d writer can now write 32-bit meshbuffers. Still can't read it though - reader needs SSkinMeshBuffer which only supports 16 bit so far (changes in loader are just spelling fixes in comments) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6346 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CB3DMeshFileLoader.cpp | 4 +-- source/Irrlicht/CB3DMeshWriter.cpp | 36 +++++++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/source/Irrlicht/CB3DMeshFileLoader.cpp b/source/Irrlicht/CB3DMeshFileLoader.cpp index c473d52..2f18257 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();