QT 3D NodeInstantiator performance issue

Viewed 82

I want to visualize x,y,z points as cubic blocks. I use C++ for backend and qtquick/javascript for frontend. I have implemented QAbstractListModel in C++ side and exposing to qml (qtquick) with QQmlApplicationEngine rootContext. Data include only x,y,z points and color codes. Data have arround 500 thousand coordinate points. I'm trying to visualize this data with NodeInstantiator dynamically. But it takes too much time to create objects, and ram usage increasing rapidly to 5-6 GB. If I solve the performance issue, I will try to add border lines to blocks. And I don't know how to do it aswell. OS: Windows 10 Ram: 8 GB max GPU: Nvidia 970 GTX QT Creator 7.0.0 Kit: Desktop Qt 5.15.2 MinGW 64 Bit

import QtQuick 2.15
import QtQuick.Window 2.15 as W
import QtQuick.Scene3D 2.15
import Qt3D.Core 2.15
import Qt3D.Render 2.15
import Qt3D.Extras 2.15
import Qt3D.Input 2.15

import QtQuick.Controls 2.5

Page {

    Rectangle {

        id: rect1
        x:0
        y:0
        width: 100
        height: 100
        color: "red"
    }
    Scene3D {
        id: scene3dId

        anchors.top: rect1.bottom

        anchors.bottom: parent.bottom
        anchors.right: parent.right
        anchors.left: parent.left

        //anchors.fill: parent
        aspects: ["input", "logic"]

        Entity {
            id: scene
            property color baseColor
            property real metalness
            property real roughness
            property real exposure
            property real gamma

            components: [
                RenderSettings {
                    activeFrameGraph: ForwardRenderer {
                        camera: mainCamera
                        clearColor: "white"
                        gamma: scene.gamma
                    }
                },
                // Event Source will be set by the Qt3DQuickWindow
                InputSettings { }
            ]
            Camera {
                id: mainCamera
                position: Qt.vector3d(0, 0, 12)
                viewCenter: Qt.vector3d(0, 0, 0)
                fieldOfView: 60
                exposure: scene.exposure
            }
            OrbitCameraController {
                camera: mainCamera
                linearSpeed: 1000
                lookSpeed: 240
            }
            CuboidMesh{
                id: cubeMesh
                xExtent: 1
                yExtent: 1
                zExtent: 1
            }

            NodeInstantiator {
                    id: grid
                    model: BM
                    delegate:
                    Entity {
                        Transform {
                            id: transformId
                            translation: Qt.vector3d(model.X, model.Y, model.Z)
                        }
                        PhongMaterial {
                            id: cubeMaterial
                            ambient: model.Color
                        }
                        components: [transformId, cubeMesh, cubeMaterial]
                    }
            }
        }
    }
}

An example of what I want to do

0 Answers
Related