summaryrefslogtreecommitdiffstats
path: root/src/render/io/gltfparser.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-05-06 12:40:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-24 20:45:00 +0200
commitaceb771ad6d24da854021a56a49b339bea029c98 (patch)
tree8de2c50fea46c610f686eae45937e753740ebd6d /src/render/io/gltfparser.cpp
parent92398ff86ba86813d2bd71469f05f660a9066fc3 (diff)
Abstract Entity, EntityNode and Quick3DEntity
Because Node no longer holds QQmlListProperties, Entity which inherited Node could'nt be used to have nested children in Qml because there was no longer a data DefaultProperty. To solve that issue Entity has become an abstract class encapsulating most what an Entity used to contain. EntityNode is a class bound to be used by the C++ API and it subclasses Node and Entity. Regarding the Qml API, Quick3DEntity subclasses Quick3DNode and Entity. RenderSceneBuilder and NodeVisitor have been slightly modified to work with those changes but the backend is pretty much the same. The big change is that Entity is no longer a QObject and no logner inherits Node. That means Node and Entity have to be used along side on the backend. On the frontend or other Aspects subclassing EntityNode or Quick3DEntity should be pretty much the same as subclassing Entity prior this change. Component classes have not been touched so they cannot contain nested QtQuick2 elements in QML. As Entity and Nodes can hold QtQuick2 Components this isn't a big issue. Also as the DefaultProperty of each Component subclasses may differ, keeping them as they are at the moment could make sense. Note: This patch restored rendering. The code is a bit messy at the moment but necessary to keep commits small. Follow up patches will clean things up a bit and move the Qml and C++ API in distinct subprojects. Change-Id: Ia048812f51bbbd43ec2ee754b5120b7ec3174436 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io/gltfparser.cpp')
-rw-r--r--src/render/io/gltfparser.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index d923a6027..add653b94 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -44,7 +44,7 @@
#include "texturedata.h"
#include "renderlogging.h"
-#include <entity.h>
+#include <entitynode.h>
#include <mesh.h>
#include <material.h>
#include <technique.h>
@@ -241,7 +241,7 @@ MeshDataPtr GLTFParser::mesh(QString id)
return MeshDataPtr();
}
-Entity* GLTFParser::defaultScene()
+EntityNode* GLTFParser::defaultScene()
{
parse();
if (m_defaultScene.isEmpty()) {
@@ -252,7 +252,7 @@ Entity* GLTFParser::defaultScene()
return scene(m_defaultScene);
}
-Entity* GLTFParser::scene(QString id)
+EntityNode* GLTFParser::scene(QString id)
{
parse();
@@ -263,10 +263,10 @@ Entity* GLTFParser::scene(QString id)
}
QJsonObject sceneObj = scenes.value(id).toObject();
- Entity* sceneEntity = new Entity;
+ EntityNode* sceneEntity = new EntityNode;
foreach (QJsonValue nnv, sceneObj.value(KEY_NODES).toArray()) {
QString nodeName = nnv.toString();
- Entity* child = node(nodeName);
+ EntityNode* child = node(nodeName);
if (!child)
continue;
@@ -276,7 +276,7 @@ Entity* GLTFParser::scene(QString id)
return sceneEntity;
}
-Entity* GLTFParser::node(QString id)
+EntityNode* GLTFParser::node(QString id)
{
QJsonObject nodes = m_json.object().value(KEY_NODES).toObject();
if (!nodes.contains(id)) {
@@ -285,13 +285,13 @@ Entity* GLTFParser::node(QString id)
}
QJsonObject jsonObj = nodes.value(id).toObject();
- Entity* result( new Entity );
+ EntityNode* result( new EntityNode );
parse();
if ( jsonObj.contains(KEY_CHILDREN) )
{
foreach (QJsonValue c, jsonObj.value(KEY_CHILDREN).toArray()) {
- Entity* child = node(c.toString());
+ EntityNode* child = node(c.toString());
if (!child)
continue;
result->addChild(child);
@@ -326,7 +326,7 @@ Entity* GLTFParser::node(QString id)
} else {
// need to make a child entity per material
foreach (QString matId, materialDict.keys()) {
- Entity* subEntity(new Entity);
+ EntityNode* subEntity(new EntityNode);
result->addChild(subEntity);
subEntity->addComponent(material(matId));