FileInstancing QML Type

Allows reading instance tables from file. 更多...

import 语句: import QtQuick3D
Since: Qt 6.2
继承: Instancing

特性

详细描述

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 instancer tool converts from XML to the binary format.

This is an example of the XML file format:

<?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:

名称 type
位置 vector3d
scale vector3d
eulerRotation vector3d
quaternion vector4d
custom vector4d
color color

Unknown attributes are silently ignored.

特性文档编制

[since 6.3] instanceCount : int

This read-only property contains the number of instances in the instance table.

This property was introduced in Qt 6.3.


source : url

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.