14#include <QRegularExpression>
15#include <QtCore/qdir.h>
16#include <QtCore/qfile.h>
17#include <QtCore/qbuffer.h>
19#include <QtGui/qimage.h>
20#include <QtGui/qimagereader.h>
22#include <QtQuick3DUtils/private/qssgmesh_p.h>
23#include <QtQuick3DUtils/private/qssgassert_p.h>
25#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
27#ifdef QT_QUICK3D_ENABLE_RT_ANIMATIONS
28#include <QtCore/QCborStreamWriter>
29#include <QtQuickTimeline/private/qquicktimeline_p.h>
34using namespace Qt::StringLiterals;
46 QVariant
getDefaultValue(QSSGSceneDesc::Node::RuntimeType type,
const char *property);
47 bool isDefaultValue(QSSGSceneDesc::Node::RuntimeType type,
const char *property,
const QVariant &value);
52 QHash<QSSGSceneDesc::Node::RuntimeType, PropertiesMap> m_properties;
57 QString nameCopy = name;
58 if (nameCopy.isEmpty())
59 return QStringLiteral(
"Presentation");
61 nameCopy = sanitizeQmlId(nameCopy);
63 if (nameCopy[0].isLower())
64 nameCopy[0] = nameCopy[0].toUpper();
71 colorString = QLatin1Char(
'\"') + color.name(QColor::HexArgb) + QLatin1Char(
'\"');
76 switch (variant.typeId()) {
77 case QMetaType::Float: {
78 auto value = variant.toDouble();
79 return QString::number(value);
81 case QMetaType::QVector2D: {
82 auto value = variant.value<QVector2D>();
83 return QString(QStringLiteral(
"Qt.vector2d(") + QString::number(
double(value.x())) +
84 QStringLiteral(
", ") + QString::number(
double(value.y())) +
87 case QMetaType::QVector3D: {
88 auto value = variant.value<QVector3D>();
89 return QString(QStringLiteral(
"Qt.vector3d(") + QString::number(
double(value.x())) +
90 QStringLiteral(
", ") + QString::number(
double(value.y())) +
91 QStringLiteral(
", ") + QString::number(
double(value.z())) +
94 case QMetaType::QVector4D: {
95 auto value = variant.value<QVector4D>();
96 return QString(QStringLiteral(
"Qt.vector4d(") + QString::number(
double(value.x())) +
97 QStringLiteral(
", ") + QString::number(
double(value.y())) +
98 QStringLiteral(
", ") + QString::number(
double(value.z())) +
99 QStringLiteral(
", ") + QString::number(
double(value.w())) +
100 QStringLiteral(
")"));
102 case QMetaType::QColor: {
103 auto value = variant.value<QColor>();
104 return colorToQml(value);
106 case QMetaType::QQuaternion: {
107 auto value = variant.value<QQuaternion>();
108 return QString(QStringLiteral(
"Qt.quaternion(") + QString::number(
double(value.scalar())) +
109 QStringLiteral(
", ") + QString::number(
double(value.x())) +
110 QStringLiteral(
", ") + QString::number(
double(value.y())) +
111 QStringLiteral(
", ") + QString::number(
double(value.z())) +
112 QStringLiteral(
")"));
115 return variant.toString();
123 if (!idCopy.isEmpty() && idCopy.at(0).isNumber())
124 idCopy.prepend(QStringLiteral(
"node"));
127 if (idCopy.startsWith(QChar::fromLatin1(
'#')))
131 static QRegularExpression regExp(QStringLiteral(
"\\W"));
132 idCopy.replace(regExp, QStringLiteral(
"_"));
136 if (!idCopy.isEmpty() && idCopy[0].isUpper()) {
139 int len = idCopy.length();
140 while (i < len && idCopy[i].isUpper()) {
141 idCopy[i] = idCopy[i].toLower();
147 static QSet<QByteArray> keywords {
243 if (keywords.contains(idCopy.toUtf8())) {
244 idCopy += QStringLiteral(
"_");
248 if (idCopy.isEmpty())
249 idCopy = QStringLiteral(
"node");
256 QString sourceCopy = source;
258 if (removeParentDirectory)
259 sourceCopy = QSSGQmlUtilities::stripParentDirectory(sourceCopy);
261 sourceCopy.replace(QChar::fromLatin1(
'\\'), QChar::fromLatin1(
'/'));
264 return QString(QStringLiteral(
"\"") + sourceCopy + QStringLiteral(
"\""));
298 auto metaObject = object->metaObject();
299 for (
auto i = 0; i < metaObject->propertyCount(); ++i) {
300 auto property = metaObject->property(i);
301 const auto name = property.name();
302 const auto value = property.read(object);
303 propertiesMap.insert(name, value);
305 return propertiesMap;
313 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Node, getObjectPropertiesMap(&node));
316 QQuick3DPrincipledMaterial principledMaterial;
317 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::PrincipledMaterial, getObjectPropertiesMap(&principledMaterial));
320 QQuick3DSpecularGlossyMaterial specularGlossyMaterial;
321 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::SpecularGlossyMaterial, getObjectPropertiesMap(&specularGlossyMaterial));
324 QQuick3DCustomMaterial customMaterial;
325 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::CustomMaterial, getObjectPropertiesMap(&customMaterial));
328 QQuick3DTexture texture;
329 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Image2D, getObjectPropertiesMap(&texture));
332 QQuick3DCubeMapTexture cubeMapTexture;
333 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::ImageCube, getObjectPropertiesMap(&cubeMapTexture));
336 QQuick3DTextureData textureData;
337 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::TextureData, getObjectPropertiesMap(&textureData));
341 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Model, getObjectPropertiesMap(&model));
344 QQuick3DOrthographicCamera orthographicCamera;
345 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::OrthographicCamera, getObjectPropertiesMap(&orthographicCamera));
348 QQuick3DPerspectiveCamera perspectiveCamera;
349 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::PerspectiveCamera, getObjectPropertiesMap(&perspectiveCamera));
352 QQuick3DDirectionalLight directionalLight;
353 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::DirectionalLight, getObjectPropertiesMap(&directionalLight));
356 QQuick3DPointLight pointLight;
357 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::PointLight, getObjectPropertiesMap(&pointLight));
360 QQuick3DSpotLight spotLight;
361 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::SpotLight, getObjectPropertiesMap(&spotLight));
364 QQuick3DSkeleton skeleton;
365 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Skeleton, getObjectPropertiesMap(&skeleton));
369 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Joint, getObjectPropertiesMap(&joint));
373 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::Skin, getObjectPropertiesMap(&skin));
376 QQuick3DMorphTarget morphTarget;
377 m_properties.insert(QSSGSceneDesc::Node::RuntimeType::MorphTarget, getObjectPropertiesMap(&morphTarget));
399template<QSSGSceneDesc::Material::RuntimeType T>
400const char *
qmlElementName() {
static_assert(!
std::is_same_v<
decltype(T),
decltype(T)>,
"Unknown type");
return nullptr; }
427 using RuntimeType = QSSGSceneDesc::Node::RuntimeType;
428 switch (node.runtimeType) {
429 case RuntimeType::Node:
430 return qmlElementName<RuntimeType::Node>();
431 case RuntimeType::PrincipledMaterial:
432 return qmlElementName<RuntimeType::PrincipledMaterial>();
433 case RuntimeType::SpecularGlossyMaterial:
434 return qmlElementName<RuntimeType::SpecularGlossyMaterial>();
435 case RuntimeType::CustomMaterial:
436 return qmlElementName<RuntimeType::CustomMaterial>();
437 case RuntimeType::Image2D:
438 return qmlElementName<RuntimeType::Image2D>();
439 case RuntimeType::ImageCube:
440 return qmlElementName<RuntimeType::ImageCube>();
441 case RuntimeType::TextureData:
442 return qmlElementName<RuntimeType::TextureData>();
443 case RuntimeType::Model:
444 return qmlElementName<RuntimeType::Model>();
445 case RuntimeType::OrthographicCamera:
446 return qmlElementName<RuntimeType::OrthographicCamera>();
447 case RuntimeType::PerspectiveCamera:
448 return qmlElementName<RuntimeType::PerspectiveCamera>();
449 case RuntimeType::DirectionalLight:
450 return qmlElementName<RuntimeType::DirectionalLight>();
451 case RuntimeType::PointLight:
452 return qmlElementName<RuntimeType::PointLight>();
453 case RuntimeType::SpotLight:
454 return qmlElementName<RuntimeType::SpotLight>();
455 case RuntimeType::Skeleton:
456 return qmlElementName<RuntimeType::Skeleton>();
457 case RuntimeType::Joint:
458 return qmlElementName<RuntimeType::Joint>();
459 case RuntimeType::Skin:
460 return qmlElementName<RuntimeType::Skin>();
461 case RuntimeType::MorphTarget:
462 return qmlElementName<RuntimeType::MorphTarget>();
463 case RuntimeType::ModelInstance:
464 return qmlElementName<RuntimeType::ModelInstance>();
466 return "UNKNOWN_TYPE";
521 case QMetaType::Bool:
523 case QMetaType::Char:
524 case QMetaType::SChar:
525 case QMetaType::UChar:
526 case QMetaType::Char16:
527 case QMetaType::Char32:
528 case QMetaType::QChar:
529 case QMetaType::Short:
530 case QMetaType::UShort:
532 case QMetaType::UInt:
533 case QMetaType::Long:
534 case QMetaType::ULong:
535 case QMetaType::LongLong:
536 case QMetaType::ULongLong:
538 case QMetaType::Float:
539 case QMetaType::Double:
541 case QMetaType::QByteArray:
542 case QMetaType::QString:
544 case QMetaType::QDate:
545 case QMetaType::QTime:
546 case QMetaType::QDateTime:
548 case QMetaType::QUrl:
550 case QMetaType::QRect:
551 case QMetaType::QRectF:
553 case QMetaType::QSize:
554 case QMetaType::QSizeF:
556 case QMetaType::QPoint:
557 case QMetaType::QPointF:
559 case QMetaType::QVariant:
561 case QMetaType::QColor:
563 case QMetaType::QMatrix4x4:
565 case QMetaType::QVector2D:
567 case QMetaType::QVector3D:
569 case QMetaType::QVector4D:
571 case QMetaType::QQuaternion:
573 case QMetaType::QFont:
590Q_GLOBAL_STATIC(UniqueIdOthers, g_idOthers)
600 g_nodeNameMap->clear();
607 static constexpr const char *typeNames[] = {
622 constexpr uint nameCount =
sizeof(typeNames)/
sizeof(
const char*);
623 const bool nodeHasName = (node.name.size() > 0);
624 uint nameIdx = qMin(uint(node.nodeType), nameCount);
625 QString name = nodeHasName ? QString::fromUtf8(node.name + typeNames[nameIdx]) : QString::fromLatin1(getQmlElementName(node));
626 QString sanitizedName = QSSGQmlUtilities::sanitizeQmlId(name);
629 if (
const auto it = g_nodeNameMap->constFind(&node); it != g_nodeNameMap->constEnd())
632 quint64 id = node.id;
634 QString candidate = sanitizedName;
636 if (
const auto it = g_idMap->constFind(candidate); it == g_idMap->constEnd()) {
637 g_idMap->insert(candidate, &node);
638 g_nodeNameMap->insert(&node, candidate);
642 candidate = QStringLiteral(
"%1%2").arg(sanitizedName).arg(id++);
643 }
while (--attempts);
650 QString name = !inName.isEmpty() ? QString::fromUtf8(inName +
"_timeline") :
"timeline0"_L1;
651 QString sanitizedName = QSSGQmlUtilities::sanitizeQmlId(name);
655 QString candidate = sanitizedName;
657 if (
const auto it = g_idMap->constFind(candidate); it == g_idMap->constEnd()) {
658 if (
const auto oIt = g_idOthers->constFind(candidate); oIt == g_idOthers->constEnd()) {
659 g_idOthers->insert(candidate);
664 candidate = QStringLiteral(
"%1%2").arg(sanitizedName).arg(++id);
665 }
while (--attempts);
671 QString sourceCopy = filePath;
672 while (sourceCopy.startsWith(QChar::fromLatin1(
'.')) || sourceCopy.startsWith(QChar::fromLatin1(
'/')) || sourceCopy.startsWith(QChar::fromLatin1(
'\\')))
673 sourceCopy.remove(0, 1);
680 if (path.startsWith(u':')) {
682 url.setScheme(u"qrc"_s);
683 url.setPath(path.mid(1));
692static const char *
indent() {
return " "; }
706 str += QString::fromLatin1(indent());
714 return output.stream;
725 output.scopeDepth = qMax(0, output.scopeDepth - 1);
731 output.stream <<
"import QtQuick\n"
732 <<
"import QtQuick3D\n\n";
734 output.stream <<
"import QtQuick.Timeline\n\n";
737static QString
toQuotedString(
const QString &text) {
return QStringLiteral(
"\"%1\"").arg(text); }
744 const auto meshFolder = getMeshFolder();
745 const auto extension = getMeshExtension();
747 return QString(meshFolder + name + extension);
756 const auto animationFolder = getAnimationFolder();
757 const auto extension = getAnimationExtension();
758 return QString(animationFolder + id + QStringLiteral(
"_")
759 + property + QStringLiteral(
"_")
760 + QString::number(index) + extension);
765 return var.toString();
770 switch (var.metaType().id()) {
771 case QMetaType::QVector2D: {
772 const auto vec2 = qvariant_cast<
QVector2D>(var);
773 return QLatin1String(
"Qt.vector2d(") + QString::number(vec2.x()) + QLatin1String(
", ") + QString::number(vec2.y()) + QLatin1Char(
')');
775 case QMetaType::QVector3D: {
776 const auto vec3 = qvariant_cast<
QVector3D>(var);
777 return QLatin1String(
"Qt.vector3d(") + QString::number(vec3.x()) + QLatin1String(
", ")
778 + QString::number(vec3.y()) + QLatin1String(
", ")
779 + QString::number(vec3.z()) + QLatin1Char(
')');
781 case QMetaType::QVector4D: {
782 const auto vec4 = qvariant_cast<
QVector4D>(var);
783 return QLatin1String(
"Qt.vector4d(") + QString::number(vec4.x()) + QLatin1String(
", ")
784 + QString::number(vec4.y()) + QLatin1String(
", ")
785 + QString::number(vec4.z()) + QLatin1String(
", ")
786 + QString::number(vec4.w()) + QLatin1Char(
')');
788 case QMetaType::QColor: {
789 const auto color = qvariant_cast<QColor>(var);
790 return colorToQml(color);
792 case QMetaType::QQuaternion: {
793 const auto &quat = qvariant_cast<QQuaternion>(var);
794 return QLatin1String(
"Qt.quaternion(") + QString::number(quat.scalar()) + QLatin1String(
", ")
795 + QString::number(quat.x()) + QLatin1String(
", ")
796 + QString::number(quat.y()) + QLatin1String(
", ")
797 + QString::number(quat.z()) + QLatin1Char(
')');
799 case QMetaType::QMatrix4x4: {
800 const auto mat44 = qvariant_cast<QMatrix4x4>(var);
801 return QLatin1String(
"Qt.matrix4x4(")
802 + QString::number(mat44(0, 0)) + u", " + QString::number(mat44(0, 1)) + u", " + QString::number(mat44(0, 2)) + u", " + QString::number(mat44(0, 3)) + u", "
803 + QString::number(mat44(1, 0)) + u", " + QString::number(mat44(1, 1)) + u", " + QString::number(mat44(1, 2)) + u", " + QString::number(mat44(1, 3)) + u", "
804 + QString::number(mat44(2, 0)) + u", " + QString::number(mat44(2, 1)) + u", " + QString::number(mat44(2, 2)) + u", " + QString::number(mat44(2, 3)) + u", "
805 + QString::number(mat44(3, 0)) + u", " + QString::number(mat44(3, 1)) + u", " + QString::number(mat44(3, 2)) + u", " + QString::number(mat44(3, 3)) + u')';
807 case QMetaType::Float:
808 case QMetaType::Double:
810 case QMetaType::Char:
811 case QMetaType::Long:
812 case QMetaType::LongLong:
813 case QMetaType::ULong:
814 case QMetaType::ULongLong:
815 case QMetaType::Bool:
816 return var.toString();
817 case QMetaType::QUrl:
828 return QStringLiteral(
"position");
830 return QStringLiteral(
"rotation");
832 return QStringLiteral(
"scale");
834 return QStringLiteral(
"weight");
836 return QStringLiteral(
"unknown");
843 const auto meshFolder = getMeshFolder();
844 const auto meshId = QSSGQmlUtilities::getIdForNode(meshNode);
845 const auto meshSourceName = QSSGQmlUtilities::getMeshSourceName(meshId);
846 Q_ASSERT(scene.meshStorage.size() > meshNode.idx);
847 const auto &mesh = scene.meshStorage.at(meshNode.idx);
850 if (!outdir.exists(meshFolder) && !outdir.mkdir(meshFolder)) {
851 qDebug() <<
"Failed to create meshes folder at" << outdir;
855 const QString path = outdir.path() + QDir::separator() + meshSourceName;
857 if (!file.open(QIODevice::WriteOnly)) {
858 return {QString(), QStringLiteral(
"Failed to find mesh at ") + path};
861 if (mesh.save(&file) == 0) {
865 return {meshSourceName, QString()};
873 QString assetPath = output.outdir.isAbsolutePath(texturePath.path()) ? texturePath.toString() : texturePath.path();
874 QFileInfo fi(assetPath);
875 if (fi.isRelative() && !output.sourceDir.isEmpty()) {
876 fi = QFileInfo(output.sourceDir + QChar(u'/') + assetPath);
879 indent(output) << comment() <<
"Source texture path expected: " << getTextureFolder() + texturePath.fileName() <<
"\n";
880 return {QString(), QStringLiteral(
"Failed to find texture at ") + assetPath};
883 const auto mapsFolder = getTextureFolder();
885 if (!output.outdir.exists(mapsFolder) && !output.outdir.mkdir(mapsFolder)) {
886 qDebug() <<
"Failed to create maps folder at" << output.outdir;
890 const QString relpath = mapsFolder + fi.fileName();
891 const auto newfilepath = QString(output.outdir.canonicalPath() + QDir::separator() + relpath);
892 if (!QFile::exists(newfilepath) && !QFile::copy(fi.canonicalFilePath(), newfilepath)) {
893 qDebug() <<
"Failed to copy file from" << fi.canonicalFilePath() <<
"to" << newfilepath;
897 return {relpath, QString()};
902 static const QRegularExpression re(QLatin1String(
"^Qt.[a-z0-9]*\\(([0-9.e\\+\\-, ]*)\\)"));
903 Q_ASSERT(re.isValid());
906 case QMetaType::QVector2D: {
907 QRegularExpressionMatch match = re.match(value);
908 if (match.hasMatch()) {
909 const auto comp = match.captured(1).split(QLatin1Char(
','));
910 if (comp.size() == 2) {
911 return { QLatin1String(
".x: ") + comp.at(0).trimmed(),
912 QLatin1String(
".y: ") + comp.at(1).trimmed() };
917 case QMetaType::QVector3D: {
918 QRegularExpressionMatch match = re.match(value);
919 if (match.hasMatch()) {
920 const auto comp = match.captured(1).split(QLatin1Char(
','));
921 if (comp.size() == 3) {
922 return { QLatin1String(
".x: ") + comp.at(0).trimmed(),
923 QLatin1String(
".y: ") + comp.at(1).trimmed(),
924 QLatin1String(
".z: ") + comp.at(2).trimmed() };
929 case QMetaType::QVector4D: {
930 QRegularExpressionMatch match = re.match(value);
931 if (match.hasMatch()) {
932 const auto comp = match.captured(1).split(QLatin1Char(
','));
933 if (comp.size() == 4) {
934 return { QLatin1String(
".x: ") + comp.at(0).trimmed(),
935 QLatin1String(
".y: ") + comp.at(1).trimmed(),
936 QLatin1String(
".z: ") + comp.at(2).trimmed(),
937 QLatin1String(
".w: ") + comp.at(3).trimmed() };
942 case QMetaType::QQuaternion: {
943 QRegularExpressionMatch match = re.match(value);
944 if (match.hasMatch()) {
945 const auto comp = match.captured(1).split(QLatin1Char(
','));
946 if (comp.size() == 4) {
947 return { QLatin1String(
".x: ") + comp.at(0).trimmed(),
948 QLatin1String(
".y: ") + comp.at(1).trimmed(),
949 QLatin1String(
".z: ") + comp.at(2).trimmed(),
950 QLatin1String(
".scalar: ") + comp.at(3).trimmed() };
965 if (mt.id() != QMetaType::QQuaternion)
966 return expandComponents(value, mt);
983 if (property.value.isNull()) {
985 result.notValidReason = QStringLiteral(
"Property value is null");
989 const QVariant &value = property.value;
990 result.name = QString::fromUtf8(property.name);
994 QString valueAsString = builtinQmlType(value);
995 if (valueAsString.size() > 0) {
996 result.value = valueAsString;
998 }
else if (value.metaType().flags() & (QMetaType::IsEnumeration | QMetaType::IsUnsignedEnumeration)) {
999 static const auto qmlEnumString = [](
const QLatin1String &element,
const QString &enumString) {
1000 return QStringLiteral(
"%1.%2").arg(element).arg(enumString);
1003 QString enumValue = asString(value);
1004 if (enumValue.size() > 0) {
1005 result.value = qmlEnumString(qmlElementName, enumValue);
1009 QByteArray element(getQmlElementName(target));
1010 if (element.size() > 0) {
1012 QByteArray keysString = flag.me.valueToKeys(
int(flag.value));
1013 if (keysString.size() > 0) {
1014 keysString.prepend(element +
'.');
1015 QByteArray replacement(
" | " + element +
'.');
1016 keysString.replace(
'|', replacement);
1017 result.value = QString::fromLatin1(keysString);
1023 if (list->count > 0) {
1024 const QString indentStr = indentString(output);
1026 const QString listIndentStr = indentString(output);
1031 for (
int i = 0, end = list->count; i != end; ++i) {
1034 str.append(listIndentStr);
1035 str.append(getIdForNode(*(list->head[i])));
1038 str.append(u'\n' + indentStr + u']');
1045 if (list.count > 0) {
1046 const QString indentStr = indentString(output);
1048 const QString listIndentStr = indentString(output);
1053 char *vptr =
reinterpret_cast<
char *>(list.data);
1054 auto size = list.mt.sizeOf();
1056 for (
int i = 0, end = list.count; i != end; ++i) {
1060 const QVariant var{list.mt,
reinterpret_cast<
void *>(vptr + (size * i))};
1061 QString valueString = builtinQmlType(var);
1062 if (valueString.isEmpty())
1063 valueString = asString(var);
1065 str.append(listIndentStr);
1066 str.append(valueString);
1069 str.append(u'\n' + indentStr + u']');
1074 }
else if (value.metaType().id() == qMetaTypeId<
QSSGSceneDesc::Node *>()) {
1075 if (
const auto node = qvariant_cast<QSSGSceneDesc::Node *>(value)) {
1079 Q_ASSERT(node->id != 0);
1083 if (node->runtimeType == QSSGSceneDesc::Node::RuntimeType::TextureData) {
1084 result.name = QStringLiteral(
"source");
1085 result.value = getIdForNode(*node->scene->root) + QLatin1Char(
'.') + getIdForNode(*node);
1087 result.value = getIdForNode(*node);
1091 }
else if (value.metaType() == QMetaType::fromType<QSSGSceneDesc::Mesh *>()) {
1092 if (
const auto meshNode = qvariant_cast<
const QSSGSceneDesc::Mesh *>(value)) {
1093 Q_ASSERT(meshNode->nodeType == QSSGSceneDesc::Node::Type::Mesh);
1094 Q_ASSERT(meshNode->scene);
1095 const auto &scene = *meshNode->scene;
1096 const auto& [meshSourceName, notValidReason] = meshAssetName(scene, *meshNode, output.outdir);
1097 result.notValidReason = notValidReason;
1098 if (!meshSourceName.isEmpty()) {
1099 result.value = toQuotedString(meshSourceName);
1103 }
else if (value.metaType() == QMetaType::fromType<QUrl>()) {
1104 if (
const auto url = qvariant_cast<QUrl>(value); !url.isEmpty()) {
1107 if (QSSGRenderGraphObject::isTexture(target.runtimeType)) {
1108 const auto& [relpath, notValidReason] = copyTextureAsset(url, output);
1109 result.notValidReason = notValidReason;
1110 if (!relpath.isEmpty()) {
1116 if (!path.isEmpty()) {
1117 result.value = toQuotedString(path);
1121 }
else if (target.runtimeType == QSSGSceneDesc::Material::RuntimeType::CustomMaterial) {
1123 if (value.metaType().id() == qMetaTypeId<QSSGSceneDesc::Texture *>()) {
1124 if (
const auto texture = qvariant_cast<QSSGSceneDesc::Texture *>(value)) {
1125 Q_ASSERT(QSSGRenderGraphObject::isTexture(texture->runtimeType));
1126 result.value = QLatin1String(
"TextureInput { texture: ") +
1127 getIdForNode(*texture) + QLatin1String(
" }");
1131 }
else if (value.metaType() == QMetaType::fromType<QString>()) {
1133 result.value = toQuotedString(value.toString());
1136 result.notValidReason = QStringLiteral(
"Unsupported value type: ") + QString::fromUtf8(value.metaType().name());
1137 qWarning() << result.notValidReason;
1142 result.expandedProperties = ((output.options & OutputContext::Options::DesignStudioWorkarounds) == OutputContext::Options::DesignStudioWorkarounds)
1143 ? expandComponentsPartially(result.value, value.metaType())
1144 : expandComponents(result.value, value.metaType());
1151 const char *skipProperty =
nullptr)
1155 indent(output) << u"id: "_s << getIdForNode(node) << u'\n';
1158 if (node.name.size()) {
1159 const QString objectName = QString::fromLocal8Bit(node.name);
1160 if (!objectName.startsWith(u'*'))
1161 indent(output) << u"objectName: \""_s << node.name << u"\"\n"_s;
1164 const auto &properties = node.properties;
1165 auto it = properties.begin();
1166 const auto end = properties.end();
1167 for (; it != end; ++it) {
1168 const auto &property = *it;
1169 if (skipProperty && qstrcmp(property->name, skipProperty) == 0)
1175 indent(output) <<
"property " << typeName(property->value.metaType()).toByteArray() <<
' ' << result.name << u": "_s << result.value << u'\n';
1177 if (result.expandedProperties.size() > 1) {
1178 for (
const auto &va : result.expandedProperties)
1179 indent(output) << result.name << va << u'\n';
1181 indent(output) << result.name << u": "_s << result.value << u'\n';
1185 QString message = u"Skipped property: "_s + QString::fromUtf8(property->name);
1186 if (!result.notValidReason.isEmpty())
1187 message.append(u", reason: "_s + result.notValidReason);
1188 qDebug() << message;
1197 Q_ASSERT(transform.nodeType == QSSGSceneDesc::Node::Type::Transform && transform.runtimeType == QSSGSceneDesc::Node::RuntimeType::Node);
1198 indent(output) << qmlElementName<QSSGSceneDesc::Node::RuntimeType::Node>() << blockBegin(output);
1205 Q_ASSERT(material.nodeType == QSSGSceneDesc::Model::Type::Material);
1206 if (material.runtimeType == QSSGSceneDesc::Model::RuntimeType::SpecularGlossyMaterial) {
1207 indent(output) << qmlElementName<Material::RuntimeType::SpecularGlossyMaterial>() << blockBegin(output);
1208 }
else if (material.runtimeType == Model::RuntimeType::PrincipledMaterial) {
1209 indent(output) << qmlElementName<Material::RuntimeType::PrincipledMaterial>() << blockBegin(output);
1210 }
else if (material.runtimeType == Material::RuntimeType::CustomMaterial) {
1211 indent(output) << qmlElementName<Material::RuntimeType::CustomMaterial>() << blockBegin(output);
1212 }
else if (material.runtimeType == Material::RuntimeType::SpecularGlossyMaterial) {
1213 indent(output) << qmlElementName<Material::RuntimeType::SpecularGlossyMaterial>() << blockBegin(output);
1218 writeNodeProperties(material, output);
1223 QString escaped = value;
1224 escaped.replace(u'\\', u"\\\\"_s);
1225 escaped.replace(u'"', u"\\\""_s);
1226 escaped.replace(u'\n', u"\\n"_s);
1227 escaped.replace(u'\r', u"\\r"_s);
1228 return u'"' + escaped + u'"';
1234 Q_ASSERT(model.nodeType == Node::Type::Model);
1235 indent(output) << qmlElementName<QSSGSceneDesc::Node::RuntimeType::Model>() << blockBegin(output);
1236 const bool hasVariants = !model.variantMaterials.isEmpty() && model.scene
1237 && !model.scene->materialVariants.isEmpty();
1238 writeNodeProperties(model, output, hasVariants ?
"materials" :
nullptr);
1241 const auto materialListString = [](
const QList<Node *> &materials) {
1243 for (
const Node *material : materials)
1244 ids.append(getIdForNode(*material));
1245 return u'[' + ids.join(u", "_s) + u']';
1248 const QStringList &names = model.scene->materialVariants;
1249 const QString rootId = getIdForNode(*model.scene->root);
1250 for (qsizetype variant = 0; variant < model.variantMaterials.size() && variant < names.size(); ++variant) {
1251 expression += rootId + u".materialVariant === "_s + toQmlStringLiteral(names.at(variant)) + u" ? "_s
1252 + materialListString(model.variantMaterials.at(variant)) + u" : "_s;
1254 expression += materialListString(model.defaultMaterials);
1256 indent(output) << u"materials: "_s << expression << u'\n';
1263 Q_ASSERT(camera.nodeType == Node::Type::Camera);
1264 if (camera.runtimeType == Camera::RuntimeType::PerspectiveCamera)
1265 indent(output) << qmlElementName<Camera::RuntimeType::PerspectiveCamera>() << blockBegin(output);
1266 else if (camera.runtimeType == Camera::RuntimeType::OrthographicCamera)
1267 indent(output) << qmlElementName<Camera::RuntimeType::OrthographicCamera>() << blockBegin(output);
1270 writeNodeProperties(camera, output);
1276 Q_ASSERT(texture.nodeType == Node::Type::Texture && QSSGRenderGraphObject::isTexture(texture.runtimeType));
1277 if (texture.runtimeType == Texture::RuntimeType::Image2D)
1278 indent(output) << qmlElementName<Texture::RuntimeType::Image2D>() << blockBegin(output);
1279 else if (texture.runtimeType == Texture::RuntimeType::ImageCube)
1280 indent(output) << qmlElementName<Texture::RuntimeType::ImageCube>() << blockBegin(output);
1281 writeNodeProperties(texture, output);
1287 Q_ASSERT(skin.nodeType == Node::Type::Skin && skin.runtimeType == Node::RuntimeType::Skin);
1288 indent(output) << qmlElementName<Node::RuntimeType::Skin>() << blockBegin(output);
1289 writeNodeProperties(skin, output);
1295 Q_ASSERT(morphTarget.nodeType == Node::Type::MorphTarget);
1296 indent(output) << qmlElementName<QSSGSceneDesc::Node::RuntimeType::MorphTarget>() << blockBegin(output);
1297 writeNodeProperties(morphTarget, output);
1302 const auto textureFolder = getTextureFolder();
1304 const auto sanitizedName = QSSGQmlUtilities::sanitizeQmlId(name);
1306 const auto ext = (fmt.isEmpty() || fmt.length() > 4) ? u".png"_s
1309 return QString(textureFolder + sanitizedName + ext);
1314 if (textureData.data.isEmpty())
1317 const auto mapsFolder = getTextureFolder();
1318 const auto id = getIdForNode(textureData);
1319 const bool isCompressed = ((textureData.flgs & quint8(QSSGSceneDesc::TextureData::Flags::Compressed)) != 0);
1320 const QString textureSourceName = getTextureSourceName(id, isCompressed ? QString::fromUtf8(textureData.fmt)
1324 if (!outdir.exists(mapsFolder) && !outdir.mkdir(mapsFolder))
1327 const auto imagePath = QString(outdir.path() + QDir::separator() + textureSourceName);
1330 QFile file(imagePath);
1331 if (!file.open(QIODevice::WriteOnly)) {
1332 qWarning(
"Failed to open file %s: %s",
1333 qPrintable(file.fileName()), qPrintable(file.errorString()));
1336 file.write(textureData.data);
1340 const auto &texData = textureData.data;
1341 const auto &size = textureData.sz;
1343 image = QImage(
reinterpret_cast<
const uchar *>(texData.data()), size.width(), size.height(), QImage::Format::Format_RGBA8888);
1344 if (!image.save(imagePath))
1348 return textureSourceName;
1354 Q_ASSERT(textureData.nodeType == Node::Type::Texture && textureData.runtimeType == Node::RuntimeType::TextureData);
1356 QString textureSourcePath = outputTextureAsset(textureData, output.outdir);
1358 static const auto writeProperty = [](
const QString &type,
const QString &name,
const QString &value) {
1359 return QString::fromLatin1(
"property %1 %2: %3").arg(type, name, value);
1362 if (!textureSourcePath.isEmpty()) {
1363 const auto type = QLatin1String(
"url");
1364 const auto name = getIdForNode(textureData);
1366 indent(output
) << writeProperty(type, name, toQuotedString(textureSourcePath)) <<
'\n';
1374 const QString folder = getInstancesFolder();
1375 if (!outdir.exists(folder) && !outdir.mkdir(folder)) {
1376 qWarning() <<
"Failed to create instances folder at" << outdir;
1379 const QString sourceName = folder + getIdForNode(instancing) + QStringLiteral(
".bin");
1380 QFile file(outdir.path() + QDir::separator() + sourceName);
1381 if (!file.open(QIODevice::WriteOnly)) {
1382 qWarning(
"Failed to open file %s: %s", qPrintable(file.fileName()), qPrintable(file.errorString()));
1385 if (!QQuick3DFileInstancing::writeInstanceTable(&file, instancing.instanceData,
int(instancing.instanceCount)))
1393 Q_ASSERT(instancing.nodeType == Node::Type::Instancing
1394 && instancing.runtimeType == Node::RuntimeType::ModelInstance);
1396 const QString instanceSourcePath = outputInstanceTableAsset(instancing, output.outdir);
1398 indent(output) << qmlElementName<Node::RuntimeType::ModelInstance>() << blockBegin(output);
1399 writeNodeProperties(instancing, output);
1400 if (!instanceSourcePath.isEmpty()) {
1402 indent(output) << u"source: "_s << toQuotedString(instanceSourcePath) << u'\n';
1409 Q_ASSERT(light.nodeType == Node::Type::Light);
1410 if (light.runtimeType == Light::RuntimeType::DirectionalLight)
1411 indent(output) << qmlElementName<Light::RuntimeType::DirectionalLight>() << blockBegin(output);
1412 else if (light.runtimeType == Light::RuntimeType::SpotLight)
1413 indent(output) << qmlElementName<Light::RuntimeType::SpotLight>() << blockBegin(output);
1414 else if (light.runtimeType == Light::RuntimeType::PointLight)
1415 indent(output) << qmlElementName<Light::RuntimeType::PointLight>() << blockBegin(output);
1418 writeNodeProperties(light, output);
1424 Q_ASSERT(skeleton.nodeType == Node::Type::Skeleton && skeleton.runtimeType == Node::RuntimeType::Skeleton);
1425 indent(output) << qmlElementName<Node::RuntimeType::Skeleton>() << blockBegin(output);
1426 writeNodeProperties(skeleton, output);
1432 Q_ASSERT(joint.nodeType == Node::Type::Joint && joint.runtimeType == Node::RuntimeType::Joint);
1433 indent(output) << qmlElementName<Node::RuntimeType::Joint>() << blockBegin(output);
1434 writeNodeProperties(joint, output);
1441 Q_ASSERT(QSSGRenderGraphObject::isResource(node.runtimeType) || node.nodeType == Node::Type::Mesh || node.nodeType == Node::Type::Skeleton);
1446 switch (node.nodeType) {
1447 case Node::Type::Skin:
1450 case Node::Type::MorphTarget:
1453 case Node::Type::Instancing:
1456 case Node::Type::Skeleton:
1459 case Node::Type::Texture:
1460 if (node.runtimeType == Node::RuntimeType::Image2D)
1462 else if (node.runtimeType == Node::RuntimeType::ImageCube)
1464 else if (node.runtimeType == Node::RuntimeType::TextureData)
1469 case Node::Type::Material:
1472 case Node::Type::Mesh:
1476 qWarning(
"Unhandled resource type \'%d\'?",
int(node.runtimeType));
1483 const bool skipBlockEnd = (node.runtimeType == Node::RuntimeType::TextureData || node.nodeType == Node::Type::Mesh);
1484 if (!skipBlockEnd && processNode && output.scopeDepth != 0) {
1494 const bool processNode = !(node.properties.isEmpty() && node.children.isEmpty())
1498 switch (node.nodeType) {
1499 case Node::Type::Skeleton:
1502 case Node::Type::Joint:
1505 case Node::Type::Light:
1508 case Node::Type::Transform:
1511 case Node::Type::Camera:
1514 case Node::Type::Model:
1522 for (
const auto &cld : node.children) {
1523 if (!QSSGRenderGraphObject::isResource(cld->runtimeType) && output.type == OutputContext::NodeTree) {
1524 QSSGQmlScopedIndent scopedIndent(output);
1525 writeQmlForNode(*cld, output);
1531 const bool skipBlockEnd = (node.runtimeType == Node::RuntimeType::TextureData || node.nodeType == Node::Type::Mesh);
1532 if (!skipBlockEnd && processNode && output.scopeDepth != 0) {
1540 auto sortedResources = resources;
1541 std::sort(sortedResources.begin(), sortedResources.end(), [](
const QSSGSceneDesc::Node *a,
const QSSGSceneDesc::Node *b) {
1542 using RType = QSSGSceneDesc::Node::RuntimeType;
1543 if (a->runtimeType == RType::TextureData && b->runtimeType != RType::TextureData)
1545 if (a->runtimeType == RType::ImageCube && (b->runtimeType != RType::TextureData && b->runtimeType != RType::ImageCube))
1547 if (a->runtimeType == RType::Image2D && (b->runtimeType != RType::TextureData && b->runtimeType != RType::Image2D))
1552 for (
const auto &res : std::as_const(sortedResources))
1553 writeQmlForResourceNode(*res, output);
1558#ifdef QT_QUICK3D_ENABLE_RT_ANIMATIONS
1559 QCborStreamWriter writer(&keyframeData);
1561 writer.startArray();
1563 writer.append(
"QTimelineKeyframes");
1565 const int keyframesDataVersion = 1;
1566 writer.append(keyframesDataVersion);
1567 writer.append(
int(channel.keys.at(0)->getValueQMetaType()));
1570 writer.startArray();
1571 quint8 compEnd = quint8(channel.keys.at(0)->getValueType());
1572 bool isQuaternion =
false;
1573 if (compEnd == quint8(QSSGSceneDesc::Animation::KeyPosition::ValueType::Quaternion)) {
1574 isQuaternion =
true;
1579 for (
const auto &key : channel.keys) {
1580 writer.append(key->time);
1582 writer.append(QEasingCurve::Linear);
1584 writer.append(key->value[3]);
1585 for (quint8 i = 0; i < compEnd; ++i)
1586 writer.append(key->value[i]);
1594 Q_UNUSED(keyframeData)
1604 const int duration = qCeil(anim
.length);
1606 const QString animationId = getIdForAnimation(anim.name);
1607 indent(output
) <<
"id: " << animationId <<
"\n";
1608 QString animationName = animationId;
1609 if (!anim.name.isEmpty())
1610 animationName = QString::fromLocal8Bit(anim.name);
1611 indent(output
) <<
"objectName: \"" << animationName <<
"\"\n";
1613 indent(output
) <<
"startFrame: 0\n";
1614 indent(output
) <<
"endFrame: " << duration <<
"\n";
1615 indent(output
) <<
"currentFrame: 0\n";
1619 if (generateTimelineAnimations) {
1620 indent(output
) <<
"enabled: true\n";
1621 indent(output
) <<
"animations: TimelineAnimation {\n";
1624 indent(output
) <<
"duration: " << duration <<
"\n";
1626 indent(output
) <<
"to: " << duration <<
"\n";
1627 indent(output
) <<
"running: true\n";
1628 indent(output
) <<
"loops: Animation.Infinite\n";
1633 for (
const auto &channel : anim.channels) {
1634 QString id = getIdForNode(*channel->target);
1635 QString propertyName = asString(channel->targetProperty);
1637 indent(output) <<
"KeyframeGroup {\n";
1639 QSSGQmlScopedIndent scopedIndent(output);
1640 indent(output) <<
"target: " << id <<
"\n";
1641 indent(output) <<
"property: " << toQuotedString(propertyName) <<
"\n";
1642 if (useBinaryKeyframes && channel->keys.size() != 1) {
1643 const auto animFolder = getAnimationFolder();
1644 const auto animSourceName = getAnimationSourceName(id, propertyName, index);
1645 if (!output.outdir.exists(animFolder) && !output.outdir.mkdir(animFolder)) {
1649 QFile file(output.outdir.path() + QDir::separator() + animSourceName);
1650 if (!file.open(QIODevice::WriteOnly))
1652 QByteArray keyframeData;
1656 generateKeyframeData(*channel, keyframeData);
1657 file.write(keyframeData);
1659 indent(output) <<
"keyframeSource: " << toQuotedString(animSourceName) <<
"\n";
1661 Q_ASSERT(!channel->keys.isEmpty());
1662 for (
const auto &key : std::as_const(channel->keys)) {
1663 indent(output) <<
"Keyframe {\n";
1665 QSSGQmlScopedIndent scopedIndent(output);
1666 indent(output) <<
"frame: " << key->time <<
"\n";
1667 indent(output) <<
"value: " << variantToQml(key->getValue()) <<
"\n";
1669 indent(output) << blockEnd(output);
1673 indent(output) << blockEnd(output);
1675 return {animationName, animationId};
1678void writeQml(
const QSSGSceneDesc::Scene &scene, QTextStream &stream,
const QDir &outdir,
const QJsonObject &optionsObject)
1680 static const auto checkBooleanOption = [](
const QLatin1String &optionName,
const QJsonObject &options,
bool defaultValue =
false) {
1681 const auto it = options.constFind(optionName);
1682 const auto end = options.constEnd();
1686 value = it->toObject().value(QLatin1String(
"value"));
1690 return value.toBool(defaultValue);
1693 auto root = scene.root;
1698 QJsonObject options = optionsObject;
1700 if (
auto it = options.constFind(QLatin1String(
"options")), end = options.constEnd(); it != end)
1701 options = it->toObject();
1704 if (checkBooleanOption(QLatin1String(
"expandValueComponents"), options))
1708 if (checkBooleanOption(QLatin1String(
"designStudioWorkarounds"), options))
1711 const bool useBinaryKeyframes = checkBooleanOption(
"useBinaryKeyframes"_L1, options);
1712 const bool generateTimelineAnimations = !checkBooleanOption(
"manualAnimations"_L1, options);
1716 writeImportHeader(output, scene.animations.count() > 0);
1719 writeQml(*root, output);
1721 if (!scene.materialVariants.isEmpty()) {
1724 QStringList variantNames;
1725 for (
const QString &name : scene.materialVariants)
1726 variantNames.append(toQmlStringLiteral(name));
1727 indent(output
) << u"property string materialVariant: \"\"\n"_s;
1728 indent(output) << u"readonly property list<string> materialVariants: ["_s << variantNames.join(u", "_s)
1733 stream <<
indent() <<
"// Resources\n";
1735 writeQmlForResources(scene.resources, output);
1738 stream <<
indent() <<
"// Nodes:\n";
1739 for (
const auto &cld : std::as_const(root->children))
1740 writeQmlForNode(*cld, output);
1743 qsizetype animId = 0;
1745 stream <<
indent() <<
"// Animations:\n";
1746 QList<QPair<QString, QString>> animationMap;
1747 for (
const auto &cld : scene.animations) {
1748 QSSGQmlScopedIndent scopedIndent(output);
1749 auto mapValues = writeQmlForAnimation(*cld, animId++, output, useBinaryKeyframes, generateTimelineAnimations);
1750 animationMap.append(mapValues);
1751 indent(output) << blockEnd(output);
1754 if (!generateTimelineAnimations) {
1757 stream <<
indent() <<
"// An exported mapping of Timelines (--manualAnimations)\n";
1758 stream <<
indent() <<
"property var timelineMap: {\n";
1760 for (
const auto &mapValues : animationMap) {
1761 QSSGQmlScopedIndent scopedIndent(output);
1762 indent(output) <<
"\"" << mapValues.first <<
"\": " << mapValues.second <<
",\n";
1765 stream <<
indent() <<
"// A simple list of Timelines (--manualAnimations)\n";
1766 stream <<
indent() <<
"property var timelineList: [\n";
1767 for (
const auto &mapValues : animationMap) {
1768 QSSGQmlScopedIndent scopedIndent(output);
1769 indent(output) << mapValues.second <<
",\n";
1781#ifdef QT_QUICK3D_ENABLE_RT_ANIMATIONS
1782 auto timeline =
new QQuickTimeline(parent);
1783 auto timelineKeyframeGroup = timeline->keyframeGroups();
1784 for (
const auto &channel : anim.channels) {
1785 auto keyframeGroup =
new QQuickKeyframeGroup(timeline);
1786 keyframeGroup->setTargetObject(channel->target->obj);
1787 keyframeGroup->setProperty(asString(channel->targetProperty));
1789 Q_ASSERT(!channel->keys.isEmpty());
1790 if (useBinaryKeyframes) {
1791 QByteArray keyframeData;
1792 generateKeyframeData(*channel, keyframeData);
1794 keyframeGroup->setKeyframeData(keyframeData);
1796 auto keyframes = keyframeGroup->keyframes();
1797 for (
const auto &key : std::as_const(channel->keys)) {
1798 auto keyframe =
new QQuickKeyframe(keyframeGroup);
1799 keyframe->setFrame(key->time);
1800 keyframe->setValue(key->getValue());
1801 keyframes.append(&keyframes, keyframe);
1804 (qobject_cast<QQmlParserStatus *>(keyframeGroup))->componentComplete();
1805 timelineKeyframeGroup.append(&timelineKeyframeGroup, keyframeGroup);
1807 timeline->setEndFrame(anim.length);
1808 timeline->setEnabled(isEnabled);
1810 auto timelineAnimation =
new QQuickTimelineAnimation(timeline);
1811 timelineAnimation->setObjectName(anim.name);
1812 timelineAnimation->setDuration(
int(anim.length));
1813 timelineAnimation->setFrom(0.0f);
1814 timelineAnimation->setTo(anim.length);
1815 timelineAnimation->setLoops(QQuickTimelineAnimation::Infinite);
1816 timelineAnimation->setTargetObject(timeline);
1818 (qobject_cast<QQmlParserStatus *>(timeline))->componentComplete();
1820 timelineAnimation->setRunning(
true);
1825 Q_UNUSED(useBinaryKeyframes)
1833 QSSG_ASSERT(node.scene !=
nullptr,
return);
1837 if (node.runtimeType == Material::RuntimeType::CustomMaterial) {
1838 QString sourceDir = node.scene->sourceDir;
1843 const auto &resources = node.scene->resources;
1844 writeQmlForResources(resources, output);
bool isDefaultValue(QSSGSceneDesc::Node::RuntimeType type, const char *property, const QVariant &value)
PropertiesMap propertiesForType(QSSGSceneDesc::Node::RuntimeType type)
static PropertyMap * instance()
QVariant getDefaultValue(QSSGSceneDesc::Node::RuntimeType type, const char *property)
QHash< QByteArray, QVariant > PropertiesMap
The QVector2D class represents a vector or vertex in 2D space.
The QVector3D class represents a vector or vertex in 3D space.
The QVector4D class represents a vector or vertex in 4D space.
static QString getInstancesFolder()
static const char * blockEnd()
static constexpr QByteArrayView qml_basic_types[]
QString builtinQmlType(const QVariant &var)
static void generateKeyframeData(const QSSGSceneDesc::Animation::Channel &channel, QByteArray &keyframeData)
void writeQmlComponent(const QSSGSceneDesc::Node &node, QTextStream &stream, const QDir &outDir)
static QString getIdForNode(const QSSGSceneDesc::Node &node)
QString asString(const QVariant &var)
static void writeNodeProperties(const QSSGSceneDesc::Node &node, OutputContext &output, const char *skipProperty=nullptr)
static QString getTextureFolder()
QString qmlComponentName(const QString &name)
static PropertyMap::PropertiesMap getObjectPropertiesMap(QObject *object)
static QString getAnimationFolder()
static QString getAnimationExtension()
static ValueToQmlResult valueToQml(const QSSGSceneDesc::Node &target, const QSSGSceneDesc::Property &property, OutputContext &output)
static QString outputInstanceTableAsset(const QSSGSceneDesc::Instancing &instancing, const QDir &outdir)
static void writeQml(const QSSGSceneDesc::Model &model, OutputContext &output)
QString colorToQml(const QColor &color)
void createTimelineAnimation(const QSSGSceneDesc::Animation &anim, QObject *parent, bool isEnabled, bool useBinaryKeyframes)
static QString getMeshExtension()
static const char * blockBegin()
static const char * blockBegin(OutputContext &output)
static void writeQml(const QSSGSceneDesc::Node &transform, OutputContext &output)
static QStringList expandComponents(const QString &value, QMetaType mt)
void writeQmlForResources(const QSSGSceneDesc::Scene::ResourceNodes &resources, OutputContext &output)
const char * qmlElementName()
QString sanitizeQmlId(const QString &id)
static QString toQmlStringLiteral(const QString &value)
static const char * blockEnd(OutputContext &output)
static QString outputTextureAsset(const QSSGSceneDesc::TextureData &textureData, const QDir &outdir)
static const char * comment()
static QTextStream & indent(OutputContext &output)
static QString toQuotedString(const QString &text)
static QString getIdForAnimation(const QByteArray &inName)
static QString getMeshFolder()
static void writeImportHeader(OutputContext &output, bool hasAnimation=false)
static QStringList expandComponentsPartially(const QString &value, QMetaType mt)
QPair< QString, QString > writeQmlForAnimation(const QSSGSceneDesc::Animation &anim, qsizetype index, OutputContext &output, bool useBinaryKeyframes=true, bool generateTimelineAnimations=true)
const char * getQmlElementName(const QSSGSceneDesc::Node &node)
static std::pair< QString, QString > copyTextureAsset(const QUrl &texturePath, OutputContext &output)
static std::pair< QString, QString > meshAssetName(const QSSGSceneDesc::Scene &scene, const QSSGSceneDesc::Mesh &meshNode, const QDir &outdir)
static const char * indent()
QString getAnimationSourceName(const QString &id, const QString &property, qsizetype index)
QString getMeshSourceName(const QString &name)
QString variantToQml(const QVariant &variant)
QString stripParentDirectory(const QString &filePath)
QString asString(QSSGSceneDesc::Animation::Channel::TargetProperty prop)
static void writeQmlForResourceNode(const QSSGSceneDesc::Node &node, OutputContext &output)
QString sanitizeQmlSourcePath(const QString &source, bool removeParentDirectory)
QString getTextureSourceName(const QString &name, const QString &fmt)
static void resetIdAllocator()
static QByteArrayView typeName(QMetaType mt)
QUrl urlForFilePath(const QString &path)
void writeQml(const QSSGSceneDesc::Scene &scene, QTextStream &stream, const QDir &outdir, const QJsonObject &optionsObject)
static QString indentString(OutputContext &output)
void writeQml(const QSSGSceneDesc::Material &material, OutputContext &output)
static void writeQmlForNode(const QSSGSceneDesc::Node &node, OutputContext &output)
Combined button and popup list for selecting options.
@ DesignStudioWorkarounds
QSSGQmlScopedIndent(OutputContext &out)
QStringList expandedProperties