Fixed some minor bugs in the Q3D loader. All test models from quick3d.org load correctly now.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@215 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
daae32d62f
commit
5d2fd0ef35
|
@ -103,7 +103,8 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
|
||||||
std::string(&((const char*)stream.GetPtr())[8],2));
|
std::string(&((const char*)stream.GetPtr())[8],2));
|
||||||
|
|
||||||
// ... an store it
|
// ... an store it
|
||||||
unsigned int ff = strtol10(&((const char*)stream.GetPtr())[8]);
|
char major = ((const char*)stream.GetPtr())[8];
|
||||||
|
char minor = ((const char*)stream.GetPtr())[9];
|
||||||
|
|
||||||
stream.IncPtr(10);
|
stream.IncPtr(10);
|
||||||
unsigned int numMeshes = (unsigned int)stream.GetI4();
|
unsigned int numMeshes = (unsigned int)stream.GetI4();
|
||||||
|
@ -212,19 +213,21 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
|
||||||
Face& vec = faces[i];
|
Face& vec = faces[i];
|
||||||
for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
|
for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
|
||||||
{
|
{
|
||||||
vec.indices[a] = stream.GetI4();
|
vec.uvindices[a] = stream.GetI4();
|
||||||
if (!i && !a)
|
if (!i && !a)
|
||||||
mesh.prevUVIdx = vec.indices[a];
|
mesh.prevUVIdx = vec.uvindices[a];
|
||||||
else if (vec.indices[a] != mesh.prevUVIdx)
|
else if (vec.uvindices[a] != mesh.prevUVIdx)
|
||||||
mesh.prevUVIdx = 0xffffffff;
|
mesh.prevUVIdx = 0xffffffff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't need the rest, but we need to get to the next chunk
|
// we don't need the rest, but we need to get to the next chunk
|
||||||
stream.IncPtr(36 + ((ff > 30 ? 12 : 0 )));
|
stream.IncPtr(36);
|
||||||
|
if (minor > '0' && major == '3')
|
||||||
|
stream.IncPtr(mesh.faces.size());
|
||||||
}
|
}
|
||||||
stream.IncPtr(4 + (ff > 30 ? 24 : 0 )); // unknown value here
|
// stream.IncPtr(4); // unknown value here
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -262,7 +265,9 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
|
||||||
mat.transparency = stream.GetF4();
|
mat.transparency = stream.GetF4();
|
||||||
|
|
||||||
// unknown value here
|
// unknown value here
|
||||||
stream.IncPtr(4);
|
// stream.IncPtr(4);
|
||||||
|
// FIX: it could be the texture index ...
|
||||||
|
mat.texIdx = (unsigned int)stream.GetI4();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -431,7 +436,8 @@ outer:
|
||||||
mat->AddProperty(&srcMat.specular, 1,AI_MATKEY_COLOR_SPECULAR);
|
mat->AddProperty(&srcMat.specular, 1,AI_MATKEY_COLOR_SPECULAR);
|
||||||
mat->AddProperty(&srcMat.ambient, 1,AI_MATKEY_COLOR_AMBIENT);
|
mat->AddProperty(&srcMat.ambient, 1,AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
|
||||||
//srcMat.transparency = 1.0f - srcMat.transparency;
|
//if (!(minor > '0' && major == '3'))
|
||||||
|
// srcMat.transparency = 1.0f - srcMat.transparency;
|
||||||
mat->AddProperty(&srcMat.transparency, 1, AI_MATKEY_OPACITY);
|
mat->AddProperty(&srcMat.transparency, 1, AI_MATKEY_OPACITY);
|
||||||
|
|
||||||
// add shininess - Quick3D seems to use it ins its viewer
|
// add shininess - Quick3D seems to use it ins its viewer
|
||||||
|
@ -445,10 +451,11 @@ outer:
|
||||||
mat->AddProperty(&srcMat.name,AI_MATKEY_NAME);
|
mat->AddProperty(&srcMat.name,AI_MATKEY_NAME);
|
||||||
|
|
||||||
// Add a texture
|
// Add a texture
|
||||||
if (real < pScene->mNumTextures)
|
if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures)
|
||||||
{
|
{
|
||||||
srcMat.name.data[0] = '*';
|
srcMat.name.data[0] = '*';
|
||||||
srcMat.name.length = itoa10(&srcMat.name.data[1],1000,real);
|
srcMat.name.length = itoa10(&srcMat.name.data[1],1000,
|
||||||
|
(srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real));
|
||||||
mat->AddProperty(&srcMat.name,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
mat->AddProperty(&srcMat.name,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +526,7 @@ outer:
|
||||||
{
|
{
|
||||||
if (m.prevUVIdx != 0xffffffff && m.uv.size() >= m.verts.size()) // workaround
|
if (m.prevUVIdx != 0xffffffff && m.uv.size() >= m.verts.size()) // workaround
|
||||||
{
|
{
|
||||||
*uv++ = m.uv[face.indices[n]];
|
*uv = m.uv[face.indices[n]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -528,8 +535,10 @@ outer:
|
||||||
DefaultLogger::get()->warn("Quick3D: Texture coordinate index overflow");
|
DefaultLogger::get()->warn("Quick3D: Texture coordinate index overflow");
|
||||||
face.uvindices[n] = 0;
|
face.uvindices[n] = 0;
|
||||||
}
|
}
|
||||||
*uv++ = m.uv[face.uvindices[n]];
|
*uv = m.uv[face.uvindices[n]];
|
||||||
}
|
}
|
||||||
|
uv->y = 1.f - uv->y;
|
||||||
|
++uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup the new vertex index
|
// setup the new vertex index
|
||||||
|
|
|
@ -94,11 +94,14 @@ private:
|
||||||
Material()
|
Material()
|
||||||
: diffuse (0.6f,0.6f,0.6f)
|
: diffuse (0.6f,0.6f,0.6f)
|
||||||
, transparency (0.f)
|
, transparency (0.f)
|
||||||
|
, texIdx (0xffffffff)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
aiString name;
|
aiString name;
|
||||||
aiColor3D ambient, diffuse, specular;
|
aiColor3D ambient, diffuse, specular;
|
||||||
float transparency;
|
float transparency;
|
||||||
|
|
||||||
|
unsigned int texIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Face
|
struct Face
|
||||||
|
|
Loading…
Reference in New Issue