前面的博客中介绍了如何在Qt Quick 3D中加载三维模型,下面介绍如何设置三维模型的材质,例如下图模型:
我需要设置为金属材质时,设置该Model的materials为PrincipledMaterial,其中baseColor:材质的基础色;metalness:金属质感程度;roughness:模型表面反射光线的强度。代码如下:
Model {
id: cubeModel
source: "test.mesh"
materials: PrincipledMaterial {
id: cubeMaterial
baseColor: "#e9d805"
roughness: 0.4
metalness: 0.8
}
}
效果图:
源码GitHub:https://github.com/zjgo007/QtQuick3D/tree/master/Principled3DMaterial