Update to 3ds loader

A forum to store posts deemed exceptionally wise and useful
Post Reply
JoeWright
Posts: 74
Joined: Mon Dec 08, 2003 3:51 pm

Update to 3ds loader

Post by JoeWright »

Here's a suggested update to the 3ds loader that gets the colour information. Changes are in bold.

You have to manually set the ambient value (e.g. to black) because the default ambient value makes the object completely white. The 3ds loader doesn't currently bring in the ambient values.

We need normals to be read in for those nice curved surfaces.

Joe


bool C3DSMeshFileLoader::readColorChunk(io::IReadFile* file, ChunkData* chunk,
video::SColor& out)
{
ChunkData data;
readChunkData(file, data);

u8 c[3];

if (sizeof(c) != data.header.length - data.read)
{
os::Printer::log("Unknown size of color chunk in 3Ds file.", ELL_WARNING);
file->seek(data.header.length - data.read, true);
data.read += data.header.length - data.read;
}
else
{
file->read(c, data.header.length - data.read);
out.set(255, c[0], c[1], c[2]);
data.read += data.header.length - data.read;
}

chunk->read += data.read;

return true;
}
Post Reply