summaryrefslogtreecommitdiffstats
path: root/src/plugins/sceneparsers/gltf/gltfimporter.h
diff options
context:
space:
mode:
authorMassimo Callegari <massimocallegari@yahoo.it>2018-12-21 11:02:13 +0100
committerMassimo Callegari <massimocallegari@yahoo.it>2018-12-22 07:47:53 +0000
commitcc4c126d29e43c51e16a1c3fdcc0c7987e84ee42 (patch)
tree1f82f0107e2cd90c45ccb55aa1c0cdf4c783796a /src/plugins/sceneparsers/gltf/gltfimporter.h
parent02ac30f7d12df759146f3a5ce000a5f1cb7998fe (diff)
Preliminary glTF 2.0 scene import support
- add parsing of assets and detect the format version - add support for embedded resources - add composite metalness+roughness texture support See notes in cpp file. Task-number: QTBUG-61258 Change-Id: I40f2922d3e2391eb384527a6808fe1509a4aff96 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/plugins/sceneparsers/gltf/gltfimporter.h')
-rw-r--r--src/plugins/sceneparsers/gltf/gltfimporter.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.h b/src/plugins/sceneparsers/gltf/gltfimporter.h
index d47a6a729..271ce5979 100644
--- a/src/plugins/sceneparsers/gltf/gltfimporter.h
+++ b/src/plugins/sceneparsers/gltf/gltfimporter.h
@@ -57,6 +57,7 @@
#include <QtCore/qjsondocument.h>
#include <QtCore/qjsonobject.h>
#include <QtCore/qhash.h>
+#include <QtCore/qloggingcategory.h>
#include <Qt3DRender/private/qsceneimporter_p.h>
@@ -82,6 +83,7 @@ class QParameter;
class QGeometryRenderer;
class QAbstractLight;
class QRenderPass;
+class QTexture2D;
Q_DECLARE_LOGGING_CATEGORY(GLTFImporterLog)
@@ -94,7 +96,7 @@ public:
~GLTFImporter();
void setBasePath(const QString& path);
- bool setJSON( const QJsonDocument &json );
+ bool setJSON(const QJsonDocument &json);
// SceneParserInterface interface
void setSource(const QUrl &source) final;
@@ -130,7 +132,7 @@ private:
{
public:
AccessorData();
- explicit AccessorData(const QJsonObject& json);
+ explicit AccessorData(const QJsonObject& json, int major, int minor);
QString bufferViewName;
QAttribute::VertexBaseType type;
@@ -141,6 +143,7 @@ private:
};
static bool isGLTFSupported(const QStringList &extensions);
+ static bool isEmbeddedResource(const QString &url);
static void renameFromJson(const QJsonObject& json, QObject * const object );
static bool hasStandardUniformNameFromSemantic(const QString &semantic);
static QString standardAttributeNameFromSemantic(const QString &semantic);
@@ -151,8 +154,11 @@ private:
bool fillCamera(QCameraLens &lens, QCamera *cameraEntity, const QString &id) const;
void parse();
+ void parseV1();
+ void parseV2();
void cleanup();
+ void processJSONAsset(const QJsonObject &json);
void processJSONBuffer(const QString &id, const QJsonObject &json);
void processJSONBufferView(const QString &id, const QJsonObject &json);
void processJSONShader(const QString &id, const QJsonObject &jsonObject);
@@ -181,12 +187,16 @@ private:
void populateRenderStates(QRenderPass *pass, const QJsonObject &states);
void addProgramToPass(QRenderPass *pass, const QString &progName);
+ void setTextureSamplerInfo(const QString &id, const QJsonObject &jsonObj, QTexture2D *tex);
QMaterial *materialWithCustomShader(const QString &id, const QJsonObject &jsonObj);
QMaterial *commonMaterial(const QJsonObject &jsonObj);
+ QMaterial *pbrMaterial(const QJsonObject &jsonObj);
QJsonDocument m_json;
QString m_basePath;
bool m_parseDone;
+ int m_majorVersion;
+ int m_minorVersion;
QString m_defaultScene;
// multi-hash because our QMeshData corresponds to a single primitive
@@ -215,6 +225,7 @@ private:
QHash<QString, QAbstractTexture*> m_textures;
QHash<QString, QString> m_imagePaths;
+ QHash<QString, QImage> m_imageData;
QHash<QString, QAbstractLight *> m_lights;
};