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
This commit is contained in:
cutealien 2022-04-20 17:56:40 +00:00
parent 8cd7e46506
commit 28e092673f
2 changed files with 29 additions and 11 deletions

@ -859,7 +859,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()
while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats 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; core::stringc name;
readString(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 (i=num_textures; i>0; --i)
{ {
for (u32 j=i-1; j<num_textures-1; ++j) for (u32 j=i-1; j<num_textures-1; ++j)

@ -255,18 +255,36 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag
file->write(&i, 4); file->write(&i, 4);
u32 numIndices = mb->getIndexCount(); u32 numIndices = mb->getIndexCount();
const u16 * const idx = (u16 *) mb->getIndices(); if ( mb->getIndexType() == video::EIT_16BIT )
for (u32 j = 0; j < numIndices; j += 3)
{ {
u32 tmp = idx[j] + currentMeshBufferIndex; const u16 * const idx = mb->getIndices();
file->write(&tmp, sizeof(u32)); for (u32 j = 0; j < numIndices; j += 3)
{
u32 tmp = idx[j] + currentMeshBufferIndex;
file->write(&tmp, sizeof(u32));
tmp = idx[j + 1] + currentMeshBufferIndex; tmp = idx[j + 1] + currentMeshBufferIndex;
file->write(&tmp, sizeof(u32)); file->write(&tmp, sizeof(u32));
tmp = idx[j + 2] + currentMeshBufferIndex; tmp = idx[j + 2] + currentMeshBufferIndex;
file->write(&tmp, sizeof(u32)); 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 writeSizeFrom(file, trisSizeAdress+4, trisSizeAdress); // TRIS chunk size
currentMeshBufferIndex += mb->getVertexCount(); currentMeshBufferIndex += mb->getVertexCount();