我正在ApplicationWindow中从PyQT5加载qml3d场景。 但是,我无法用鼠标平移和旋转自定义模型。你知道吗
import QtQuick.Controls 2.5
import QtQuick.Scene3D 2.12
import Qt3D.Core 2.12
import Qt3D.Render 2.12
import Qt3D.Input 2.12
import Qt3D.Extras 2.13
import QtQuick 2.12 as QQ2
ApplicationWindow{
Scene3D {
id: scene3d
anchors.fill: parent
anchors.margins: 10
focus: true
aspects: "input"
FirstPersonCameraController {
camera: camera
}
Entity {
id: sceneRoot
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 0.0, 0.0, 40.0 )
upVector: Qt.vector3d( 0.0, 1.0, 1.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
PointLight{
id:pl3
}
}
ObjectPicker{
id: spherePicker
onPressed:{
console.log("Sphere clicked")
}
}
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
camera: camera
clearColor: "transparent"
}
},
InputSettings { }
]
PhongMaterial {
id: material
diffuse:Qt.rgba(0.5,0.5,0,1)
}
PointLight{
id:pl2
}
Mesh {
id: esh
source: "egg1.obj"
}
Transform {
id: torusTransform
scale3D: Qt.vector3d(5, 5, 5)
rotation: fromAxisAndAngle(Qt.vector3d(1, 1, 0), 45)
}
Entity {
id: torusEntity
components: [ esh, material, torusTransform,spherePicker ]
}
}
}
}
模型加载正确只是因为我不能用鼠标控制它的旋转。你知道吗
我想这和“第一人称摄影机控制器”有关
这是我的工作,我目前正在使用旋转和平移对象从其位置。`你知道吗
如您所见,rotX、rotY和rotZ被用作场景外部的属性。 然后我简单地使用了关于MouseX和MouseY值的case语句。我希望你明白。 }你知道吗
我目前无法亲自验证这一点,但我假设您必须在名为
sceneRoot
的根实体中移动FirstPersonCameraController
。你知道吗现在它是
Scene3D
的孩子。试着把它移到Camera
节点下面,看看是否有效。你知道吗顺便说一下:我想你的意思是你不能控制摄像机,这就是你说的
相关问题 更多 >
编程相关推荐