Qt3d points and lines
I've just started messing around with Qt3d (without QML) and wondered if it is possible to simply draw a line between two points in 3-dimensional space.
Also, is there an easy way to set the bottom of a, for example, Qt3DExtras::QConeMesh() to point 1 and let the top end at point 2 (automatically set the length and angle between two points, so to speak).
So I figuered out how to draw simple lines with the help of
and Vertex/Index buffer. Now I got some flat lines. I would like to give them some more "volume" to make them look like tubes.
Anyone got an approach?
I don't quite get how to make a cylinder mesh behave like a line or make a line look like a cylinder.
I don't understand the question. A line is a mathematical abstraction, it has no volume and no surface area (just like a point). If one needs to draw a line one uses a realistic object that represents the line - e.g. a rectangle in 2D, or a cuboid or cylinder in 3D. Also I don't understand how does a line is supposed to behave ...?
@guy-incognito could you share the code for drawing lines ? thanks!
Let' s say i want to draw a triangle. I define the vertices p1 (0,0,0), p2 (2,0,0), and p3(1,2,0) and draw the lines between them. That's what i currently do. Now I want to draw a triangle with tubes instead of lines, so that it sort of looks like the triangle music instrument. I think thats called tubing and extrusion in OpenGL.
It was my question if there is a convenient way in qt3d to do this. Maybe my lines could be replaced with cylinders, so the bottom surface starts at (0,0,0), the top surface ends in (2,0,0) etc. (thats what i meant with "behave like a line").
Look at this thread's example code. It should be enough to get you started.
Thanks, the x,y and z axis look exactly like what I want. The only problem is, that QTransform for the QCylincerMesh is pretty unconvenient (as far as I see).
Take a look at this code. I used it to get an idea how to create custom meshes. You can adapt it to make it draw lines instead of TetraHedrons pretty easily.
This has been my PITA also. I have just found an example in qt5.6 that was dropped in all further releases but it provides a working set of code that creates a custom entity with your own set of vectors / normals / colors. If you look at this in code.qt.io
I wish Qt (KDAB is actually doing the Qt3D stuff) would spend a bit of time and put together some documented examples at the level of what their qGraphicsItem module was. Or at a minimum put some details to the qt function documentation. It is very frustrating to try and figure things out when there is no documentation or good functional examples on the objects we are supposed to use.
I am trying to draw a line in qml. I used the custom_mesh_qml for checking how it works in qt 5.9. but I encountered an error in the main.cpp file in the line 'engine.aspectEngine()->setData(data);' like setData not found. Can you help me on this. Thank you.
@MatPaul Why don't you post the actual error message?
I guess the compiler tells you that there is no such method: setData.
I guess aspectEngine() returns https://doc.qt.io/qt-5/qt3dcore-quick-qqmlaspectengine.html and QQmlAspectEngine does not have setData() method.
I had used the code from this link
And run that on qt5.9
I think the setData() functionality is removed in 5.9. is there a new function which does the similar behaviour