FileInstancing QML Type
允许从文件中读取实例表。更多
Import Statement: | import QtQuick3D |
Since: | Qt 6.2 |
Inherits: |
属性
- instanceCount : int
(since 6.3)
- source : url
详细说明
FileInstancing 类型可以从文件中读取实例表。
有两种支持的文件格式:XML 和 Qt 特有的二进制格式。二进制文件格式使用与上传到 GPU 的表相同的布局,因此可以直接映射到内存中。instancer工具可将 XML 转换为二进制格式。
这是 XML 文件格式的一个示例:
<?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>
为了有效,XML 文件必须有一个顶级InstanceTable
元素。每个实例由InstanceTable
内的Instance
元素表示。未知元素将被静默忽略。
一个Instance
元素可以有多个属性。color
属性由正常的Qt SVG 颜色名称或十六进制符号指定。vector3d
和 {vector4d} 属性由空格分隔的数字字符串指定,缺失的尾数表示零。支持以下属性:
名称 | 类型 |
---|---|
position | vector3d |
scale | vector3d |
eulerRotation | vector3d |
quaternion | vector4d |
custom | vector4d |
color | color |
未知属性将被忽略。
属性文档
instanceCount : int |
此只读属性包含实例表中的实例数量。
该属性在 Qt 6.3 中引入。
source : url |
该属性保存包含实例数据的 XML 或二进制文件的位置。
如果文件名后缀名为".bin",则表示该文件是二进制文件。否则,就认为是指 XML 文件。如果指定了一个 XML 文件foo.xml,而foo.xml.bin文件存在,则将加载二进制文件foo.xml. bin。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.