From 8447d3f5315b506d078b82410bb93c0708b7c9ac Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 14 Apr 2022 14:39:31 +0000 Subject: [PATCH] obj writer can now write 32 bit buffers git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6334 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 3 ++- source/Irrlicht/COBJMeshWriter.cpp | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/changes.txt b/changes.txt index 1aa4b1d..67985d8 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) -- obj meshloader can now load 32-bit buffers when setPreferredIndexType is set to EIT_32BIT. +- obj writer can now write 32 bit buffers +- obj meshloader can now load 32 bit buffers when setPreferredIndexType is set to EIT_32BIT. It's 16 bit meshes use now also an IDynamicMeshbuffer instead of an SMeshBuffer. - Add IMeshLoader::setPreferredIndexType and getPreferredIndexType to allow setting hints for the loaders if users prefer 16 or 32 bit meshbuffers. - Add IMeshBuffer::getType to allow finding out which class type a meshbuffer has (similar to ISceneNode::getType). diff --git a/source/Irrlicht/COBJMeshWriter.cpp b/source/Irrlicht/COBJMeshWriter.cpp index 372b9c2..7f5bfab 100644 --- a/source/Irrlicht/COBJMeshWriter.cpp +++ b/source/Irrlicht/COBJMeshWriter.cpp @@ -130,8 +130,23 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla const u32 indexCount = buffer->getIndexCount(); for (j=0; jgetIndexType()) + { + case video::EIT_16BIT: + idx2 = buffer->getIndices()[j+2]+allVertexCount; + idx1 = buffer->getIndices()[j+1]+allVertexCount; + idx0 = buffer->getIndices()[j+0]+allVertexCount; + break; + case video::EIT_32BIT: + idx2 = ((u32*)buffer->getIndices())[j+2]+allVertexCount; + idx1 = ((u32*)buffer->getIndices())[j+1]+allVertexCount; + idx0 = ((u32*)buffer->getIndices())[j+0]+allVertexCount; + break; + } + file->write("f ",2); - num = core::stringc(buffer->getIndices()[j+2]+allVertexCount); + num = core::stringc(idx2); file->write(num.c_str(), num.size()); file->write("/",1); file->write(num.c_str(), num.size()); @@ -139,7 +154,7 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla file->write(num.c_str(), num.size()); file->write(" ",1); - num = core::stringc(buffer->getIndices()[j+1]+allVertexCount); + num = core::stringc(idx1); file->write(num.c_str(), num.size()); file->write("/",1); file->write(num.c_str(), num.size()); @@ -147,7 +162,7 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla file->write(num.c_str(), num.size()); file->write(" ",1); - num = core::stringc(buffer->getIndices()[j+0]+allVertexCount); + num = core::stringc(idx0); file->write(num.c_str(), num.size()); file->write("/",1); file->write(num.c_str(), num.size());