- fbx: read texture -> material connections.

pull/14/head
Alexander Gessler 2012-07-03 19:42:14 +02:00
parent effcaf066a
commit a0c45f9190
2 changed files with 28 additions and 2 deletions

View File

@ -184,7 +184,7 @@ private:
};
typedef std::fbx_unordered_map<std::string,Texture*> TextureMap;
typedef std::fbx_unordered_map<std::string, const Texture*> TextureMap;
/** DOM class for generic FBX materials */

View File

@ -94,7 +94,33 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
props = GetPropertyTable(doc,templateName,element,sc);
// resolve texture links
doc.GetConnectionsByDestinationSequenced(ID());
const std::vector<const Connection*> conns = doc.GetConnectionsByDestinationSequenced(ID());
BOOST_FOREACH(const Connection* con, conns) {
// texture link to properties, not objects
if (!con->PropertyName().length()) {
continue;
}
const Object* const ob = con->SourceObject();
if(!ob) {
DOMWarning("failed to read source object for texture link, ignoring",&element);
continue;
}
const Texture* const tex = dynamic_cast<const Texture*>(ob);
if(!tex) {
DOMWarning("source object for texture link is not a texture, ignoring",&element);
continue;
}
const std::string& prop = con->PropertyName();
if (textures.find(prop) != textures.end()) {
DOMWarning("duplicate texture link: " + prop,&element);
}
textures[prop] = tex;
}
}