Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Get size of entity in QT3D
zoeetc last edited by
I'm trying to add some text to my 3D scene using the QExtrudedTextMesh to create my entity. I would like to put a plane directly behind this text based on the size of the text. I can't seem to find any way to get the width/height of this entity so I can determine the size of my plane. Is there a way?
I've also looked into using a 2DScene to create a material of the text to put on a plane, but the same issue here, how can I determine the size of the text so my plane will grow/shrink with the content?
Any ideas would be much appreciated!
HappyFeet last edited by
There has been a question here already: https://forum.qt.io/topic/85533/qt3d-qml-geometry-bounding-box. But I couldn't really find any code in the github repository.
What I'd suggest is you get the QGeometryRenderer from the text entity. The geometry renderer has a QGeomemtry attribute, which in turn has a set of QAttributes. There must be an attribute with a name like "vertexPosition". You need to get the QBuffer from the attribute and retrieve the vertices starting at position byteOffset (that is an attribute of QAttribute). The next vertexSize (also an attribute of QAttribute) entries should belong to the vertex position. Then continute at position byteOffset + i * byteStride, while i being the index you're reading right now. Do this for count (also an attribute) times. This way you can get all vertex positions and calculate a bounding box based on them.