![]() |
Qt 6.x
The Qt SDK
|
#include "qquick3dinstancing_p.h"
#include "qquick3dscenemanager_p.h"
#include <QtQuick3DRuntimeRender/private/qssgrenderinstancetable_p.h>
#include <QtQuick3DUtils/private/qssgutils_p.h>
#include <QXmlStreamReader>
#include <QtQml/QQmlFile>
Go to the source code of this file.
Classes | |
struct | QQuick3DInstancingBinaryFileHeader |
Functions | |
static QQuick3DInstancing::InstanceTableEntry | calculate (const QVector3D &position, const QVector3D &scale, const QVector3D &eulerRotation, const QColor &color, const QVector4D &customData) |
static bool | writeInstanceTable (QIODevice *out, const QByteArray &instanceData, int instanceCount) |
Variables | |
static constexpr quint16 | currentMajorVersion = 1 |
\qmltype FileInstancing \inherits Instancing \inqmlmodule QtQuick3D | |
|
inlinestatic |
Definition at line 371 of file qquick3dinstancing.cpp.
References QQuaternion::fromEulerAngles(), position(), QQuaternion::toRotationMatrix(), and xform.
Referenced by QQuick3DInstancing::calculateTableEntry().
|
static |
Definition at line 809 of file qquick3dinstancing.cpp.
References QByteArray::constData(), QString::count(), header(), instanceCount, out, qWarning, and QByteArray::size().
Referenced by QQuick3DFileInstancing::writeToBinaryFile().
|
staticconstexpr |
\qmltype FileInstancing \inherits Instancing \inqmlmodule QtQuick3D
Allows reading instance tables from file.
The FileInstancing type makes it possible to read instance tables from files.
There are two supported file formats: XML, and a Qt-specific binary format. The binary file format uses the same layout as the table that is uploaded to the GPU, so it can be directly mapped to memory. The \l{Instancer Tool}{instancer} tool converts from XML to the binary format.
This is an example of the XML file format: \badcode <?xml version="1.0" encoding="UTF-8" ?> <InstanceTable> <Instance position="0 200 0" scale="0.75 0.75 0.75" custom="20 20" color="#ffcf7f"> <Instance position="0 -100 0" scale="0.5 0.5 0.5" color="red"> <Instance position="0 -200 0" eulerRotation="0 0 60" color="darkred" custom="10 40 0 0"> </InstanceTable>
In order to be valid, the XML file must have a top-level {InstanceTable} element. Each instance is represented by an
{Instance} element inside the
{InstanceTable}. Unknown elements are silently ignored.
An {Instance} element can have a number of attributes.
{color} attributes are specified by the normal Qt SVG color names, or by hexadecimal notation.
{vector3d} and {vector4d} attributes are specified by a string of space-separated numbers, where missing trailing numbers indicate zeroes. The following attributes are supported: \table \header
position
vector3d
\row scale
vector3d
\row eulerRotation
vector3d
\row quaternion
vector4d
\row custom
vector4d
\row color
color
\endtable Unknown attributes are silently ignored.\qmlproperty url QtQuick3D::FileInstancing::source
This property holds the location of an XML or binary file containing the instance data.
If the file name has a ".bin" extension, it is assumed to refer to a binary file. Otherwise it is assumed to refer to an XML file. If an XML file {foo.xml} is specified, and the file {foo.xml.bin} exists, the binary file {foo.xml.bin} will be loaded instead.
\qmlproperty int QtQuick3D::FileInstancing::instanceCount
This read-only property contains the number of instances in the instance table.
Definition at line 797 of file qquick3dinstancing.cpp.
Referenced by QQuick3DFileInstancing::loadFromBinaryFile(), and QWidget::restoreGeometry().