Qt Quick 3D - 서브 메시 예제
서브메시에 머티리얼을 할당하는 방법을 보여줍니다.
이 예제는 머티리얼과 서브메시 매핑 방법을 보여줍니다.
서브메시 및 머티리얼
Model 이 두 개 이상의 메시로 구성된 경우 이러한 메시를 서브 메시라고 합니다. 각 하위 메시에는 고유한 머티리얼이 있을 수 있지만 모델당 하나 이상의 머티리얼을 제공할 필요는 없습니다. 서브 메시가 머티리얼 수보다 많으면 materials 목록의 마지막 머티리얼이 나머지 모든 서브 메시에 사용됩니다. 모델에 서브메시당 하나의 머티리얼이 제공되면 목록의 첫 번째 머티리얼은 첫 번째 서브메시에, 두 번째 머티리얼은 두 번째 서브메시에 적용하는 식으로 일대일로 매핑됩니다. 모델에서 서브 메시가 정렬되는 방식은 모델을 만드는 데 사용된 3D 모델링 도구에서 모델을 생성하고 내보낸 방식에 따라 달라집니다.
다음 예는 큐브의 각 면이 자체적으로 서브 메시인 두 개의 왜곡된 큐브를 보여줍니다.
왼쪽의 큐브를 보면 한쪽 면이 빨간색으로 칠해져 있고 나머지 면은 녹색으로 칠해져 있는 것을 볼 수 있는데, 그 이유는 물론 머티리얼에 빨간색과 녹색의 두 가지 머티리얼만 있기 때문입니다. 이 모델에서 첫 번째 하위 메시가 왜곡된 큐브의 "위쪽" 면이며, 빨간색 머티리얼이 머티리얼 목록에서 가장 먼저 배치되었으므로 예상대로 빨간색이 됩니다. 목록의 두 번째 머티리얼은 녹색 머티리얼로, 두 번째 하위 메시에 매핑되어 왜곡된 큐브의 "앞면"에 해당하며, 목록의 마지막 머티리얼이므로 왜곡된 큐브의 나머지 모든 면에 사용되는 머티리얼이 됩니다.
DistortedCube { x: -4 scale: Qt.vector3d(2, 2, 2) materials: [ PrincipledMaterial { baseColor: "red" lighting: PrincipledMaterial.NoLighting }, PrincipledMaterial { baseColor: "green" lighting: PrincipledMaterial.NoLighting } ]
오른쪽의 큐브를 보면 색이 좀 더 추가되었음을 알 수 있는데, 이는 물론 6개의 서브 메시 각각에 대해 각각 다른 색의 머티리얼을 하나씩 제공했기 때문입니다.
Model { source: "qrc:/meshes/distortedcube.mesh" PrincipledMaterial { id: frontTop_material baseColor: "red" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } PrincipledMaterial { id: frontBottom_material baseColor: "green" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } PrincipledMaterial { id: leftSide_material baseColor: "blue" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } PrincipledMaterial { id: rightSide_material baseColor: "pink" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } PrincipledMaterial { id: backSide_material baseColor: "orange" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } PrincipledMaterial { id: bottomSide_material baseColor: "navy" cullMode: Material.NoCulling lighting: PrincipledMaterial.NoLighting } materials: [ frontTop_material, frontBottom_material, leftSide_material, backSide_material, rightSide_material, bottomSide_material ] }
© 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.