Solved Dynamic Entities in Qt 3D QML
-
Hey all,
I am trying to dynamically create lines (thin cylinders) from one point to another in a series of points in Qt 3D with QML.
Entity objects that I create inside a Repeater, with the model of points I want to connect, do not appear.
Scene3D { id: scene3D anchors { fill: parent } cameraAspectRatioMode: Scene3D.AutomaticAspectRatio aspects: ["input", "logic"] multisample: true Entity { Camera { id: camera projectionType: CameraLens.PerspectiveProjection fieldOfView: 45 nearPlane : 0.1 farPlane : 1000.0 position: Qt.vector3d(0.0, 0.0, 300.0) upVector: Qt.vector3d(0.0, 1.0, 0.0) viewCenter: Qt.vector3d(0.0, 0.0, 0.0) } // DOESN'T WORK Repeater { model: ListModel { ListElement { role_start: "0, 0, 0"; role_end: "100, 100, 0" } ListElement { role_start: "100, 100, 0"; role_end: "0, 200, 0" } } LineEntity { start: role_start end: role_end } } // WORKS LineEntity { start: "0, 0, 0" end: "100, 100, 0" }
Is this possible? How can I create a Qt 3D scene in QML dynamically and add/remove entities at will?
-
Solved! Found the NodeInstantiator class that does what Repeater does in a Scene3D.