mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 09:33:52 +02:00
Merge pull request #1014 from ey6es/master
Fix for relative texture paths.
This commit is contained in:
commit
c2e3682f6e
2 changed files with 17 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue