[Interest] Qt3D for cad project
Sean Harmer
sean.harmer at kdab.com
Tue Dec 1 10:09:20 CET 2015
Hi,
On Tuesday 01 Dec 2015 04:27:30 Tom Kulaga wrote:
> Hi All, Qt3D Team,
>
> I've been tinkering with Qt3D recently for an electronics CAD project I'm
> working on.
>
> I've got a few questions about as to approaches I could/should take to help
> me make it work.
>
> A lot of the items I will be drawing will be "meta items" of sorts. They
> will be moveable as one item, but contain different sub parts, on different
> "layers".
>
> Taking a look at this image below taken from Altium:
> https://i.ytimg.com/vi/pW_kpk5lQlM/maxresdefault.jpg
>
> You can see the different subparts to this particular component, The
> different coloured circles, and the numbers. Would I have a different
> Qt3DRender::QGeometryRenderer for each bit. Possibly sub-classing it, to
> add in the "layer" information (where layer here basically means different
> colour).
I would suggest using as few geometry renderer's as possible as these
translate to draw calls under the hood. To this end I would take a look at the
per vertex color material that allows you to associate a colour with each
vertex. That way a single geometry renderer can be used to draw the different
coloured sub objects you describe.
> If I take this approach and each component say has about 5 or 6
> Qt3DRender::QGeometryRenderers associated with it, and I have about 30000
> of these guys. Will Qt3D handle that nicely?
Not likely. This would translate into 30k draw calls per frame which is too
much for OpenGL which prefers to have fewer draw calls (a few thousand per
frame) but with larger sets of data to process.
To bring this number down, the best way would be to use instancing. Take a
look at
http://code.qt.io/cgit/qt/qt3d.git/tree/examples/qt3d/instanced-arrays-qml
to see one way of doing this with Qt3D. With instancing it is possible to draw
many 10's of thousands of instances of a base object with each instance able
to be customised in any way that you can parametrise in your shaders,
typically things like position, scale, orientation, colour etc.
>
> Another question that I have is am I able to group these
> Qt3DRender::QGeometryRenderer, so that when I draw my Item, all the
> "layers" are drawn. Or would I have different The vertex data in one big
> Qt3DRender::QGeometryRenderer with some primitive restarts and different
> per-vertex colours?
>
> I also want to enable picking (which I've seen from the qt3d examples is
> very easy and simple). If I enable an object picker onto these 300000
> Entities, will that cause any significant performance problems? (This will
> definitely vary depending on machine, I guess im just asking conceptually
> if its the right thing to do).
The downside with instancing is that we do not yet support picking with
instanced items out of the box. This is because you could be doing anything
inside your shaders on a per instance basis. To make this work in the future
in a general way we would need the user to specify some additional information
about how the shaders transform each instance. Perhaps we can look into this
for Qt 5.8 if there is interest.
There may be a way to mix instancing with the builtin picking by using
instanced rendering to draw the bulk of your objects, then falling back to
regular entities for those items that need to be pickable. Or you could
implement your own picking code to work with instancing in the short term
given that you will know how you transform each instance.
>
> Any help would be appreciated.
Hope this helps give you some ideas to investigate,
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