[Interest] [Qt3D] Dynamic object generation

Markus Heß markus.hess at etit.tu-chemnitz.de
Tue Jun 21 16:36:08 CEST 2016


Am Dienstag, 21. Juni 2016, 10:44:03 CEST schrieben Sie:
> Hi,
> 
> On Tuesday 21 June 2016 08:59:03 Markus Heß wrote:
> > Hi,
> > 
> > I want to use Qt3D (5.7) to visualize some 3d boxes in a scene. These
> > boxes
> > are created dynamically based on data coming from a 3D Sensor (10Hz).
> > Because I want to display only the edges of the boxes, I created a
> > separate
> > box entity which itself contains 12 entities representing the edges of the
> > box. When I create the boxes only once and add them to the scene entity
> > everything is displayed fine. The problem occurs when I try to add and
> > remove boxes dynamically depending on the sensor data. In that case it
> > happens that some boxes or even only some edges of one box are not drawn.
> > I
> > assume that maybe the objects are already removed again before the
> > rendering was fully done in the rendering thread. Could that be the
> > reason?
> > 
> > Is there any way to solve this issue? Maybe there is a signal which
> > notifies me that the rendering was done? I also tried to update the scene
> > only on the "triggered" signal of QFrameAction. But still the boxes are
> > not drawn correctly.
> 
> The changes from the main thread (frontend) to the Qt 3D backend are batched
> up via a zero ms timer using the Qt event loop. So if you block the event
> loop long enough to add and then remove entities from the scene, it's
> possible the backend will not ever draw them.
> 

OK, I did some more investigation and it seems that the problem also occurs 
when the boxes are slowly updated. I implemented a small example where I 
remove and add the boxes after a defined time period using a QTimer. (see 
attached) Even if I set the update time more than a second, the behavior is 
still the same. Maybe it is a bug? I am also not sure, if I correctly remove 
the objects. I simply set the parent of the object to be removed to nullptr 
and delete the object afterwards. Is that correct?

> Does it "work" if you don't delete the entities? I.e. only create them from
> your data. If so, then perhaps you can add a minimum lifetime to your
> entities by deleting them in a deferred way in response to a timer.
> 

When I do not remove the previous created boxes, all boxes are drawn 
correctly. 

> As a side note, do you need each edge to be selectable or something else
> that requires them to be an entire entity? You could make this more
> efficient by using one entity per cube and drawing the edges using some
> custom geometry as lines.
> 

Thank you for the suggestion of using a custom geometry but I think single 
entities are more suitable in my case because it makes it possible to change 
the material of each edge independently which may is necessary in the future.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Qt3dBoxIssue.zip
Type: application/zip
Size: 3108 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160621/dc8d3fe1/attachment.zip>


More information about the Interest mailing list