add resolvePath() to find files rel to .obj path
This commit is contained in:
parent
1918cc89bf
commit
08e558482f
9
WFObj.cc
9
WFObj.cc
@ -341,7 +341,7 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref)
|
||||
void WFObj::loadMaterial(const std::string & name)
|
||||
{
|
||||
Buffer buff;
|
||||
string path = (name[0] != '/') ? basePath(m_path) + name : name;
|
||||
string path = resolvePath(name);
|
||||
if (!m_loadfile(path.c_str(), buff))
|
||||
{
|
||||
cerr << "WFObj: error: couldn't open material file '" << path << "'"
|
||||
@ -422,7 +422,7 @@ void WFObj::loadMaterial(const std::string & name)
|
||||
}
|
||||
else if (tokens[0] == "map_Kd")
|
||||
{
|
||||
m_materials[mat_name].texture = loadTexture(tokens[1]);
|
||||
m_materials[mat_name].texture = loadTexture(resolvePath(tokens[1]));
|
||||
if (m_materials[mat_name].texture != 0)
|
||||
m_materials[mat_name].flags |= Material::TEXTURE_BIT;
|
||||
}
|
||||
@ -571,6 +571,11 @@ GLuint WFObj::loadTexture(const std::string & path)
|
||||
return id;
|
||||
}
|
||||
|
||||
string WFObj::resolvePath(const string & name)
|
||||
{
|
||||
return (name[0] != '/') ? basePath(m_path) + name : name;
|
||||
}
|
||||
|
||||
bool WFObj::VertexRef::operator<(const VertexRef & other) const
|
||||
{
|
||||
if (vertex != other.vertex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user