Fix for relative texture paths.

This commit is contained in:
Andrzej Kapolka 2013-10-03 15:47:43 -07:00
parent a140f4e309
commit 2fc1af8c1a
2 changed files with 17 additions and 18 deletions

View file

@ -334,6 +334,18 @@ public:
FBXBlendshape blendshape;
};
void printNode(const FBXNode& node, int indent) {
QByteArray spaces(indent, ' ');
qDebug("%s%s: ", spaces.data(), node.name.data());
foreach (const QVariant& property, node.properties) {
qDebug() << property;
}
qDebug() << "\n";
foreach (const FBXNode& child, node.children) {
printNode(child, indent + 1);
}
}
FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) {
QHash<qint64, FBXMesh> meshes;
QVector<ExtractedBlendshape> blendshapes;
@ -560,8 +572,10 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
} else if (object.name == "Texture") {
foreach (const FBXNode& subobject, object.children) {
if (subobject.name == "RelativeFilename") {
textureFilenames.insert(object.properties.at(0).value<qint64>(),
subobject.properties.at(0).toByteArray());
// trim off any path information
QByteArray filename = subobject.properties.at(0).toByteArray();
filename = filename.mid(qMax(filename.lastIndexOf('\\'), filename.lastIndexOf('/')) + 1);
textureFilenames.insert(object.properties.at(0).value<qint64>(), filename);
}
}
} else if (object.name == "Deformer") {
@ -678,18 +692,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
return geometry;
}
void printNode(const FBXNode& node, int indent) {
QByteArray spaces(indent, ' ');
qDebug("%s%s: ", spaces.data(), node.name.data());
foreach (const QVariant& property, node.properties) {
qDebug() << property;
}
qDebug() << "\n";
foreach (const FBXNode& child, node.children) {
printNode(child, indent + 1);
}
}
FBXGeometry readFBX(const QByteArray& model, const QByteArray& mapping) {
QBuffer modelBuffer(const_cast<QByteArray*>(&model));
modelBuffer.open(QIODevice::ReadOnly);

View file

@ -363,10 +363,7 @@ void NetworkGeometry::maybeReadModelWithMapping() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
QString basePath = url.path();
int idx = basePath.lastIndexOf('/');
if (idx != -1) {
basePath = basePath.left(idx);
}
basePath = basePath.left(basePath.lastIndexOf('/') + 1);
if (!mesh.diffuseFilename.isEmpty()) {
url.setPath(basePath + mesh.diffuseFilename);
networkMesh.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, mesh.isEye);