现在我们做电池模块驱动轴的3D显示,显示效果如下:
具体的代码也比较简单,我们先来看一下所需要的参数
emissiveFactor: 发射因子,在具有黑色环境照明的场景中,发射因子为0的材质在光线不照射的地方将显示为黑色,将发射因子设置为1将导致材质以漫反射颜色显示。
specularAmount: 镜面反射量,越大颜色显得亮一点
diffuseColor: 漫反射颜色
显示效果如下:
代码如下所示:
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick3D 1.15
Node{
id:rootNode
property alias powerCable_materialEmissiveFactor:powerCable_material.emissiveFactor
Node{
id:battery
y:37.1467
z:-6.57201
eulerRotation.x:-90
Model{
id:backMotor
x:-0.00150466
y:135.958
z:-0.139786
source: "meshes/backMotor.mesh"
PrincipledMaterial{
id:motors_material
metalness: 0.6
roughness: 0.8
baseColor: "#ddf3f3"
}
materials: [
motors_material
]
}
Model{
id:frontMotors
x:-1.90735e-06
y:-140.554
z:-0.139786
source: "meshes/frontMotors.mesh"
materials: [
motors_material
]
}
Model{
id:line001
x:2.50093e-06
y:50.6425
z:-1.53307
eulerRotation.x:0
eulerRotation.y:-90
eulerRotation.z:-90
source: "meshes/line001.mesh"
materials: powerCable_material
}
Model{
id:cable005
x:-6.45353
y:-133.43
z:0.626755
source: "meshes/cable005.mesh"
DefaultMaterial{
id:powerCable_material
specularAmount: 0.1 //镜面反射量
emissiveFactor: 0 //发射因子:
diffuseColor: "#b1f8fc" //漫反射颜色
}
materials: [
powerCable_material
]
}
Model{
id:cable006
x:-11.6086
y:-134.272
z:0.626755
source: "meshes/cable006.mesh"
materials: [
powerCable_material
]
}
Model{
id:eCU
x:0.000259161
y:-114.679
z:-10.3093
eulerRotation.x:-5
scale.x:1.03955
scale.y:1.41603
scale.z:1.64852
source: "meshes/eCU.mesh"
DefaultMaterial{
id:eCU_material
specularAmount: 0.2
diffuseColor: "#ffd0d0c2"
}
materials: [
eCU_material
]
}
}
}
至此我们把驱动轴的程序写完了。接下来我们写3D车模的显示程序。