summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/runtime/q3dscustommaterial.cpp14
-rw-r--r--src/runtime/q3dscustommaterial_p.h3
-rw-r--r--src/runtime/q3dsuippresentation.cpp13
-rw-r--r--src/runtime/q3dsuippresentation_p.h1
4 files changed, 31 insertions, 0 deletions
diff --git a/src/runtime/q3dscustommaterial.cpp b/src/runtime/q3dscustommaterial.cpp
index 77b8cb3..592c19f 100644
--- a/src/runtime/q3dscustommaterial.cpp
+++ b/src/runtime/q3dscustommaterial.cpp
@@ -176,7 +176,21 @@ Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(const QString &filename, bool
*ok = false;
return Q3DSCustomMaterial();
}
+ return parse(ok);
+}
+Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(const QByteArray &data, bool *ok)
+{
+ if (!setSourceData(data)) {
+ if (ok != nullptr)
+ *ok = false;
+ return Q3DSCustomMaterial();
+ }
+ return parse(ok);
+}
+
+Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(bool *ok)
+{
m_material = Q3DSCustomMaterial();
QXmlStreamReader *r = reader();
diff --git a/src/runtime/q3dscustommaterial_p.h b/src/runtime/q3dscustommaterial_p.h
index 8c3cfbb..11eca98 100644
--- a/src/runtime/q3dscustommaterial_p.h
+++ b/src/runtime/q3dscustommaterial_p.h
@@ -138,8 +138,11 @@ class Q3DSV_PRIVATE_EXPORT Q3DSCustomMaterialParser : public Q3DSAbstractXmlPars
{
public:
Q3DSCustomMaterial parse(const QString &filename, bool *ok = nullptr);
+ Q3DSCustomMaterial parse(const QByteArray &data, bool *ok = nullptr);
private:
+ Q3DSCustomMaterial parse(bool *ok = nullptr);
+
void parseMaterial();
void parseMetaData();
void parseShaders();
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp
index bafb313..260f4c4 100644
--- a/src/runtime/q3dsuippresentation.cpp
+++ b/src/runtime/q3dsuippresentation.cpp
@@ -4279,6 +4279,19 @@ Q3DSCustomMaterial Q3DSUipPresentation::customMaterial(const QString &idOrFilena
return d->customMaterials.value(key);
}
+Q3DSCustomMaterial Q3DSUipPresentation::customMaterial(const QByteArray &id, const QByteArray &data)
+{
+ Q3DSCustomMaterialParser p;
+ bool ok = false;
+ Q3DSCustomMaterial mat = p.parse(data, &ok);
+ if (!ok) {
+ qWarning("Failed to parse metadata %s", id.constData());
+ return Q3DSCustomMaterial();
+ }
+ d->customMaterials.insert(id, mat);
+ return mat;
+}
+
bool Q3DSUipPresentation::loadEffect(const QByteArray &id, const QString &assetFilename)
{
return loadMeta<Q3DSEffect, Q3DSEffectParser>(id, assetFilename, &d->effects);
diff --git a/src/runtime/q3dsuippresentation_p.h b/src/runtime/q3dsuippresentation_p.h
index 2e89a22..064456b 100644
--- a/src/runtime/q3dsuippresentation_p.h
+++ b/src/runtime/q3dsuippresentation_p.h
@@ -2120,6 +2120,7 @@ public:
void registerImageBuffer(const QString &sourcePath, bool hasTransparency);
Q3DSCustomMaterial customMaterial(const QString &idOrFilename);
+ Q3DSCustomMaterial customMaterial(const QByteArray &id, const QByteArray &data);
Q3DSEffect effect(const QString &idOrFilename);
Q3DSBehavior behavior(const QString &idOrFilename);
MeshList mesh(const QString &assetFilename, int part = 1);