ProceduralMesh QML Type
QML을 통해 지오메트리를 생성할 수 있습니다. 더 보기...
| Import Statement: | import QtQuick3D.Helpers |
| Since: | Qt 6.6 |
| Inherits: |
속성
- binormals : List<QVector3D>
- colors : List<QVector4D>
- indexes : List<int>
- joints : List<QVector4D>
- normals : List<QVector3D>
- positions : List<QVector3D>
- primitiveMode : enumeration
- subsets : List<ProceduralMeshSubset>
- tangents : List<QVector3D>
- uv0s : List<QVector2D>
- uv1s : List<QVector2D>
- weights : List<QVector4D>
상세 설명
ProceduralMesh는 QML에서 Geometry 인스턴스를 생성할 수 있게 해주는 헬퍼 타입입니다. Geometry 컴포넌트는 추상 컴포넌트이며, 일반적으로 C++에서 생성됩니다.
component TorusMesh : ProceduralMesh {
property real rings: 50
property real segments: 50
property real radius: 100.0
property real tubeRadius: 10.0
property var meshArrays: generateTorus(rings, segments, radius, tubeRadius)
positions: meshArrays.verts
normals: meshArrays.normals
uv0s: meshArrays.uvs
indexes: meshArrays.indices
function generateTorus(rings: real, segments: real, radius: real, tubeRadius: real) {
let verts = []
let normals = []
let uvs = []
let indices = []
for (let i = 0; i <= rings; ++i) {
for (let j = 0; j <= segments; ++j) {
let u = i / rings * Math.PI * 2;
let v = j / segments * Math.PI * 2;
let centerX = radius * Math.cos(u);
let centerZ = radius * Math.sin(u);
let posX = centerX + tubeRadius * Math.cos(v) * Math.cos(u);
let posY = tubeRadius * Math.sin(v);
let posZ = centerZ + tubeRadius * Math.cos(v) * Math.sin(u);
verts.push(Qt.vector3d(posX, posY, posZ));
let normal = Qt.vector3d(posX - centerX, posY, posZ - centerZ).normalized();
normals.push(normal);
uvs.push(Qt.vector2d(i / rings, j / segments));
}
}
for (let i = 0; i < rings; ++i) {
for (let j = 0; j < segments; ++j) {
let a = (segments + 1) * i + j;
let b = (segments + 1) * (i + 1) + j;
let c = (segments + 1) * (i + 1) + j + 1;
let d = (segments + 1) * i + j + 1;
// Generate two triangles for each quad in the mesh
// Adjust order to be counter-clockwise
indices.push(a, d, b);
indices.push(b, d, c);
}
}
return { verts: verts, normals: normals, uvs: uvs, indices: indices }
}
}위의 코드는 Model 컴포넌트와 함께 사용할 Geometry로 활용될 수 있는 TorusMesh 컴포넌트를 정의합니다. ring, segments, radius 또는 tubeRadius 속성이 수정되면 지오메트리가 업데이트됩니다.
ProceduralMesh 컴포넌트는 C++에서 Geometry를 직접 생성하는 것만큼 유연하거나 성능이 뛰어나지는 않지만, 편의성과 단순성 면에서 그 단점을 보완합니다. 속성은 고정된 속성 목록으로 구성되어 있으며, 값을 입력하면 필요한 버퍼가 자동으로 생성됩니다.
속성 설명서
binormals : List<QVector3D>
binormals 속성 목록을 포함합니다.
colors : List<QVector4D>
이 속성은 정점 색상 값의 목록을 정의합니다.
indexes : List<int>
이 속성은 속성 목록에 대한 인덱스 목록을 정의합니다. 이 목록이 비어 있는 경우, 정점 버퍼의 값이 직접 사용됩니다.
joints : List<QVector4D>
이 속성은 스키닝에 사용되는 조인트 인덱스 목록을 정의합니다.
normals : List<QVector3D>
노멀 속성 목록을 저장합니다.
positions : List<QVector3D>
‘positions’ 속성 목록입니다. 이 목록이 비어 있으면 기하 구조가 생성되지 않습니다.
primitiveMode : enumeration [default: ProceduralMesh.Triangles]
이 속성은 지오메트리를 렌더링할 때 사용할 프리미티브 모드를 정의합니다.
| 상수 | 설명 |
|---|---|
ProceduralMesh.Points | '점' 프리미티브 모드가 사용됩니다. |
ProceduralMesh.LineStrip | 선 스트립 프리미티브 모드가 사용됩니다. |
ProceduralMesh.Lines | 'lines' 프리미티브 모드가 사용됩니다. |
ProceduralMesh.TriangleStrip | 삼각형 스트립 프리미티브 모드가 사용됩니다. |
ProceduralMesh.TriangleFan | 삼각형 팬 프리미티브 모드가 사용됩니다. |
ProceduralMesh.Triangles | 삼각형 프리미티브 모드가 사용됩니다. 참고: 모든 렌더링 백엔드에서 모든 모드가 지원되는 것은아닙니다 . |
subsets : List<ProceduralMeshSubset>
이 속성은 지오메트리 데이터를 분할할 부분 집합 목록을 정의합니다. 각 부분 집합은 고유한 재질을 가질 수 있습니다. 이 배열의 순서는 해당 지오메트리를 사용할 때 모델의 재질 목록 순서와 일치합니다.
이 속성은 선택 사항이며, 비워두면 단일 하위 집합이 생성됩니다.
참고: 사용 가능한 정점/인덱스 값의 범위를 벗어난 값을 지정하는부분 집합은 무시됩니다.
tangents : List<QVector3D>
'tangents' 속성 목록을 포함합니다.
uv0s : List<QVector2D>
이 속성은 첫 번째 UV 채널(uv0)에 대한 UV 좌표 목록을 정의합니다.
uv1s : List<QVector2D>
이 속성은 두 번째 UV 채널(uv1)에 대한 UV 좌표 목록을 정의합니다.
weights : List<QVector4D>
이 속성은 스키닝에 사용되는 관절 가중치 목록을 정의합니다.
© 2026 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.