summaryrefslogtreecommitdiffstats
path: root/src/plugins/sceneparsers
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-05 20:34:44 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-05 20:47:59 +0200
commit8e67fb1f148b2f3c795d230faad7aee20389878a (patch)
tree34358c0ee9ab4816d20d58d84bdab20093b1d423 /src/plugins/sceneparsers
parentba5bc93b95d28a28a72e60281f765a6f031129a5 (diff)
parentd4fb24c0871320667640f100b743f34f702db6cf (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/animation/backend/channelmapper_p.h Change-Id: I4e0f59c6648925ba45d30ccc2405524a9e901a0e
Diffstat (limited to 'src/plugins/sceneparsers')
-rw-r--r--src/plugins/sceneparsers/assimp/assimpimporter.cpp6
-rw-r--r--src/plugins/sceneparsers/gltf/gltfimporter.cpp34
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexporter.cpp41
3 files changed, 68 insertions, 13 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
index a1558b7e2..3a06c7807 100644
--- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
@@ -403,8 +403,8 @@ void AssimpImporter::setSource(const QUrl &source)
}
/*!
- * Sets the \a source used by the parser to load the asset file.
- * If the file is valid, this will trigger parsing of the file.
+ * Sets the \a basePath used by the parser to load the asset file.
+ * If the file specified in \a data is valid, this will trigger parsing of the file.
*/
void AssimpImporter::setData(const QByteArray &data, const QString &basePath)
{
@@ -412,7 +412,7 @@ void AssimpImporter::setData(const QByteArray &data, const QString &basePath)
}
/*!
- * Returns \c true if the extension of \a source is supported by
+ * Returns \c true if the extension in QStringList \a extensions is supported by
* the assimp parser.
*/
bool AssimpImporter::areFileTypesSupported(const QStringList &extensions) const
diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
index a94a4f307..4419bd708 100644
--- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
@@ -268,11 +268,23 @@ GLTFImporter::~GLTFImporter()
}
+/*!
+ \class Qt3DRender::GLTFImporter
+ \inmodule Qt3DRender
+ \brief Handles importing of gltf files
+*/
+/*!
+ Set the base \a path for importing scenes.
+*/
void GLTFImporter::setBasePath(const QString& path)
{
m_basePath = path;
}
+/*!
+ Set a \a json document as the file used for importing a scene.
+ Returns true if the operation is successful.
+*/
bool GLTFImporter::setJSON(const QJsonDocument &json )
{
if ( !json.isObject() ) {
@@ -286,7 +298,8 @@ bool GLTFImporter::setJSON(const QJsonDocument &json )
}
/*!
- * Sets the \a path used by the parser to load the scene file.
+ * Sets the path based on parameter \a source. The path is
+ * used by the parser to load the scene file.
* If the file is valid, parsing is automatically triggered.
*/
void GLTFImporter::setSource(const QUrl &source)
@@ -314,8 +327,9 @@ void GLTFImporter::setSource(const QUrl &source)
}
/*!
- * Sets the \a path used by the parser to load the scene file.
- * If the file is valid, parsing is automatically triggered.
+ * Sets the \a basePath used by the parser to load the scene file.
+ * If the file derived from \a data is valid, parsing is automatically
+ * triggered.
*/
void GLTFImporter::setData(const QByteArray& data, const QString &basePath)
{
@@ -332,7 +346,7 @@ void GLTFImporter::setData(const QByteArray& data, const QString &basePath)
}
/*!
- * Returns true if the extensions are supported by the
+ * Returns true if the \a extensions are supported by the
* GLTF parser.
*/
bool GLTFImporter::areFileTypesSupported(const QStringList &extensions) const
@@ -340,6 +354,9 @@ bool GLTFImporter::areFileTypesSupported(const QStringList &extensions) const
return GLTFImporter::isGLTFSupported(extensions);
}
+/*!
+ Imports the node specified in \a id from the GLTF file.
+*/
Qt3DCore::QEntity* GLTFImporter::node(const QString &id)
{
QJsonObject nodes = m_json.object().value(KEY_NODES).toObject();
@@ -507,6 +524,9 @@ Qt3DCore::QEntity* GLTFImporter::node(const QString &id)
return result;
}
+/*!
+ Imports the scene specified in parameter \a id.
+*/
Qt3DCore::QEntity* GLTFImporter::scene(const QString &id)
{
parse();
@@ -1656,6 +1676,9 @@ void GLTFImporter::processJSONRenderPass(const QString &id, const QJsonObject &j
m_renderPasses[id] = pass;
}
+/*!
+ Loads raw data from the GLTF file into the buffer.
+*/
void GLTFImporter::loadBufferData()
{
for (auto &bufferData : m_bufferDatas) {
@@ -1665,6 +1688,9 @@ void GLTFImporter::loadBufferData()
}
}
+/*!
+ Removes all data from the buffer.
+*/
void GLTFImporter::unloadBufferData()
{
for (const auto &bufferData : qAsConst(m_bufferDatas)) {
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
index 7921fce64..ba100e095 100644
--- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
+++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
@@ -266,6 +266,13 @@ GLTFExporter::~GLTFExporter()
{
}
+/*!
+ \class Qt3DRender::GLTFExporter
+ \inmodule Qt3DRender
+ \brief Manages the export of a 3D scene to the GLTF format.
+
+ Handles the export of a 3D scene to the GLTF format.
+*/
// sceneRoot : The root entity that contains the exported scene. If the sceneRoot doesn't have
// any exportable components, it is not exported itself. This is because importing a
// scene creates an empty top level entity to hold the scene.
@@ -278,6 +285,23 @@ GLTFExporter::~GLTFExporter()
// "binaryJson" (bool): Generates a binary JSON file, which is more efficient to parse.
// "compactJson" (bool): Removes unnecessary whitespace from the generated JSON file.
// Ignored if "binaryJson" option is true.
+
+/*!
+ Exports the scene to the GLTF format
+
+ \a sceneRoot is the root entity that will be exported.
+ If the sceneRoot does not have any exportable components, it is not exported itself.
+
+ \a outDir is the directory in which the scene export is created.
+
+ \a exportName is the name of the directory created in \c outDir that will hold
+ the exported scene.
+
+ \a options contain the export options.
+
+ Returns true if the export was carried out successfully.
+*/
+
bool GLTFExporter::exportScene(QEntity *sceneRoot, const QString &outDir,
const QString &exportName, const QVariantHash &options)
{
@@ -643,18 +667,23 @@ void GLTFExporter::parseMaterials()
for (auto param : parameters) {
if (param->value().type() == QVariant::Color) {
QColor color = param->value().value<QColor>();
- if (param->name() == MATERIAL_AMBIENT_COLOR)
+ if (param->name() == MATERIAL_AMBIENT_COLOR) {
matInfo.colors.insert(QStringLiteral("ambient"), color);
- else if (param->name() == MATERIAL_DIFFUSE_COLOR)
+ } else if (param->name() == MATERIAL_DIFFUSE_COLOR) {
+ if (matInfo.type == MaterialInfo::TypePhongAlpha) {
+ matInfo.values.insert(QStringLiteral("transparency"), float(color.alphaF()));
+ color.setAlphaF(1.0f);
+ }
matInfo.colors.insert(QStringLiteral("diffuse"), color);
- else if (param->name() == MATERIAL_SPECULAR_COLOR)
+ } else if (param->name() == MATERIAL_SPECULAR_COLOR) {
matInfo.colors.insert(QStringLiteral("specular"), color);
- else if (param->name() == MATERIAL_COOL_COLOR) // Custom Qt3D gooch
+ } else if (param->name() == MATERIAL_COOL_COLOR) { // Custom Qt3D gooch
matInfo.colors.insert(QStringLiteral("cool"), color);
- else if (param->name() == MATERIAL_WARM_COLOR) // Custom Qt3D gooch
+ } else if (param->name() == MATERIAL_WARM_COLOR) { // Custom Qt3D gooch
matInfo.colors.insert(QStringLiteral("warm"), color);
- else
+ } else {
matInfo.colors.insert(param->name(), color);
+ }
} else if (param->value().canConvert<QAbstractTexture *>()) {
const QString urlString = textureVariantToUrl(param->value());
if (param->name() == MATERIAL_DIFFUSE_TEXTURE)