[Interest] [Qt3D] Dynamic object generation

Sean Harmer sean.harmer at kdab.com
Tue Jun 21 11:44:03 CEST 2016


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.

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.

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.

Cheers,

Sean
-- 
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts



More information about the Interest mailing list