I'm trying out the Qt 3D classes for the first time and am in need of a couple
pointers.
At a high level, I have the following:
- 1 view, 1 scene, 1 camera, and 1 QOrbitCameraController
- in the scene, I create 7 entities, each a child of the root entity
- each of the entities contains a mesh that is sourced from a
corresponding .obj file
Then my main window contains 7 radio buttons to toggle which entity is visible
at any
given time. The radio buttons are mutually exclusive, so the goal is that only
one entity
is visible at any time. I'm having two main issues with the setup so far:
Issue 1: QEntity::setEnabled(false) doesn't seem to make the entity invisible
Each radio button is connected to a corresponding slot which just does the
following:
void MainWindow::slotEntity1Toggled(bool checked)
{
qDebug() << __FUNCTION__ << checked;
Entity1 ->setEnabled(checked);
}
When the button becomes enabled (checked == true) the entity does in fact
become
visible. But when the button is disabled (checked == false), the entity is
still
visible in the view. If at that point I resize the application (and therefore
the
view) then the old entity disappears. It appears I need the 3D version of a
repaint(), but so far I haven't found where that is (or even which class I
should be
looking at). I did try explicitly calling repaint() on the QWidget that holds
the
view, but that didn't force the 3D scene to re-render, so far I've only been
able
to get it to redraw by resizing the widget.
From the qDebug() statement in there, I can see that this slot is getting
called
as expected. Every time it's called with "true" the entity changes from
invisible->visible without requiring any window resizing. But every time this
function
is called with "false", I have to resize the window to get the entity to
disappear
Issue 2: Is there any sort of "fit in view" functionality for 3D views?
Since I'm only allowing the user to display one entity at a time, I'd like to
be
able to automatically set the camera settings to zoom as needed to fit the
entire
entity within the view, so the user doesn't have to manually zoom in/out as
they
switch between entities.
I've used the 2D classes QGraphicsView & QGraphicsScene fairly extensively
and I'm
used to using QGraphicsView::fitInView(QGraphicsItem*) and have the
QGraphicsView set
the transform needed to fit that item within the view. I was hoping that Qt
3D has
something similar, but so far I haven't stumbled across it. I don't know
enough about
the Qt 3D classes yet to know if there's some easy way to compute the correct
transform
required to set this up?
The .obj files I'm playing around with have VASTLY different scale factors so
a
camera setting for one entity often doesn't work well for another.
Other pertinent information:
- Using Qt 5.15.2, but could switch to Qt 6 if required.
- I would prefer to stick with QWidget & C++, not QML
- I'm extremely new to Qt 3D, OpenGL, etc. so go ahead and make the assumption
that
I know nothing about anything in that realm. It's an accurate assumption,
and I won't
be offended!
Thanks,
Sean
This e-mail, including any attached files, may contain confidential
information, privileged information and/or trade secrets for the sole use of
the intended recipient. Any review, use, distribution, or disclosure by others
is strictly prohibited. If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by
reply e-mail and delete all copies of this message.
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest