Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can't load data.. (about QQuick3DGeometry)

Can't load data.. (about QQuick3DGeometry)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 750 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doomdi
    wrote on last edited by doomdi
    #1

    Hi all

    CAN'T LOAD DATA!!!!

    make Custom Geometry for real time c++ data to qml
    But data not show...

    Here is my code.

    in main.qml

    View3D {
            anchors.fill: parent
            camera: camera
    
            PerspectiveCamera {
                id: camera
                position: Qt.vector3d(0, 200, 300)
            }
    
            Model {
                geometry: Pointcloud {
                    name: "test"
    //                count: 1440
                }
                materials: PrincipledMaterial {}
                scale: Qt.vector3d(1, 1, 1)
            }
    
            AxisHelper {
                enableXYGrid: true
                enableXZGrid: true
                enableYZGrid: true
                enableAxisLines: true
            }
    
            WasdController {
                controlledObject: camera
            }
        }
    

    in pointcloud_test.cpp

    void pointcloud_test::updateGeometry()
    {
        clear();
    
        QByteArray vertexData;
        vertexData.resize((/*real data*/).size() * 3);
        vertexData.clear();
    //    float *p = reinterpret_cast<float *>(vertexData.data());
    //    float *dump = p;
    
        for (int i = 0; i < (/*real data*/).size(); i++) {
            QVector3D vertex;
            vertex.setX(/*some float data*/);
            vertex.setY(/*some float data*/);
            vertex.setZ(/*some float data*/);
    //        qDebug() << vertex;
            vertexData.append(vertex.x());
            vertexData.append(vertex.y());
            vertexData.append(vertex.z());
    //        *p++ = vertex.x();
    //        *p++ = vertex.y();
    //        *p++ = vertex.z();
        }
    
        setVertexData(vertexData);
        setPrimitiveType(QQuick3DGeometry::PrimitiveType::Points);
        setStride(3);
        addAttribute(QQuick3DGeometry::Attribute::PositionSemantic, 0, QQuick3DGeometry::Attribute::F32Type);
    //    qDebug() << vertexData;
    //    p = dump;
    //    free(p);
    }
    

    I refered to this.

    1 Reply Last reply
    0
    • oria66O Offline
      oria66O Offline
      oria66
      wrote on last edited by
      #2

      Hi, @doomdi. This works for me. https://github.com/oria66/test-qml-3dquickpc.

      Hope you find your answer.

      Still:

      1. I can not change the size of the points.
      2. I can not change the color individually.

      Kind regards

      The truth is out there

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doomdi
        wrote on last edited by
        #3

        Hi @oria66.

        Unfortunately, I'm still stuck..

        u said

        1. I can not change the size of the points.
        2. I can not change the color individually.

        point size maybe... in your git's code

        in main.qml
        give scale

        Model {
                    geometry: CustomGeometry{
                        name: "mypointcloud"
                        count: 10000000
                    }
                    materials: PrincipledMaterial{
                        baseColor: "white"
                        metalness: 0
                        roughness: 0
                        specularAmount: 0
                        indexOfRefraction: 0
                        specularTint: 0.0
                        opacity: 1.0
                        emissiveColor: "white"
                    }
                    scale: Qt.vector3d(10,10,10)
                }
        

        color individually... I think it's impossible in a model.
        how about make many model in a view3D?

        oria66O 1 Reply Last reply
        0
        • D doomdi

          Hi @oria66.

          Unfortunately, I'm still stuck..

          u said

          1. I can not change the size of the points.
          2. I can not change the color individually.

          point size maybe... in your git's code

          in main.qml
          give scale

          Model {
                      geometry: CustomGeometry{
                          name: "mypointcloud"
                          count: 10000000
                      }
                      materials: PrincipledMaterial{
                          baseColor: "white"
                          metalness: 0
                          roughness: 0
                          specularAmount: 0
                          indexOfRefraction: 0
                          specularTint: 0.0
                          opacity: 1.0
                          emissiveColor: "white"
                      }
                      scale: Qt.vector3d(10,10,10)
                  }
          

          color individually... I think it's impossible in a model.
          how about make many model in a view3D?

          oria66O Offline
          oria66O Offline
          oria66
          wrote on last edited by
          #4

          @doomdi Hi. If you manipulate the scale, you scale the model, but the points maintain the same size.

          The truth is out there

          1 Reply Last reply
          0
          • D Offline
            D Offline
            doomdi
            wrote on last edited by
            #5

            Hi @oria66 ..

            That's..

            So, when real time c++ data load to qml... (it must be renderred to 3D)
            what is the best ?

            I have 1 more question.

            I tried clear() in my pointcloud_test.cpp
            it's not update data... what is it?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              doomdi
              wrote on last edited by
              #6

              Hi All.

              I solved this problem.
              just remove clear() and add update() in pointcloud_test.cpp

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved