我是Qt3d新手,我需要处理多个模型的场景中的用户输入。特别是,我需要找到用户单击的模型。我尝试使用mouseHandler和ObjectPicker,但它似乎不起作用。有人有例子吗?
例如,如果我有:
Entity {
Camera { id: camera ... }
FirstPersonCameraController {
camera: camera
}
components: [
RenderSettings{
activeFrameGraph: ForwardRenderer {
camera: camera
clearColor: "transparent"
},
InputSettings{}
]
MouseDevice {
id: mouse1
sensitivity: 0.1
}
SphereMesh {
id: sphereMesh
radius: 3
}
PhongMaterial{
id: material
}
Entity {
id: sphere1
components: [sphereMesh, material]
MouseHandler {
sourceDevice: mouse1
onClicked: console.log("[sphere 1] clicked"
}
}
Entity {
id: sphere2
components: [sphereMesh, material]
MouseHandler {
sourceDevice: mouse1
onClicked: console.log("[sphere 2] clicked"
}
}
}
我需要区分用户是单击sphere1还是sphere2,但如果我单击球体,我就看不到任何日志!
发布于 2017-06-15 19:39:55
Entity {
id: sphere2
components: [sphereMesh, material, spherePicker]
}
ObjectPicker{
id: spherePicker
onPressed:{
console.log("Sphere clicked")
}
}
components: [
RenderSettings{
activeFrameGraph:ForwardRenderer {
camera: camera
clearColor: "transparent"
},
InputSettings{}
pickingSettings.pickMethod: PickingSettings.TrianglePicking
pickingSettings.faceOrientationPickingMode: PickingSettings.FrontAndBackFace
]
ObjectPicker{
onPressed:{
console.log("Pressed at: " + pick.worldIntersection)
//If using triangle picking, you can also see index of the pressed triangle
console.log("Triangle index: " + pick.triangleIndex)
}
}
相关文档为这里
https://stackoverflow.com/questions/40847974
复制相似问题