summaryrefslogtreecommitdiffstats
path: root/src/plugins/sceneparsers
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sceneparsers')
-rw-r--r--src/plugins/sceneparsers/CMakeLists.txt2
-rw-r--r--src/plugins/sceneparsers/assimp/CMakeLists.txt1
-rw-r--r--src/plugins/sceneparsers/assimp/assimp.pro20
-rw-r--r--src/plugins/sceneparsers/assimp/assimpimporter.cpp37
-rw-r--r--src/plugins/sceneparsers/gltf/gltf.pro16
-rw-r--r--src/plugins/sceneparsers/gltf/gltfimporter.cpp13
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexport.pro16
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexporter.cpp16
-rw-r--r--src/plugins/sceneparsers/sceneparsers.pro12
9 files changed, 27 insertions, 106 deletions
diff --git a/src/plugins/sceneparsers/CMakeLists.txt b/src/plugins/sceneparsers/CMakeLists.txt
index f9c2801a4..abc33e92a 100644
--- a/src/plugins/sceneparsers/CMakeLists.txt
+++ b/src/plugins/sceneparsers/CMakeLists.txt
@@ -4,7 +4,7 @@
# Generated from sceneparsers.pro.
add_subdirectory(gltf)
-if(QT_FEATURE_qt3d_assimp AND NOT IOS AND NOT TVOS AND NOT QNX
+if(QT_FEATURE_qt3d_assimp AND NOT QNX
AND (CLANG OR GCC OR QT_FEATURE_qt3d_system_assimp OR (ANDROID AND CLANG) OR MSVC))
add_subdirectory(assimp)
endif()
diff --git a/src/plugins/sceneparsers/assimp/CMakeLists.txt b/src/plugins/sceneparsers/assimp/CMakeLists.txt
index 773b0bf2e..1edc3cad7 100644
--- a/src/plugins/sceneparsers/assimp/CMakeLists.txt
+++ b/src/plugins/sceneparsers/assimp/CMakeLists.txt
@@ -25,6 +25,7 @@ qt_internal_add_plugin(AssimpSceneImportPlugin
Qt::Core
Qt::CorePrivate
Qt::Gui
+ NO_UNITY_BUILD
)
#### Keys ignored in scope 1:.:.:assimp.pro:<TRUE>:
diff --git a/src/plugins/sceneparsers/assimp/assimp.pro b/src/plugins/sceneparsers/assimp/assimp.pro
deleted file mode 100644
index f761db12e..000000000
--- a/src/plugins/sceneparsers/assimp/assimp.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET = assimpsceneimport
-QT += core-private 3dcore 3dcore-private 3drender 3drender-private 3dextras 3danimation
-
-include(../../../3rdparty/assimp/assimp_dependency.pri)
-
-HEADERS += \
- assimphelpers.h \
- assimpimporter.h
-
-SOURCES += \
- assimphelpers.cpp \
- main.cpp \
- assimpimporter.cpp
-
-DISTFILES += \
- assimp.json
-
-PLUGIN_TYPE = sceneparsers
-PLUGIN_CLASS_NAME = AssimpSceneImportPlugin
-load(qt_plugin)
diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
index 91763d156..4d32d1cc7 100644
--- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
@@ -20,9 +20,8 @@
#include <Qt3DExtras/qdiffusespecularmapmaterial.h>
#include <Qt3DExtras/qphongmaterial.h>
#include <Qt3DExtras/qmorphphongmaterial.h>
-#include <Qt3DExtras/qdiffusemapmaterial.h>
-#include <Qt3DExtras/qdiffusespecularmapmaterial.h>
-#include <Qt3DExtras/qphongmaterial.h>
+#include <Qt3DExtras/qnormaldiffusemapmaterial.h>
+#include <Qt3DExtras/qnormaldiffusespecularmapmaterial.h>
#include <Qt3DAnimation/qkeyframeanimation.h>
#include <Qt3DAnimation/qmorphinganimation.h>
#include <QtCore/QFileInfo>
@@ -36,11 +35,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-using namespace Qt3DExtras;
namespace Qt3DRender {
+using namespace Qt3DCore;
+using namespace Qt3DExtras;
+
/*!
\class Qt3DRender::AssimpImporter
\inmodule Qt3DRender
@@ -69,6 +69,8 @@ const QString ASSIMP_MATERIAL_AMBIENT_TEXTURE = QLatin1String("ambientTex");
const QString ASSIMP_MATERIAL_SPECULAR_TEXTURE = QLatin1String("specularTexture");
const QString ASSIMP_MATERIAL_EMISSIVE_TEXTURE = QLatin1String("emissiveTex");
const QString ASSIMP_MATERIAL_NORMALS_TEXTURE = QLatin1String("normalsTex");
+// Keep the old "normalsTex" parameter name to keep backwards compatibility, add "normalTexture" as a new one
+const QString ASSIMP_MATERIAL_NORMALS_TEXTURE2 = QLatin1String("normalTexture");
const QString ASSIMP_MATERIAL_OPACITY_TEXTURE = QLatin1String("opacityTex");
const QString ASSIMP_MATERIAL_REFLECTION_TEXTURE = QLatin1String("reflectionTex");
const QString ASSIMP_MATERIAL_HEIGHT_TEXTURE = QLatin1String("heightTex");
@@ -115,9 +117,14 @@ inline QString aiStringToQString(const aiString &str)
QMaterial *createBestApproachingMaterial(const aiMaterial *assimpMaterial)
{
aiString path; // unused but necessary
+ const bool hasNormalTexture = (assimpMaterial->GetTexture(aiTextureType_NORMALS, 0, &path) == AI_SUCCESS);
const bool hasDiffuseTexture = (assimpMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &path) == AI_SUCCESS);
const bool hasSpecularTexture = (assimpMaterial->GetTexture(aiTextureType_SPECULAR, 0, &path) == AI_SUCCESS);
+ if (hasNormalTexture && hasDiffuseTexture && hasSpecularTexture)
+ return QAbstractNodeFactory::createNode<QNormalDiffuseSpecularMapMaterial>("QNormalDiffuseSpecularMapMaterial");
+ if (hasNormalTexture && hasDiffuseTexture)
+ return QAbstractNodeFactory::createNode<QNormalDiffuseMapMaterial>("QNormalDiffuseMapMaterial");
if (hasDiffuseTexture && hasSpecularTexture)
return QAbstractNodeFactory::createNode<QDiffuseSpecularMapMaterial>("QDiffuseSpecularMapMaterial");
if (hasDiffuseTexture)
@@ -810,11 +817,7 @@ QGeometryRenderer *AssimpImporter::loadMesh(uint meshIndex)
= new Qt3DAnimation::QMorphingAnimation(geometryRenderer);
QList<QString> names;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<Qt3DAnimation::QMorphTarget *> targets;
-#else
- QVector<Qt3DAnimation::QMorphTarget *> targets;
-#endif
uint voff = 0;
uint noff = 0;
uint tanoff = 0;
@@ -1131,11 +1134,7 @@ void AssimpImporter::loadAnimation(uint animationIndex)
aiMesh *mesh = m_scene->m_aiScene->mMeshes[targetNode->mMeshes[0]];
Qt3DAnimation::QMorphingAnimation *morphingAnimation = new Qt3DAnimation::QMorphingAnimation;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<float> positions;
-#else
- QVector<float> positions;
-#endif
positions.resize(morphAnim->mNumKeys);
// set so that weights array is allocated to correct size in morphingAnimation
morphingAnimation->setTargetPositions(positions);
@@ -1143,11 +1142,7 @@ void AssimpImporter::loadAnimation(uint animationIndex)
aiMeshMorphKey &key = morphAnim->mKeys[j];
positions[j] = key.mTime * tickScale;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<float> weights;
-#else
- QVector<float> weights;
-#endif
weights.resize(key.mNumValuesAndWeights);
for (int k = 0; k < weights.size(); k++) {
const unsigned int value = key.mValues[k];
@@ -1286,8 +1281,12 @@ void AssimpImporter::copyMaterialTextures(QMaterial *material, aiMaterial *assim
tex->setWrapMode(wrapMode);
qCDebug(AssimpImporterLog) << Q_FUNC_INFO << " Loaded Texture " << fullPath;
- setParameterValue(m_scene->m_textureToParameterName[textureType[i]],
- material, QVariant::fromValue(tex));
+ const QString parameterName = m_scene->m_textureToParameterName[textureType[i]];
+ setParameterValue(parameterName, material, QVariant::fromValue(tex));
+
+ if (parameterName == ASSIMP_MATERIAL_NORMALS_TEXTURE) {
+ setParameterValue(ASSIMP_MATERIAL_NORMALS_TEXTURE2, material, QVariant::fromValue(tex));
+ }
}
}
}
diff --git a/src/plugins/sceneparsers/gltf/gltf.pro b/src/plugins/sceneparsers/gltf/gltf.pro
deleted file mode 100644
index 8f0cc2fe0..000000000
--- a/src/plugins/sceneparsers/gltf/gltf.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = gltfsceneimport
-QT += core-private 3dcore 3dcore-private 3drender 3drender-private 3dextras
-
-HEADERS += \
- gltfimporter.h
-
-SOURCES += \
- main.cpp \
- gltfimporter.cpp
-
-DISTFILES += \
- gltf.json
-
-PLUGIN_TYPE = sceneparsers
-PLUGIN_CLASS_NAME = GLTFSceneImportPlugin
-load(qt_plugin)
diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
index 69d4c8954..4f29cab06 100644
--- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
@@ -239,8 +239,6 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-using namespace Qt3DExtras;
namespace {
@@ -287,6 +285,9 @@ Qt3DRender::QFilterKey *buildFilterKey(const QString &key, const QJsonValue &val
namespace Qt3DRender {
+using namespace Qt3DCore;
+using namespace Qt3DExtras;
+
Q_LOGGING_CATEGORY(GLTFImporterLog, "Qt3D.GLTFImport", QtWarningMsg);
class GLTFRawTextureImage : public QAbstractTextureImage
@@ -1050,9 +1051,9 @@ QMaterial *GLTFImporter::commonMaterial(const QJsonObject &jsonObj)
} else {
for (QVariantHash::const_iterator it = params.constBegin(), itEnd = params.constEnd(); it != itEnd; ++it)
mat->setProperty(it.key().toUtf8(), it.value());
- }
- renameFromJson(jsonObj, mat);
+ renameFromJson(jsonObj, mat);
+ }
return mat;
}
@@ -1819,11 +1820,7 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json)
target->setProperty(propName.constData(), QVariant(size));
}
} else {
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QMetaType propType = target->property(propName.constData()).metaType();
-#else
- const QMetaType propType(target->property(propName.constData()).type());
-#endif
if (propType.id() == QMetaType::Int) {
target->setProperty(propName.constData(), QVariant(it.value().toInt()));
} else {
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexport.pro b/src/plugins/sceneparsers/gltfexport/gltfexport.pro
deleted file mode 100644
index 9da330605..000000000
--- a/src/plugins/sceneparsers/gltfexport/gltfexport.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = gltfsceneexport
-QT += core-private 3dcore 3dcore-private 3drender 3drender-private 3dextras
-
-HEADERS += \
- gltfexporter.h
-
-SOURCES += \
- main.cpp \
- gltfexporter.cpp
-
-DISTFILES += \
- gltfexport.json
-
-PLUGIN_TYPE = sceneparsers
-PLUGIN_CLASS_NAME = GLTFSceneExportPlugin
-load(qt_plugin)
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
index 31808caa7..12c979019 100644
--- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
+++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
@@ -186,11 +186,11 @@ inline void promoteColorsToRGBA(QJsonObject *obj)
QT_BEGIN_NAMESPACE
+namespace Qt3DRender {
+
using namespace Qt3DCore;
using namespace Qt3DExtras;
-namespace Qt3DRender {
-
Q_LOGGING_CATEGORY(GLTFExporterLog, "Qt3D.GLTFExport", QtWarningMsg)
const QString MATERIAL_DIFFUSE_COLOR = QStringLiteral("kd");
@@ -627,11 +627,7 @@ void GLTFExporter::parseMaterials()
if (material->effect()) {
QList<QParameter *> parameters = material->effect()->parameters();
for (auto param : parameters) {
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (param->value().metaType().id() == QMetaType::QColor) {
-#else
- if (param->value().type() == QMetaType::QColor) {
-#endif
QColor color = param->value().value<QColor>();
if (param->name() == MATERIAL_AMBIENT_COLOR) {
matInfo.colors.insert(QStringLiteral("ambient"), color);
@@ -1768,11 +1764,7 @@ void GLTFExporter::exportParameter(QJsonObject &jsonObj, const QString &name,
paramObj[typeStr] = GL_SAMPLER_2D;
paramObj[valueStr] = m_textureIdMap.value(textureVariantToUrl(variant));
} else {
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
switch (variant.metaType().id()) {
-#else
- switch (variant.type()) {
-#endif
case QMetaType::Bool:
paramObj[typeStr] = GL_BOOL;
paramObj[valueStr] = variant.toBool();
@@ -2044,11 +2036,7 @@ QString GLTFExporter::textureVariantToUrl(const QVariant &var)
void GLTFExporter::setVarToJSonObject(QJsonObject &jsObj, const QString &key, const QVariant &var)
{
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
switch (var.metaType().id()) {
-#else
- switch (var.type()) {
-#endif
case QMetaType::Bool:
jsObj[key] = var.toBool();
break;
diff --git a/src/plugins/sceneparsers/sceneparsers.pro b/src/plugins/sceneparsers/sceneparsers.pro
deleted file mode 100644
index 573a5ddad..000000000
--- a/src/plugins/sceneparsers/sceneparsers.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TEMPLATE = subdirs
-# QNX is not supported, and Linux GCC 4.9 on ARM chokes on the assimp
-# sources (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66964).
-QT_FOR_CONFIG += 3dcore-private
-!ios:!tvos:!qcc:qtConfig(qt3d-assimp):if(qtConfig(qt3d-system-assimp)|android-clang|clang|win32-msvc|gcc) {
- SUBDIRS += assimp
-}
-SUBDIRS += gltf
-
-qtConfig(temporaryfile):qtConfig(regularexpression) {
- SUBDIRS += gltfexport
-}