mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 21:18:54 +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;
|
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) {
|
FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) {
|
||||||
QHash<qint64, FBXMesh> meshes;
|
QHash<qint64, FBXMesh> meshes;
|
||||||
QVector<ExtractedBlendshape> blendshapes;
|
QVector<ExtractedBlendshape> blendshapes;
|
||||||
|
@ -560,8 +572,10 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
} else if (object.name == "Texture") {
|
} else if (object.name == "Texture") {
|
||||||
foreach (const FBXNode& subobject, object.children) {
|
foreach (const FBXNode& subobject, object.children) {
|
||||||
if (subobject.name == "RelativeFilename") {
|
if (subobject.name == "RelativeFilename") {
|
||||||
textureFilenames.insert(object.properties.at(0).value<qint64>(),
|
// trim off any path information
|
||||||
subobject.properties.at(0).toByteArray());
|
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") {
|
} else if (object.name == "Deformer") {
|
||||||
|
@ -678,18 +692,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
return geometry;
|
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) {
|
FBXGeometry readFBX(const QByteArray& model, const QByteArray& mapping) {
|
||||||
QBuffer modelBuffer(const_cast<QByteArray*>(&model));
|
QBuffer modelBuffer(const_cast<QByteArray*>(&model));
|
||||||
modelBuffer.open(QIODevice::ReadOnly);
|
modelBuffer.open(QIODevice::ReadOnly);
|
||||||
|
|
|
@ -363,10 +363,7 @@ void NetworkGeometry::maybeReadModelWithMapping() {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
QString basePath = url.path();
|
QString basePath = url.path();
|
||||||
int idx = basePath.lastIndexOf('/');
|
basePath = basePath.left(basePath.lastIndexOf('/') + 1);
|
||||||
if (idx != -1) {
|
|
||||||
basePath = basePath.left(idx);
|
|
||||||
}
|
|
||||||
if (!mesh.diffuseFilename.isEmpty()) {
|
if (!mesh.diffuseFilename.isEmpty()) {
|
||||||
url.setPath(basePath + mesh.diffuseFilename);
|
url.setPath(basePath + mesh.diffuseFilename);
|
||||||
networkMesh.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, mesh.isEye);
|
networkMesh.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, mesh.isEye);
|
||||||
|
|
Loading…
Reference in a new issue