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
qquick3dinstancing.cpp File Reference

(2b139225745a94ab4fa7e30f28cd0207469ee68e)

#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>
+ Include dependency graph for qquick3dinstancing.cpp:

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
 

Function Documentation

◆ calculate()

static QQuick3DInstancing::InstanceTableEntry calculate ( const QVector3D & position,
const QVector3D & scale,
const QVector3D & eulerRotation,
const QColor & color,
const QVector4D & customData )
inlinestatic

Definition at line 371 of file qquick3dinstancing.cpp.

References position(), and xform.

Referenced by QQuick3DInstancing::calculateTableEntry().

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

◆ writeInstanceTable()

static bool writeInstanceTable ( QIODevice * out,
const QByteArray & instanceData,
int instanceCount )
static

Definition at line 809 of file qquick3dinstancing.cpp.

References QByteArray::constData(), header(), instanceCount, out, qWarning, and QByteArray::size().

Referenced by QQuick3DFileInstancing::writeToBinaryFile().

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

Variable Documentation

◆ currentMajorVersion

constexpr quint16 currentMajorVersion = 1
staticconstexpr

\qmltype FileInstancing \inherits Instancing \inqmlmodule QtQuick3D

Since
6.2

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

  • name
  • type \row
  • 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

Since
6.3

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().