Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get size of entity in QT3D
Qt 6.11 is out! See what's new in the release blog

Get size of entity in QT3D

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqt3d qml scene3
2 Posts 2 Posters 1.4k 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.
  • Z Offline
    Z Offline
    zoeetc
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    1
    • H Offline
      H Offline
      HappyFeet
      wrote on last edited by
      #2

      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.

      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