stl mesh writer can now write 32 bit meshbuffers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6347 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-04-20 18:31:03 +00:00
parent 28e092673f
commit 3f2f98d7bd

@ -92,11 +92,14 @@ bool CSTLMeshWriter::writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s
{
const u32 indexCount = buffer->getIndexCount();
const u16 attributes = 0;
if( buffer->getIndexType() == video::EIT_16BIT )
{
const u16* indices = buffer->getIndices();
for (u32 j=0; j<indexCount; j+=3)
{
const core::vector3df& v1 = buffer->getPosition(buffer->getIndices()[j]);
const core::vector3df& v2 = buffer->getPosition(buffer->getIndices()[j+1]);
const core::vector3df& v3 = buffer->getPosition(buffer->getIndices()[j+2]);
const core::vector3df& v1 = buffer->getPosition(indices[j]);
const core::vector3df& v2 = buffer->getPosition(indices[j+1]);
const core::vector3df& v3 = buffer->getPosition(indices[j+2]);
const core::plane3df tmpplane(v1,v2,v3);
file->write(&tmpplane.Normal, 12);
file->write(&v1, 12);
@ -105,6 +108,23 @@ bool CSTLMeshWriter::writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s
file->write(&attributes, 2);
}
}
else if( buffer->getIndexType() == video::EIT_32BIT )
{
const u32* indices = (const u32*)buffer->getIndices();
for (u32 j=0; j<indexCount; j+=3)
{
const core::vector3df& v1 = buffer->getPosition(indices[j]);
const core::vector3df& v2 = buffer->getPosition(indices[j+1]);
const core::vector3df& v3 = buffer->getPosition(indices[j+2]);
const core::plane3df tmpplane(v1,v2,v3);
file->write(&tmpplane.Normal, 12);
file->write(&v1, 12);
file->write(&v2, 12);
file->write(&v3, 12);
file->write(&attributes, 2);
}
}
}
}
return true;
}
@ -127,12 +147,27 @@ bool CSTLMeshWriter::writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s3
if (buffer)
{
const u32 indexCount = buffer->getIndexCount();
if ( buffer->getIndexType() == video::EIT_16BIT )
{
const u16* indices = buffer->getIndices();
for (u32 j=0; j<indexCount; j+=3)
{
writeFace(file,
buffer->getPosition(buffer->getIndices()[j]),
buffer->getPosition(buffer->getIndices()[j+1]),
buffer->getPosition(buffer->getIndices()[j+2]));
buffer->getPosition(indices[j]),
buffer->getPosition(indices[j+1]),
buffer->getPosition(indices[j+2]));
}
}
else if ( buffer->getIndexType() == video::EIT_32BIT )
{
const u32* indices = (const u32*)buffer->getIndices();
for (u32 j=0; j<indexCount; j+=3)
{
writeFace(file,
buffer->getPosition(indices[j]),
buffer->getPosition(indices[j+1]),
buffer->getPosition(indices[j+2]));
}
}
file->write("\n",1);
}