В моем приложении QML я показываю пользовательскую сетку, созданную из медицинских изображений. Теперь я хочу, чтобы камера вращалась вокруг центра этой сетки.
В соответствии с ответами на этот вопрос я должен установить viewCenter
камеры на перевод сетки. Однако имеющиеся у меня сетки уже переведены (центроид не находится в [0, 0, 0]), поскольку они находятся в системе координат КТ/МР-сканера.
Как я могу получить центр тяжести импортированной сетки, чтобы соответствующим образом установить viewCenter?
В моем файле QML у меня есть:
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.0
import QtQuick 2.0 as QQ2
Entity {
id: sceneRoot
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d(0, 0, 20)
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) // here I should set the viewcenter to the centroid of "organModel"
}
OrbitCameraController { camera: camera }
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
camera: camera
clearColor: "transparent"
}
},
InputSettings { }
]
PhongMaterial {
id: material
ambient: "darkRed"
}
Mesh {
id: organModel
source: "qrc:/organModel.obj"
}
Transform {
id: transformLiver
}
Entity {
id: torusEntity
components: [ liver, material, transformLiver ]
}
}