Solved Can't load data.. (about QQuick3DGeometry)
-
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.
-
Hi, @doomdi. This works for me. https://github.com/oria66/test-qml-3dquickpc.
Hope you find your answer.
Still:
- I can not change the size of the points.
- I can not change the color individually.
Kind regards
-
Hi @oria66.
Unfortunately, I'm still stuck..
u said
- I can not change the size of the points.
- I can not change the color individually.
point size maybe... in your git's code
in main.qml
give scaleModel { 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? -
@doomdi Hi. If you manipulate the scale, you scale the model, but the points maintain the same size.
-
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? -
Hi All.
I solved this problem.
just remove clear() and add update() in pointcloud_test.cpp