summaryrefslogtreecommitdiffstats
path: root/src/render/io/gltfparser.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-07-02 12:54:47 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-07-05 16:03:19 +0200
commit3c37d50d0e526959223b8c51dd75cde7a2527d9d (patch)
treebad3c01af4e28e27d660726b460a09650a4b2a31 /src/render/io/gltfparser.cpp
parenta20f272b2fe5179d95e397afc6aa3ed80afb7188 (diff)
Refactored QAbstractMesh, QMesh and QAbstractShapeMesh
The Backend now monitors QAbstractMesh elements instead of QMesh. QAbstractMesh subclasses have to implement a load method. For QMesh it uses the ObjLoader to create MeshData from a source file while QAbstractShapeMesh loads MeshData created by code. Each scene parser can then implement its own QAbstractMesh subclass. The loadmeshdatajobs has been corrected and works with QAbstractMesh. Change-Id: I5caae63a153f18eaae3b2f1bdbfa8995c63a2d23 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io/gltfparser.cpp')
-rw-r--r--src/render/io/gltfparser.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index b4a32addd..4db8928ea 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -339,7 +339,7 @@ Entity* GLTFParser::node(QString id)
if ( jsonObj.contains(KEY_MESHES) )
{
- typedef QList<QMesh*> MeshList;
+ typedef QList<GLTFParserMesh *> MeshList;
QMap<QString, MeshList> materialDict;
foreach (QJsonValue m, jsonObj.value(KEY_MESHES).toArray())
@@ -351,7 +351,7 @@ Entity* GLTFParser::node(QString id)
foreach (MeshDataPtr md, m_meshDict.values(m.toString())) {
QString matId = m_meshMaterialDict[md.data()];
- QMesh* meshComp = new QMesh;
+ GLTFParserMesh* meshComp = new GLTFParserMesh;
meshComp->setData(md);
materialDict[matId].append(meshComp);
}
@@ -360,7 +360,7 @@ Entity* GLTFParser::node(QString id)
if (materialDict.size() == 1) {
// common case
result->addComponent(material(materialDict.firstKey()));
- foreach (QMesh* m, materialDict.first())
+ foreach (GLTFParserMesh* m, materialDict.first())
result->addComponent(m);
} else {
// need to make a child entity per material
@@ -369,7 +369,7 @@ Entity* GLTFParser::node(QString id)
result->addChild(subEntity);
subEntity->addComponent(material(matId));
- foreach (QMesh* m, materialDict.value(matId))
+ foreach (GLTFParserMesh* m, materialDict.value(matId))
subEntity->addComponent(m);
} // of distinct material iteration
} // of multiple materials case
@@ -960,6 +960,21 @@ QVariant GLTFParser::parameterValueFromJSON(Parameter* p, QJsonValue val)
return QVariant();
}
+GLTFParser::GLTFParserMesh::GLTFParserMesh(Node *parent)
+ : QAbstractMesh(parent)
+{
+}
+
+bool GLTFParser::GLTFParserMesh::load()
+{
+ return true;
+}
+
+void GLTFParser::GLTFParserMesh::setData(MeshDataPtr data)
+{
+ QAbstractMesh::setData(data.staticCast<QAbstractMeshData>());
+}
+
} // of namespace Qt3D
QT_END_NAMESPACE