> > 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); > > } > > > > Please provide more details on how the view is setup.
Sure. Here's the code that sets up the view & scene view = new Qt3DExtras::Qt3DWindow(); Qt3DCore::QEntity *scene = createScene(); // <- explained below Qt3DRender::QCamera *camera = view->camera(); camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 100000.0f); camera->setPosition(QVector3D(0, 0, 750)); camera->setViewCenter(QVector3D(0, 0, 0)); Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(scene); camController->setLinearSpeed( 1000.0f ); camController->setLookSpeed( 180.0f ); camController->setCamera(camera); view->setRootEntity(scene); view->show(); QWidget* w = QWidget::createWindowContainer(view, this); // from here I add the widget "w" to my main window The createScene() function does the following: // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity; // Material Qt3DRender::QMaterial *material; // Entity mEntity = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QMesh *mMesh = new Qt3DRender::QMesh(rootEntity); material = new Qt3DExtras::QPhongMaterial(rootEntity); mMesh->setSource(QUrl(filename)); mEntity->addComponent(mMesh); mEntity->addComponent(material); mEntity->setEnabled(false); > > 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. > > > > 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. > > There's relevant methods on the QCamera class. Shortly after posting my original message, I did stumble across QCamera::viewEntity() and added that. So now in my slot that is supposed to enable/disable an entity I do the following: void MainWindow::slotEntity1Toggled(bool checked) { qDebug() << __FUNCTION__ << checked; Entity1->setEnabled(checked); if(checked && view && view->camera()) { view->camera()->viewEntity(Entity1); } } This change ALMOST works, like the first issue, after I make this call, the new entity is shown, but the old entity is still visible too, and the camera is still at the same position as before. I have to do something that forces the view to resize before the camera actually changes position and the scene gets rendered correctly. As soon as that resize happens, the scene is re-rendered exactly as I want: the previous entity is no longer visible, the new entity is centered and fits nicely within the view. So I'm getting closer - I just seem to be missing something that triggers the scene to get rendered again after I make changes - basically whatever the Qt 3D equivalent of QWidget::repaint() is. I haven't stumbled across that yet. 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 Interest@qt-project.org https://lists.qt-project.org/listinfo/interest