Changed base of material indices in models from one to zero for consistency with everything else.

ver1_5_1
Chris Laurel 2004-02-18 08:17:23 +00:00
parent 286d0cc517
commit e539502cfb
4 changed files with 11 additions and 10 deletions

View File

@ -376,10 +376,9 @@ void Mesh::render(const std::vector<const Material*>& materials,
const Material* mat = NULL;
uint32 materialIndex = (*iter)->materialIndex;
if (materialIndex != lastMaterial &&
materialIndex > 0 &&
materialIndex <= materials.size())
materialIndex < materials.size())
{
mat = materials[materialIndex - 1];
mat = materials[materialIndex];
}
rc.setMaterial(mat);

View File

@ -456,7 +456,7 @@ static Model*
Convert3DSModel(const M3DScene& scene, const string& texPath)
{
Model* model = new Model();
uint32 materialIndex = 1;
uint32 materialIndex = 0;
for (unsigned int i = 0; i < scene.getModelCount(); i++)
{

View File

@ -110,8 +110,6 @@ Model* LoadModel(istream& in, const string& texPath)
delete loader;
cout << "Model loaded\n"; cout.flush();
return model;
}
@ -483,7 +481,12 @@ AsciiModelLoader::loadMesh()
delete mesh;
return NULL;
}
uint32 materialIndex = (uint32) tok.getNumberValue();
uint32 materialIndex;
if (tok.getNumberValue() == -1.0)
materialIndex = ~0;
else
materialIndex = (uint32) tok.getNumberValue();
if (tok.nextToken() != Tokenizer::TokenNumber)
{
@ -491,6 +494,7 @@ AsciiModelLoader::loadMesh()
delete mesh;
return NULL;
}
uint32 indexCount = (uint32) tok.getNumberValue();
uint32* indices = new uint32[indexCount];
@ -556,8 +560,6 @@ AsciiModelLoader::load()
string name = tok.getNameValue();
tok.pushBack();
cout << "token " << name << '\n';
if (name == "material")
{
if (seenMeshes)

View File

@ -384,7 +384,7 @@ Mesh* SphereMesh::convertToMesh() const
indexData[j * 2 + 1] = (i + 1) * (nSlices + 1) + j;
}
mesh->addGroup(Mesh::TriStrip, 0, (nSlices + 1) * 2, indexData);
mesh->addGroup(Mesh::TriStrip, ~0, (nSlices + 1) * 2, indexData);
}
return mesh;