Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
assimpimporter_rt.cpp File Reference

(7b7db472caedb76f2d85b98cf414519bf971f97a)

#include "assimpimporter.h"
#include <assimputils.h>
#include <QtCore/qurl.h>
#include <QtCore/qbytearrayalgorithms.h>
#include <QtGui/QQuaternion>
#include <QtQml/QQmlFile>
#include <QtQuick3DAssetImport/private/qssgassetimporterfactory_p.h>
#include <QtQuick3DAssetImport/private/qssgassetimporter_p.h>
#include <QtQuick3DAssetUtils/private/qssgscenedesc_p.h>
#include <QtQuick3DAssetUtils/private/qssgsceneedit_p.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/Logger.hpp>
#include <assimp/DefaultLogger.hpp>
#include <assimp/postprocess.h>
#include <assimp/material.h>
#include <assimp/GltfMaterial.h>
#include <assimp/importerdesc.h>
#include <assimp/IOSystem.hpp>
#include <assimp/IOStream.hpp>
+ Include dependency graph for assimpimporter_rt.cpp:

Go to the source code of this file.

Classes

struct  NodeInfo
 
struct  TextureInfo
 
struct  TextureEntry
 
struct  SceneInfo
 
struct  SceneInfo::Options
 
struct  SceneInfo::skinData
 
class  ResourceIOStream
 
class  ResourceIOSystem
 

Macros

#define AI_GLTF_FILTER_NEAREST   0x2600
 
#define AI_GLTF_FILTER_LINEAR   0x2601
 
#define AI_GLTF_FILTER_NEAREST_MIPMAP_NEAREST   0x2700
 
#define AI_GLTF_FILTER_LINEAR_MIPMAP_NEAREST   0x2701
 
#define AI_GLTF_FILTER_NEAREST_MIPMAP_LINEAR   0x2702
 
#define AI_GLTF_FILTER_LINEAR_MIPMAP_LINEAR   0x2703
 
#define demonPostProcessPresets
 

Typedefs

using NodeMap = QHash<const aiNode *, NodeInfo>
 
using AnimationNodeMap = QHash<QByteArray, QSSGSceneDesc::Node *>
 
using MorphAttributes = QQuick3DMorphTarget::MorphTargetAttributes
 
using MorphProperty = QPair<MorphAttributes, float>
 

Functions

static Q_REQUIRED_RESULT QColor aiColorToQColor (const aiColor3D &color)
 
static Q_REQUIRED_RESULT QColor aiColorToQColor (const aiColor4D &color)
 
static QByteArray fromAiString (const aiString &string)
 
 Q_DECLARE_TYPEINFO (NodeInfo, Q_PRIMITIVE_TYPE)
 
static bool isEqual (const aiUVTransform &a, const aiUVTransform &b)
 
bool operator== (const TextureInfo &a, const TextureInfo &b)
 
size_t qHash (const TextureEntry &key, size_t seed)
 
bool operator== (const TextureEntry &a, const TextureEntry &b)
 
static void setNodeProperties (QSSGSceneDesc::Node &target, const aiNode &source, const SceneInfo &sceneInfo, aiMatrix4x4 *transformCorrection)
 
static void setTextureProperties (QSSGSceneDesc::Texture &target, const TextureInfo &texInfo, const SceneInfo &sceneInfo)
 
static void setMaterialProperties (QSSGSceneDesc::Material &target, const aiMaterial &source, const SceneInfo &sceneInfo, QSSGSceneDesc::Material::RuntimeType type)
 
static void setCameraProperties (QSSGSceneDesc::Camera &target, const aiCamera &source, const aiNode &sourceNode, const SceneInfo &sceneInfo)
 
static void setLightProperties (QSSGSceneDesc::Light &target, const aiLight &source, const aiNode &sourceNode, const SceneInfo &sceneInfo)
 
static QVector< MorphPropertygetMorphTargetProperties (const aiMesh &mesh)
 
static void setModelProperties (QSSGSceneDesc::Model &target, const aiNode &source, const SceneInfo &sceneInfo)
 
static QSSGSceneDesc::NodecreateSceneNode (const NodeInfo &nodeInfo, const aiNode &srcNode, QSSGSceneDesc::Node &parent, const SceneInfo &sceneInfo)
 
static void processNode (const SceneInfo &sceneInfo, const aiNode &source, QSSGSceneDesc::Node &parent, const NodeMap &nodeMap, AnimationNodeMap &animationNodes)
 
static QSSGSceneDesc::Animation::KeyPosition toAnimationKey (const aiVectorKey &key, qreal freq)
 
static QSSGSceneDesc::Animation::KeyPosition toAnimationKey (const aiQuatKey &key, qreal freq)
 
static QSSGSceneDesc::Animation::KeyPosition toAnimationKey (const aiMeshMorphKey &key, qreal freq, uint morphId)
 
static bool checkBooleanOption (const QString &optionName, const QJsonObject &options)
 
static qreal getRealOption (const QString &optionName, const QJsonObject &options)
 
static aiPostProcessSteps processOptions (const QJsonObject &optionsObject, std::unique_ptr< Assimp::Importer > &importer)
 
static SceneInfo::Options processSceneOptions (const QJsonObject &optionsObject)
 
static QString importImp (const QUrl &url, const QJsonObject &options, QSSGSceneDesc::Scene &targetScene)
 

Macro Definition Documentation

◆ AI_GLTF_FILTER_LINEAR

#define AI_GLTF_FILTER_LINEAR   0x2601

Definition at line 37 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ AI_GLTF_FILTER_LINEAR_MIPMAP_LINEAR

#define AI_GLTF_FILTER_LINEAR_MIPMAP_LINEAR   0x2703

Definition at line 41 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ AI_GLTF_FILTER_LINEAR_MIPMAP_NEAREST

#define AI_GLTF_FILTER_LINEAR_MIPMAP_NEAREST   0x2701

Definition at line 39 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ AI_GLTF_FILTER_NEAREST

#define AI_GLTF_FILTER_NEAREST   0x2600

Definition at line 36 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ AI_GLTF_FILTER_NEAREST_MIPMAP_LINEAR

#define AI_GLTF_FILTER_NEAREST_MIPMAP_LINEAR   0x2702

Definition at line 40 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ AI_GLTF_FILTER_NEAREST_MIPMAP_NEAREST

#define AI_GLTF_FILTER_NEAREST_MIPMAP_NEAREST   0x2700

Definition at line 38 of file assimpimporter_rt.cpp.

Referenced by setTextureProperties().

◆ demonPostProcessPresets

#define demonPostProcessPresets
Value:
( \
aiProcess_CalcTangentSpace | \
aiProcess_GenSmoothNormals | \
aiProcess_JoinIdenticalVertices | \
aiProcess_ImproveCacheLocality | \
aiProcess_RemoveRedundantMaterials | \
aiProcess_SplitLargeMeshes | \
aiProcess_Triangulate | \
aiProcess_GenUVCoords | \
aiProcess_SortByPType | \
aiProcess_FindDegenerates | \
aiProcess_FindInvalidData | \
0 )

Definition at line 1517 of file assimpimporter_rt.cpp.

Referenced by importImp().

Typedef Documentation

◆ AnimationNodeMap

◆ MorphAttributes

using MorphAttributes = QQuick3DMorphTarget::MorphTargetAttributes

Definition at line 1197 of file assimpimporter_rt.cpp.

◆ MorphProperty

Definition at line 1198 of file assimpimporter_rt.cpp.

◆ NodeMap

using NodeMap = QHash<const aiNode *, NodeInfo>

Definition at line 68 of file assimpimporter_rt.cpp.

Function Documentation

◆ aiColorToQColor() [1/2]

static Q_REQUIRED_RESULT QColor aiColorToQColor ( const aiColor3D & color)
inlinestatic

Definition at line 43 of file assimpimporter_rt.cpp.

References QColor::fromRgbF().

Referenced by setMaterialProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aiColorToQColor() [2/2]

static Q_REQUIRED_RESULT QColor aiColorToQColor ( const aiColor4D & color)
inlinestatic

Definition at line 48 of file assimpimporter_rt.cpp.

References QColor::fromRgbF().

+ Here is the call graph for this function:

◆ checkBooleanOption()

static bool checkBooleanOption ( const QString & optionName,
const QJsonObject & options )
static

Definition at line 1488 of file assimpimporter_rt.cpp.

References QJsonObject::constEnd(), QJsonObject::constFind(), and it.

Referenced by processOptions(), processSceneOptions(), and QSSGQmlUtilities::writeQml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSceneNode()

static QSSGSceneDesc::Node * createSceneNode ( const NodeInfo & nodeInfo,
const aiNode & srcNode,
QSSGSceneDesc::Node & parent,
const SceneInfo & sceneInfo )
static

Definition at line 1347 of file assimpimporter_rt.cpp.

References QSSGSceneDesc::addNode(), QSSGSceneDesc::Node::scene, setCameraProperties(), QQuick3DJoint::setIndex(), setLightProperties(), setModelProperties(), setNodeProperties(), and QSSGSceneDesc::setProperty().

Referenced by processNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromAiString()

static QByteArray fromAiString ( const aiString & string)
static

Definition at line 53 of file assimpimporter_rt.cpp.

References QByteArray().

Referenced by importImp(), setMaterialProperties(), setModelProperties(), and setNodeProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMorphTargetProperties()

static QVector< MorphProperty > getMorphTargetProperties ( const aiMesh & mesh)
static

Definition at line 1200 of file assimpimporter_rt.cpp.

References QQuick3DMorphTarget::Binormal, i, QQuick3DMorphTarget::Normal, QQuick3DMorphTarget::Position, qMakePair(), qMin(), and QQuick3DMorphTarget::Tangent.

Referenced by processNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRealOption()

static qreal getRealOption ( const QString & optionName,
const QJsonObject & options )
static

Definition at line 1502 of file assimpimporter_rt.cpp.

References QJsonObject::constEnd(), QJsonObject::constFind(), and it.

Referenced by processSceneOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importImp()

static QString importImp ( const QUrl & url,
const QJsonObject & options,
QSSGSceneDesc::Scene & targetScene )
static

◆ isEqual()

static bool isEqual ( const aiUVTransform & a,
const aiUVTransform & b )
inlinestatic

Definition at line 72 of file assimpimporter_rt.cpp.

Referenced by QLineEdit::changeEvent(), QWidget::event(), operator==(), QCocoaFileDialogHelper::panelDirectoryDidChange(), QCoreTextFontDatabase::populateFamilyAliases(), setTextureProperties(), and QCocoaMenuBar::syncMenu_helper().

+ Here is the caller graph for this function:

◆ operator==() [1/2]

bool operator== ( const TextureEntry & a,
const TextureEntry & b )

Definition at line 116 of file assimpimporter_rt.cpp.

◆ operator==() [2/2]

bool operator== ( const TextureInfo & a,
const TextureInfo & b )

Definition at line 87 of file assimpimporter_rt.cpp.

References isEqual().

+ Here is the call graph for this function:

◆ processNode()

static void processNode ( const SceneInfo & sceneInfo,
const aiNode & source,
QSSGSceneDesc::Node & parent,
const NodeMap & nodeMap,
AnimationNodeMap & animationNodes )
static

Definition at line 1407 of file assimpimporter_rt.cpp.

References QSSGSceneDesc::addNode(), QSet< T >::constEnd(), QSet< T >::constFind(), createSceneNode(), getMorphTargetProperties(), i, it, QQuick3DModel::morphTargets, QString::number(), processNode(), Q_ASSERT, QStringLiteral, QSSGSceneDesc::Node::scene, QQuick3DMorphTarget::setAttributes(), QSSGSceneDesc::setProperty(), and QQuick3DMorphTarget::setWeight().

Referenced by importImp(), processNode(), QSSGQmlUtilities::writeQmlForNode(), and QSSGQmlUtilities::writeQmlForResourceNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processOptions()

static aiPostProcessSteps processOptions ( const QJsonObject & optionsObject,
std::unique_ptr< Assimp::Importer > & importer )
static

Definition at line 1531 of file assimpimporter_rt.cpp.

References checkBooleanOption(), QJsonObject::constEnd(), QJsonObject::constFind(), QJsonObject::isEmpty(), it, and QStringLiteral.

Referenced by importImp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processSceneOptions()

static SceneInfo::Options processSceneOptions ( const QJsonObject & optionsObject)
static

Definition at line 1629 of file assimpimporter_rt.cpp.

References checkBooleanOption(), QJsonObject::constEnd(), QJsonObject::constFind(), getRealOption(), QJsonObject::isEmpty(), it, qBound(), and QStringLiteral.

Referenced by importImp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( NodeInfo ,
Q_PRIMITIVE_TYPE  )

◆ qHash()

size_t qHash ( const TextureEntry & key,
size_t seed )

Definition at line 104 of file assimpimporter_rt.cpp.

References qHash(), qHashBits(), and seed.

Referenced by qHash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCameraProperties()

static void setCameraProperties ( QSSGSceneDesc::Camera & target,
const aiCamera & source,
const aiNode & sourceNode,
const SceneInfo & sceneInfo )
static

Definition at line 1021 of file assimpimporter_rt.cpp.

References QQuick3DPerspectiveCamera::Horizontal, M_PI, qRadiansToDegrees(), QQuick3DOrthographicCamera::setClipFar(), QQuick3DPerspectiveCamera::setClipFar(), QQuick3DOrthographicCamera::setClipNear(), QQuick3DPerspectiveCamera::setClipNear(), QQuick3DPerspectiveCamera::setFieldOfView(), QQuick3DPerspectiveCamera::setFieldOfViewOrientation(), QQuick3DOrthographicCamera::setHorizontalMagnification(), setNodeProperties(), setProperty, and QQuick3DOrthographicCamera::setVerticalMagnification().

Referenced by createSceneNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLightProperties()

static void setLightProperties ( QSSGSceneDesc::Light & target,
const aiLight & source,
const aiNode & sourceNode,
const SceneInfo & sceneInfo )
static

Definition at line 1097 of file assimpimporter_rt.cpp.

References QColor::fromRgbF(), Q_FALLTHROUGH, qFuzzyIsNull(), qMax(), qRadiansToDegrees(), QQuick3DAbstractLight::setAmbientColor(), QQuick3DAbstractLight::setBrightness(), QQuick3DAbstractLight::setColor(), QQuick3DSpotLight::setConeAngle(), QQuick3DPointLight::setConstantFade(), QQuick3DSpotLight::setConstantFade(), QQuick3DSpotLight::setInnerConeAngle(), QQuick3DPointLight::setLinearFade(), QQuick3DSpotLight::setLinearFade(), setNodeProperties(), QSSGSceneDesc::setProperty(), QQuick3DPointLight::setQuadraticFade(), and QQuick3DSpotLight::setQuadraticFade().

Referenced by createSceneNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMaterialProperties()

static void setMaterialProperties ( QSSGSceneDesc::Material & target,
const aiMaterial & source,
const SceneInfo & sceneInfo,
QSSGSceneDesc::Material::RuntimeType type )
static

Definition at line 443 of file assimpimporter_rt.cpp.

References QQuick3DMaterial::A, QSSGSceneDesc::addNode(), aiColorToQColor(), QQuick3DMaterial::B, QQuick3DPrincipledMaterial::Blend, QQuick3DSpecularGlossyMaterial::Blend, QSet< T >::cend(), QSet< T >::constFind(), QQuick3DPrincipledMaterial::Default, QQuick3DSpecularGlossyMaterial::Default, fromAiString(), QString::fromUtf8(), QQuick3DMaterial::G, imageData, it, QQuick3DPrincipledMaterial::Mask, QQuick3DSpecularGlossyMaterial::Mask, QQuick3DMaterial::NoCulling, QQuick3DDefaultMaterial::NoLighting, QQuick3DPrincipledMaterial::NoLighting, QQuick3DSpecularGlossyMaterial::NoLighting, QQuick3DPrincipledMaterial::Opaque, QQuick3DSpecularGlossyMaterial::Opaque, QQuick3DMaterial::OpaquePrePassDepthDraw, Q_ASSERT, QByteArray(), QByteArrayLiteral, QQuick3DMaterial::R, QQuick3DSpecularGlossyMaterial::setAlbedoColor(), QQuick3DSpecularGlossyMaterial::setAlbedoMap(), QQuick3DPrincipledMaterial::setAlphaCutoff(), QQuick3DSpecularGlossyMaterial::setAlphaCutoff(), QQuick3DPrincipledMaterial::setAlphaMode(), QQuick3DSpecularGlossyMaterial::setAlphaMode(), QQuick3DSpecularGlossyMaterial::setAttenuationColor(), QQuick3DSpecularGlossyMaterial::setAttenuationDistance(), QQuick3DPrincipledMaterial::setBaseColor(), QQuick3DPrincipledMaterial::setBaseColorMap(), QQuick3DDefaultMaterial::setBumpAmount(), QQuick3DDefaultMaterial::setBumpMap(), QQuick3DSpecularGlossyMaterial::setClearcoatAmount(), QQuick3DSpecularGlossyMaterial::setClearcoatMap(), QQuick3DSpecularGlossyMaterial::setClearcoatNormalMap(), QQuick3DSpecularGlossyMaterial::setClearcoatRoughnessAmount(), QQuick3DSpecularGlossyMaterial::setClearcoatRoughnessMap(), QQuick3DMaterial::setCullMode(), QQuick3DMaterial::setDepthDrawMode(), QQuick3DDefaultMaterial::setDiffuseColor(), QQuick3DDefaultMaterial::setDiffuseMap(), QQuick3DSpecularGlossyMaterial::setEmissiveFactor(), QQuick3DPrincipledMaterial::setEmissiveFactor(), QQuick3DDefaultMaterial::setEmissiveMap(), QQuick3DPrincipledMaterial::setEmissiveMap(), QQuick3DSpecularGlossyMaterial::setEmissiveMap(), QQuick3DSpecularGlossyMaterial::setGlossiness(), QQuick3DSpecularGlossyMaterial::setGlossinessChannel(), QQuick3DSpecularGlossyMaterial::setGlossinessMap(), QQuick3DDefaultMaterial::setLighting(), QQuick3DPrincipledMaterial::setLighting(), QQuick3DSpecularGlossyMaterial::setLighting(), QQuick3DPrincipledMaterial::setMetalness(), QQuick3DPrincipledMaterial::setMetalnessChannel(), QQuick3DPrincipledMaterial::setMetalnessMap(), QQuick3DDefaultMaterial::setNormalMap(), QQuick3DPrincipledMaterial::setNormalMap(), QQuick3DSpecularGlossyMaterial::setNormalMap(), QQuick3DPrincipledMaterial::setNormalStrength(), QQuick3DSpecularGlossyMaterial::setNormalStrength(), QQuick3DPrincipledMaterial::setOcclusionAmount(), QQuick3DSpecularGlossyMaterial::setOcclusionAmount(), QQuick3DPrincipledMaterial::setOcclusionChannel(), QQuick3DSpecularGlossyMaterial::setOcclusionChannel(), QQuick3DPrincipledMaterial::setOcclusionMap(), QQuick3DSpecularGlossyMaterial::setOcclusionMap(), QQuick3DDefaultMaterial::setOpacity(), QQuick3DPrincipledMaterial::setOpacityChannel(), QQuick3DSpecularGlossyMaterial::setOpacityChannel(), QQuick3DDefaultMaterial::setOpacityMap(), QSSGSceneDesc::setProperty(), QQuick3DPrincipledMaterial::setRoughness(), QQuick3DPrincipledMaterial::setRoughnessChannel(), QQuick3DPrincipledMaterial::setRoughnessMap(), QQuick3DTexture::setSource(), QQuick3DSpecularGlossyMaterial::setSpecularColor(), QQuick3DDefaultMaterial::setSpecularMap(), QQuick3DSpecularGlossyMaterial::setSpecularMap(), QQuick3DTexture::setTextureData(), setTextureProperties(), QQuick3DSpecularGlossyMaterial::setThicknessFactor(), QQuick3DSpecularGlossyMaterial::setThicknessMap(), QQuick3DSpecularGlossyMaterial::setTransmissionFactor(), QQuick3DSpecularGlossyMaterial::setTransmissionMap(), and TextureInfo::transform.

Referenced by setModelProperties().

+ Here is the caller graph for this function:

◆ setModelProperties()

static void setModelProperties ( QSSGSceneDesc::Model & target,
const aiNode & source,
const SceneInfo & sceneInfo )
static

Definition at line 1221 of file assimpimporter_rt.cpp.

References QSSGSceneDesc::addNode(), QList< T >::first(), fromAiString(), QVariant::fromValue(), AssimpUtils::generateMeshData(), i, QList< T >::isEmpty(), QQuick3DModel::materials, QList< T >::push_back(), Q_ASSERT, setMaterialProperties(), setNodeProperties(), QSSGSceneDesc::setProperty(), and QQuick3DModel::setSource().

Referenced by createSceneNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNodeProperties()

static void setNodeProperties ( QSSGSceneDesc::Node & target,
const aiNode & source,
const SceneInfo & sceneInfo,
aiMatrix4x4 * transformCorrection )
static

Definition at line 282 of file assimpimporter_rt.cpp.

References fromAiString(), QQuick3DNode::setPosition(), QSSGSceneDesc::setProperty(), QQuick3DNode::setRotation(), QQuick3DNode::setScale(), QQuick3DNode::setX(), QQuick3DNode::setY(), QQuick3DNode::setZ(), and QVector3D::x().

Referenced by createSceneNode(), setCameraProperties(), setLightProperties(), and setModelProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTextureProperties()

◆ toAnimationKey() [1/3]

static QSSGSceneDesc::Animation::KeyPosition toAnimationKey ( const aiMeshMorphKey & key,
qreal freq,
uint morphId )
static

◆ toAnimationKey() [2/3]

static QSSGSceneDesc::Animation::KeyPosition toAnimationKey ( const aiQuatKey & key,
qreal freq )
static

Definition at line 1478 of file assimpimporter_rt.cpp.

References QSSGSceneDesc::Animation::KeyPosition::Quaternion, QSSGSceneDesc::Animation::KeyPosition::Time, and QVector4D::x().

+ Here is the call graph for this function:

◆ toAnimationKey() [3/3]

static QSSGSceneDesc::Animation::KeyPosition toAnimationKey ( const aiVectorKey & key,
qreal freq )
static

Definition at line 1473 of file assimpimporter_rt.cpp.

References QSSGSceneDesc::Animation::KeyPosition::Time, QSSGSceneDesc::Animation::KeyPosition::Vec3, and QVector4D::x().

Referenced by importImp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: