void initializeScene() { SceneWindow *window = new SceneWindow(); //QWidget *container = QWidget::createWindowContainer(window); Qt3DCore::QAspectEngine engine; Qt3DInput::QInputAspect *inputAspect = new Qt3DInput::QInputAspect(); engine.registerAspect(new Qt3DRender::QRenderAspect()); engine.registerAspect(inputAspect); QVariantMap data; data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(window))); data.insert(QStringLiteral("eventSource"), QVariant::fromValue(window)); engine.setData(data); // root entity Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // camera scene Qt3DCore::QCamera *camera = new Qt3DCore::QCamera(sceneRoot); camera->setFieldOfView(25); camera->setNearPlane(1); camera->setFarPlane(1000); camera->setViewCenter(QVector3D(0, 3, 0)); inputAspect->setCamera(camera); Qt3DRender::QFrameGraph *frameGraphComponent = new Qt3DRender::QFrameGraph(sceneRoot); Qt3DRender::QForwardRenderer *forwardRenderer = new Qt3DRender::QForwardRenderer(); forwardRenderer->setCamera(camera); forwardRenderer->setClearColor(Qt::blue); frameGraphComponent->setActiveFrameGraph(forwardRenderer); sceneRoot->addComponent(frameGraphComponent); // scene loader Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot); Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity); SceneHandler sceneHandler(sceneLoader); QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneHandler, &SceneHandler::onStatusChanged); sceneLoaderEntity->addComponent(sceneLoader); QUrl fileName; fileName = QUrl::fromLocalFile("file:://C:/Users/jacobmosehansen/Desktop/IKT/20mm_hollow_cube.stl"); sceneLoader->setSource(fileName); engine.setRootEntity(sceneRoot); }
int main(int ac, char **av) { QApplication app(ac, av); Qt3DExtras::Qt3DWindow view; view.defaultFrameGraph()->setClearColor(Qt::black); // Root entity Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // Scene Camera Qt3DRender::QCamera *camera = view.camera(); camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); camera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); camera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); camera->setNearPlane(0.001f); camera->setFarPlane(10000.0f); // For camera controls Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot); camController->setCamera(camera); // Scene loader Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot); Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity); SceneWalker sceneWalker(sceneLoader); QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneWalker, &SceneWalker::onStatusChanged); sceneLoaderEntity->addComponent(sceneLoader); QStringList args = QCoreApplication::arguments(); QUrl sourceFileName; if (args.count() <= 1) { QWidget *container = new QWidget(); QFileDialog dialog; dialog.setFileMode(QFileDialog::AnyFile); sourceFileName = dialog.getOpenFileUrl(container, QStringLiteral("Open a scene file")); } else { sourceFileName = QUrl::fromLocalFile(args[1]); } if (sourceFileName.isEmpty()) return 0; sceneLoader->setSource(sourceFileName); view.setRootEntity(sceneRoot); view.show(); return app.exec(); }
void SceneWalker::onStatusChanged() { qDebug() << "Status changed:" << m_loader->status(); if (m_loader->status() != Qt3DRender::QSceneLoader::Ready) return; // The QSceneLoader instance is a component of an entity. The loaded scene // tree is added under this entity. QVector<Qt3DCore::QEntity *> entities = m_loader->entities(); // Technically there could be multiple entities referencing the scene loader // but sharing is discouraged, and in our case there will be one anyhow. if (entities.isEmpty()) return; Qt3DCore::QEntity *root = entities[0]; // Print the tree. walkEntity(root); // To access a given node (like a named mesh in the scene), use QObject::findChild(). // The scene structure and names always depend on the asset. Qt3DCore::QEntity *e = root->findChild<Qt3DCore::QEntity *>(QStringLiteral("PlanePropeller_mesh")); // toyplane.obj if (e) qDebug() << "Found propeller node" << e << "with components" << e->components(); }
Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *engine ) : mMap( map ) , mEngine( engine ) { connect( &map, &Qgs3DMapSettings::backgroundColorChanged, this, &Qgs3DMapScene::onBackgroundColorChanged ); onBackgroundColorChanged(); // TODO: strange - setting OnDemand render policy still keeps QGIS busy (Qt 5.9.0) // actually it is more busy than with the default "Always" policy although there are no changes in the scene. //mRenderer->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::OnDemand ); #if QT_VERSION >= 0x050900 // we want precise picking of terrain (also bounding volume picking does not seem to work - not sure why) mEngine->renderSettings()->pickingSettings()->setPickMethod( Qt3DRender::QPickingSettings::TrianglePicking ); #endif QRect viewportRect( QPoint( 0, 0 ), mEngine->size() ); // Camera float aspectRatio = ( float )viewportRect.width() / viewportRect.height(); mEngine->camera()->lens()->setPerspectiveProjection( mMap.fieldOfView(), aspectRatio, 10.f, 10000.0f ); mFrameAction = new Qt3DLogic::QFrameAction(); connect( mFrameAction, &Qt3DLogic::QFrameAction::triggered, this, &Qgs3DMapScene::onFrameTriggered ); addComponent( mFrameAction ); // takes ownership // Camera controlling mCameraController = new QgsCameraController( this ); // attaches to the scene mCameraController->setViewport( viewportRect ); mCameraController->setCamera( mEngine->camera() ); mCameraController->resetView( 1000 ); addCameraViewCenterEntity( mEngine->camera() ); // create terrain entity createTerrainDeferred(); connect( &map, &Qgs3DMapSettings::terrainGeneratorChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::terrainVerticalScaleChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::mapTileResolutionChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::maxTerrainScreenErrorChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::maxTerrainGroundErrorChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::terrainShadingChanged, this, &Qgs3DMapScene::createTerrain ); connect( &map, &Qgs3DMapSettings::pointLightsChanged, this, &Qgs3DMapScene::updateLights ); connect( &map, &Qgs3DMapSettings::fieldOfViewChanged, this, &Qgs3DMapScene::updateCameraLens ); // create entities of renderers Q_FOREACH ( const QgsAbstract3DRenderer *renderer, map.renderers() ) { Qt3DCore::QEntity *newEntity = renderer->createEntity( map ); newEntity->setParent( this ); } // listen to changes of layers in order to add/remove 3D renderer entities connect( &map, &Qgs3DMapSettings::layersChanged, this, &Qgs3DMapScene::onLayersChanged ); updateLights(); #if 0 ChunkedEntity *testChunkEntity = new ChunkedEntity( AABB( -500, 0, -500, 500, 100, 500 ), 2.f, 3.f, 7, new TestChunkLoaderFactory ); testChunkEntity->setEnabled( false ); testChunkEntity->setParent( this ); chunkEntities << testChunkEntity; #endif connect( mCameraController, &QgsCameraController::cameraChanged, this, &Qgs3DMapScene::onCameraChanged ); connect( mCameraController, &QgsCameraController::viewportChanged, this, &Qgs3DMapScene::onCameraChanged ); #if 0 // experiments with loading of existing 3D models. // scene loader only gets loaded only when added to a scene... // it loads everything: geometries, materials, transforms, lights, cameras (if any) Qt3DCore::QEntity *loaderEntity = new Qt3DCore::QEntity; Qt3DRender::QSceneLoader *loader = new Qt3DRender::QSceneLoader; loader->setSource( QUrl( "file:///home/martin/Downloads/LowPolyModels/tree.dae" ) ); loaderEntity->addComponent( loader ); loaderEntity->setParent( this ); // mesh loads just geometry as one geometry... // so if there are different materials (e.g. colors) used in the model, this information is lost Qt3DCore::QEntity *meshEntity = new Qt3DCore::QEntity; Qt3DRender::QMesh *mesh = new Qt3DRender::QMesh; mesh->setSource( QUrl( "file:///home/martin/Downloads/LowPolyModels/tree.obj" ) ); meshEntity->addComponent( mesh ); Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial; material->setAmbient( Qt::red ); meshEntity->addComponent( material ); Qt3DCore::QTransform *meshTransform = new Qt3DCore::QTransform; meshTransform->setScale( 1 ); meshEntity->addComponent( meshTransform ); meshEntity->setParent( this ); #endif if ( map.hasSkyboxEnabled() ) { Qt3DExtras::QSkyboxEntity *skybox = new Qt3DExtras::QSkyboxEntity; skybox->setBaseName( map.skyboxFileBase() ); skybox->setExtension( map.skyboxFileExtension() ); skybox->setParent( this ); // docs say frustum culling must be disabled for skybox. // it _somehow_ works even when frustum culling is enabled with some camera positions, // but then when zoomed in more it would disappear - so let's keep frustum culling disabled mEngine->setFrustumCullingEnabled( false ); } // force initial update of chunked entities onCameraChanged(); }
void QgsBufferedLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, LineData &out, bool selected ) { if ( out.polygons.isEmpty() ) return; // nothing to show - no need to create the entity Qt3DExtras::QPhongMaterial *mat = _material( mSymbol ); if ( selected ) { // update the material with selection colors mat->setDiffuse( context.map().selectionColor() ); mat->setAmbient( context.map().selectionColor().darker() ); } QgsPointXY origin( context.map().origin().x(), context.map().origin().y() ); QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry; geometry->setPolygons( out.polygons, out.fids, origin, mSymbol.extrusionHeight() ); Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer; renderer->setGeometry( geometry ); // make entity Qt3DCore::QEntity *entity = new Qt3DCore::QEntity; entity->addComponent( renderer ); entity->addComponent( mat ); entity->setParent( parent ); if ( !selected ) entity->findChild<Qt3DRender::QGeometryRenderer *>()->setObjectName( QStringLiteral( "main" ) ); // temporary measure to distinguish between "selected" and "main" }
void QObjectPickerPrivate::propagateEvent(QPickEvent *event, EventType type) { if (!m_entities.isEmpty()) { Qt3DCore::QEntity *entity = m_entities.first(); Qt3DCore::QEntity *parentEntity = nullptr; while (entity != nullptr && entity->parentEntity() != nullptr && !event->isAccepted()) { parentEntity = entity->parentEntity(); const auto components = parentEntity->components(); for (Qt3DCore::QComponent *c : components) { if (auto objectPicker = qobject_cast<Qt3DRender::QObjectPicker *>(c)) { QObjectPickerPrivate *objectPickerPrivate = static_cast<QObjectPickerPrivate *>(QObjectPickerPrivate::get(objectPicker)); switch (type) { case Pressed: objectPickerPrivate->pressedEvent(event); break; case Released: objectPickerPrivate->releasedEvent(event); break; case Clicked: objectPickerPrivate->clickedEvent(event); break; case EventType::Moved: objectPickerPrivate->movedEvent(event); break; } break; } } entity = parentEntity; } } }
void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth) { Qt3DCore::QNodeVector nodes = e->childNodes(); for (int i = 0; i < nodes.count(); ++i) { Qt3DCore::QNode *node = nodes[i]; Qt3DCore::QEntity *entity = qobject_cast<Qt3DCore::QEntity *>(node); if (entity) { QString indent; indent.fill(' ', depth * 2); qDebug().noquote() << indent << "Entity:" << entity << "Components:" << entity->components(); walkEntity(entity, depth + 1); } } }
void PasteEntityCommand::redo() { QModelIndex index = m_sceneModel->getModelIndexByName(m_cutEntityName); if (!index.isValid()) return; QModelIndex parentIndex; EditorSceneItem *item; Qt3DCore::QEntity *pastedEntity; // Duplicate m_cutEntity to m_pastePosition if (m_parentName.isEmpty()) { parentIndex = m_sceneModel->parent(index); item = m_sceneModel->editorSceneItemFromIndex(index); pastedEntity = m_sceneModel->duplicateEntity(item->entity(), nullptr, m_pastePosition, false); } else { parentIndex = m_sceneModel->getModelIndexByName(m_parentName); if (index == parentIndex) return; item = m_sceneModel->editorSceneItemFromIndex(index); EditorSceneItem *parentItem = m_sceneModel->editorSceneItemFromIndex(parentIndex); pastedEntity = m_sceneModel->duplicateEntity(item->entity(), parentItem->entity(), QVector3D(), false); } // Delete selected if cut operation if (m_operation == EditorScene::ClipboardCut) { m_cutEntity = m_sceneModel->duplicateEntity(item->entity(), nullptr); m_cutParentEntityName = m_sceneModel->entityName(m_sceneModel->parent(index)); m_cutFromRow = index.row(); // Grab explicit ownership of the removed entity, // otherwise QML garbage collector may clean it up. QQmlEngine::setObjectOwnership(m_cutEntity, QQmlEngine::CppOwnership); // Delete original m_sceneModel->removeEntity(index); } else { EditorUtils::nameDuplicate(pastedEntity, item->entity(), m_sceneModel); } m_pastedEntityName = pastedEntity->objectName(); m_sceneModel->insertExistingEntity(pastedEntity, -1, parentIndex); m_sceneModel->scene()->setSelection(pastedEntity); }
virtual Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) { Qt3DCore::QEntity *entity = new Qt3DCore::QEntity; // create geometry renderer Qt3DRender::QGeometryRenderer *mesh = new Qt3DRender::QGeometryRenderer; mesh->setGeometry( new QuantizedMeshGeometry( qmt, mTerrain->map3D(), mapSettings.mapToPixel(), mTerrain->terrainToMapTransform(), mesh ) ); entity->addComponent( mesh ); // create material createTextureComponent( entity ); // create transform Qt3DCore::QTransform *transform; transform = new Qt3DCore::QTransform(); entity->addComponent( transform ); const Map3D &map = mTerrain->map3D(); transform->setScale3D( QVector3D( 1.f, map.zExaggeration, 1.f ) ); QgsRectangle mapExtent = mapSettings.extent(); float x0 = mapExtent.xMinimum() - map.originX; float y0 = mapExtent.yMinimum() - map.originY; float x1 = mapExtent.xMaximum() - map.originX; float y1 = mapExtent.yMaximum() - map.originY; float z0 = qmt->header.MinimumHeight, z1 = qmt->header.MaximumHeight; node->setExactBbox( AABB( x0, z0 * map.zExaggeration, -y0, x1, z1 * map.zExaggeration, -y1 ) ); //epsilon = mapExtent.width() / map.tileTextureSize; entity->setEnabled( false ); entity->setParent( parent ); return entity; }
void View3D::initLight() { //Setup light positions, intensities and color QList<QVector3D> lLightPositions; const QColor lightColor(255,255,255); const float lightIntensity = 0.2f; lLightPositions << QVector3D(-0.5,0,0) << QVector3D(0.5,0,0); /*<< QVector3D(0,0,-0.5) << QVector3D(0.5,0,0) << QVector3D(0,0,0.5) << QVector3D(0,0.5,0) << QVector3D(0,-0.5,0);*/ //Create all the lights - make it shine for(int i = 0; i < lLightPositions.size(); ++i) { //Light source Qt3DCore::QEntity* pLightEntity = new Qt3DCore::QEntity(m_pLightEntity); Qt3DCore::QTransform* pTransform = new Qt3DCore::QTransform(); pTransform->setTranslation(lLightPositions.at(i)); pLightEntity->addComponent(pTransform); Qt3DRender::QPointLight *pPointLight = new Qt3DRender::QPointLight(pLightEntity); pPointLight->setColor(lightColor); pPointLight->setIntensity(lightIntensity); pLightEntity->addComponent(pPointLight); m_lLightSources.append(pPointLight); //Uncomment the following to visualize the light sources for debugging: // Qt3DExtras::QSphereMesh* lightSphere = new Qt3DExtras::QSphereMesh(pLightEntity); // lightSphere->setRadius(0.1f); // pLightEntity->addComponent(lightSphere); // Qt3DExtras::QPhongMaterial* material = new Qt3DExtras::QPhongMaterial(pLightEntity); // material->setAmbient(lightColor); // pLightEntity->addComponent(material); } }
int main(int argc, char **argv) { QApplication app(argc, argv); Window *view = new Window(); QWidget *container = QWidget::createWindowContainer(view); QSize screenSize = view->screen()->size(); container->setMinimumSize(QSize(200, 100)); container->setMaximumSize(screenSize); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->setAlignment(Qt::AlignTop); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); widget->setWindowTitle(QStringLiteral("Basic shapes")); Qt3DCore::QAspectEngine engine; engine.registerAspect(new Qt3DRender::QRenderAspect()); Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; engine.registerAspect(input); QVariantMap data; data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(view))); data.insert(QStringLiteral("eventSource"), QVariant::fromValue(view)); engine.setData(data); // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Camera Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(rootEntity); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, 0, -20.0f)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); cameraEntity->setViewCenter(QVector3D(0, 0, 0)); input->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); Qt3DRender::QForwardRenderer *forwardRenderer = new Qt3DRender::QForwardRenderer(); forwardRenderer->setCamera(cameraEntity); forwardRenderer->setClearColor(QColor(QRgb(0x4d4d4f))); frameGraph->setActiveFrameGraph(forwardRenderer); // Setting the FrameGraph rootEntity->addComponent(frameGraph); // Scenemodifier SceneModifier *modifier = new SceneModifier(rootEntity); // Set root object of the scene engine.setRootEntity(rootEntity); // Create control widgets QCommandLinkButton *info = new QCommandLinkButton(); info->setText(QStringLiteral("Qt3D ready-made meshes")); info->setDescription(QStringLiteral("Qt3D provides several ready-made meshes, like torus, cylinder, cube and sphere.")); info->setIconSize(QSize(0,0)); QCheckBox *torusCB = new QCheckBox(widget); torusCB->setChecked(true); torusCB->setText(QStringLiteral("Torus")); QCheckBox *cylinderCB = new QCheckBox(widget); cylinderCB->setChecked(true); cylinderCB->setText(QStringLiteral("Cylinder")); QCheckBox *cuboidCB = new QCheckBox(widget); cuboidCB->setChecked(true); cuboidCB->setText(QStringLiteral("Cuboid")); QCheckBox *sphereCB = new QCheckBox(widget); sphereCB->setChecked(true); sphereCB->setText(QStringLiteral("Sphere")); vLayout->addWidget(info); vLayout->addWidget(torusCB); vLayout->addWidget(cylinderCB); vLayout->addWidget(cuboidCB); vLayout->addWidget(sphereCB); QObject::connect(torusCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableTorus); QObject::connect(cylinderCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableCylinder); QObject::connect(cuboidCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableCuboid); QObject::connect(sphereCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableSphere); torusCB->setChecked(true); cylinderCB->setChecked(true); cuboidCB->setChecked(true); sphereCB->setChecked(true); // Show window widget->show(); widget->resize(1200, 800); // Update the aspect ratio QSize widgetSize = container->size(); float aspectRatio = float(widgetSize.width()) / float(widgetSize.height()); cameraEntity->lens()->setPerspectiveProjection(45.0f, aspectRatio, 0.1f, 1000.0f); return app.exec(); }
void QgsSimpleLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, LineData &out, bool selected ) { if ( out.indexes.isEmpty() ) return; // material (only ambient color is used for the color) Qt3DExtras::QPhongMaterial *mat = _material( mSymbol ); if ( selected ) { // update the material with selection colors mat->setAmbient( context.map().selectionColor() ); } // geometry renderer QByteArray vertexBufferData; vertexBufferData.resize( out.vertices.size() * 3 * sizeof( float ) ); float *rawVertexArray = reinterpret_cast<float *>( vertexBufferData.data() ); int idx = 0; for ( const auto &v : qgis::as_const( out.vertices ) ) { rawVertexArray[idx++] = v.x(); rawVertexArray[idx++] = v.y(); rawVertexArray[idx++] = v.z(); } QByteArray indexBufferData; indexBufferData.resize( out.indexes.size() * sizeof( int ) ); unsigned int *rawIndexArray = reinterpret_cast<unsigned int *>( indexBufferData.data() ); idx = 0; for ( unsigned int indexVal : qgis::as_const( out.indexes ) ) { rawIndexArray[idx++] = indexVal; } Qt3DCore::QEntity *entity = new Qt3DCore::QEntity; Qt3DRender::QBuffer *vertexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::VertexBuffer, entity ); vertexBuffer->setData( vertexBufferData ); Qt3DRender::QBuffer *indexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::IndexBuffer, entity ); indexBuffer->setData( indexBufferData ); Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute( entity ); positionAttribute->setAttributeType( Qt3DRender::QAttribute::VertexAttribute ); positionAttribute->setBuffer( vertexBuffer ); positionAttribute->setVertexBaseType( Qt3DRender::QAttribute::Float ); positionAttribute->setVertexSize( 3 ); positionAttribute->setName( Qt3DRender::QAttribute::defaultPositionAttributeName() ); Qt3DRender::QAttribute *indexAttribute = new Qt3DRender::QAttribute( entity ); indexAttribute->setAttributeType( Qt3DRender::QAttribute::IndexAttribute ); indexAttribute->setBuffer( indexBuffer ); indexAttribute->setVertexBaseType( Qt3DRender::QAttribute::UnsignedInt ); Qt3DRender::QGeometry *geom = new Qt3DRender::QGeometry; geom->addAttribute( positionAttribute ); geom->addAttribute( indexAttribute ); Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer; renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStrip ); renderer->setGeometry( geom ); renderer->setVertexCount( out.vertices.count() ); renderer->setPrimitiveRestartEnabled( true ); renderer->setRestartIndexValue( 0 ); // make entity entity->addComponent( renderer ); entity->addComponent( mat ); entity->setParent( parent ); }
void filterEntities_data() { QTest::addColumn<Qt3DCore::QEntity *>("entitySubtree"); QTest::addColumn<Qt3DCore::QNodeIdVector>("layerFilterIds"); QTest::addColumn<Qt3DCore::QNodeIdVector>("expectedSelectedEntities"); { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Q_UNUSED(childEntity1); Q_UNUSED(childEntity2); Q_UNUSED(childEntity3); QTest::newRow("EntitiesNoLayerNoLayerFilterNoDiscardNoRecursive-ShouldSelectAll") << rootEntity << Qt3DCore::QNodeIdVector() << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id() << childEntity2->id() << childEntity3->id() ); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); Q_UNUSED(childEntity1); Q_UNUSED(childEntity2); Q_UNUSED(childEntity3); QTest::newRow("EntityNoLayerWithLayerFilterWithNoFilter-ShouldSelectNone") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << Qt3DCore::QNodeIdVector(); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Q_UNUSED(childEntity1); Q_UNUSED(childEntity2); Q_UNUSED(childEntity3); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer); QTest::newRow("AcceptAny-NoLayerWithLayerFilterWithFilter-ShouldSelectNone") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << Qt3DCore::QNodeIdVector(); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); childEntity1->addComponent(layer); childEntity2->addComponent(layer); childEntity3->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer); QTest::newRow("AcceptAny-LayerWithLayerFilterWithFilter-ShouldSelectAllButRoot") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id() << childEntity2->id() << childEntity3->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Q_UNUSED(childEntity1) Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); childEntity2->addComponent(layer2); childEntity3->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer); layerFilter->addLayer(layer2); QTest::newRow("AcceptAny-LayerWithLayerFilterWithFilter-ShouldSelectChild2And3") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity2->id() << childEntity3->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); childEntity1->addComponent(layer); childEntity2->addComponent(layer); childEntity3->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer2); QTest::newRow("AcceptAny-LayerWithLayerFilterWithFilter-ShouldSelectNone") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << Qt3DCore::QNodeIdVector(); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); childEntity1->setEnabled(false); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); childEntity1->addComponent(layer); childEntity2->addComponent(layer); childEntity3->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer); QTest::newRow("AcceptAny-LayerWithEntityDisabled-ShouldSelectOnlyEntityEnabled") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity2->id() << childEntity3->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); rootEntity->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->addLayer(layer); QTest::newRow("AcceptAny-RecursiveLayerOnRoot-ShouldSelectAll") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id() << childEntity2->id() << childEntity3->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Q_UNUSED(childEntity1); Q_UNUSED(childEntity2); Q_UNUSED(childEntity3); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); rootEntity->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers); layerFilter->addLayer(layer); QTest::newRow("DiscardAny-RecursiveLayerLayerFilterDiscardOnRoot-ShouldSelectNone") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers); layerFilter->addLayer(layer); QTest::newRow("DiscardAny-LayerLayerFilterDiscardOnRoot-ShouldSelectAllButRoot") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id() << childEntity2->id() << childEntity3->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer2); childEntity2->addComponent(layer3); childEntity3->addComponent(layer2); childEntity3->addComponent(layer3); childEntity3->addComponent(layer); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers); layerFilter->addLayer(layer2); layerFilter->addLayer(layer3); QTest::newRow("DiscardAny-LayerLayerFilterDiscardOnRoot-ShouldSelectRoot") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer3); childEntity1->addComponent(layer2); childEntity2->addComponent(layer); childEntity2->addComponent(layer3); childEntity3->addComponent(layer); childEntity3->addComponent(layer2); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::AcceptAllMatchingLayers); layerFilter->addLayer(layer2); layerFilter->addLayer(layer3); QTest::newRow("AcceptAll-LayerFilterWith2LayersNonRecursive-ShouldSelectChild1") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer3); childEntity1->addComponent(layer2); childEntity2->addComponent(layer3); childEntity3->addComponent(layer2); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::AcceptAllMatchingLayers); layerFilter->addLayer(layer); layerFilter->addLayer(layer3); QTest::newRow("AcceptAll-LayerFilterWith2LayersRecursive-ShouldSelectChild12") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id() << childEntity2->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer3); childEntity1->addComponent(layer2); childEntity2->addComponent(layer); childEntity2->addComponent(layer3); childEntity3->addComponent(layer2); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::AcceptAllMatchingLayers); layerFilter->addLayer(layer); layerFilter->addLayer(layer3); QTest::newRow("AcceptAll-LayerFilterWith2LayersRecursiveAndDirectReferenceToRecursiveLayer-ShouldSelectChild12") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id() << childEntity2->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer); childEntity1->addComponent(layer2); childEntity2->addComponent(layer); childEntity2->addComponent(layer3); childEntity3->addComponent(layer2); childEntity3->addComponent(layer3); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAllMatchingLayers); layerFilter->addLayer(layer2); layerFilter->addLayer(layer3); QTest::newRow("DiscardAll-LayerFilterWith2Layers-ShouldSelectRootAndChild12") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id() << childEntity2->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer2); childEntity2->addComponent(layer3); childEntity3->addComponent(layer3); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAllMatchingLayers); layerFilter->addLayer(layer); layerFilter->addLayer(layer3); QTest::newRow("DiscardAll-LayerFilterWith2LayersRecursive-ShouldSelectRootAndChild1") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer2); childEntity1->addComponent(layer); childEntity2->addComponent(layer3); childEntity3->addComponent(layer3); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAllMatchingLayers); layerFilter->addLayer(layer); layerFilter->addLayer(layer3); QTest::newRow("DiscardAll-LayerFilterWith2LayersRecursiveAndDirectReference-ShouldSelectRootAndChild1") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer4 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer5 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer2); childEntity1->addComponent(layer3); childEntity2->addComponent(layer2); childEntity2->addComponent(layer3); childEntity2->addComponent(layer4); childEntity2->addComponent(layer5); childEntity3->addComponent(layer2); childEntity3->addComponent(layer3); childEntity3->addComponent(layer5); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::AcceptAllMatchingLayers); layerFilter->addLayer(layer); layerFilter->addLayer(layer2); layerFilter->addLayer(layer3); Qt3DRender::QLayerFilter *layerFilter2 = new Qt3DRender::QLayerFilter(rootEntity); layerFilter2->setFilterMode(Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers); layerFilter2->addLayer(layer4); layerFilter2->addLayer(layer5); QTest::newRow("NestedFiltering-SelectAllOfLayer123AndNoneOf45-ShouldChild1") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id() << layerFilter2->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id()); } { Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); Qt3DCore::QEntity *childEntity1 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity3 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity4 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *childEntity5 = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QLayer *layer = new Qt3DRender::QLayer(rootEntity); layer->setRecursive(true); Qt3DRender::QLayer *layer2 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer3 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer4 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer5 = new Qt3DRender::QLayer(rootEntity); Qt3DRender::QLayer *layer6 = new Qt3DRender::QLayer(rootEntity); rootEntity->addComponent(layer); childEntity1->addComponent(layer2); childEntity1->addComponent(layer3); childEntity2->addComponent(layer2); childEntity2->addComponent(layer3); childEntity2->addComponent(layer4); childEntity2->addComponent(layer5); childEntity3->addComponent(layer2); childEntity3->addComponent(layer5); childEntity4->addComponent(layer2); childEntity4->addComponent(layer); childEntity4->addComponent(layer3); childEntity4->addComponent(layer6); childEntity5->addComponent(layer3); childEntity5->addComponent(layer4); childEntity5->addComponent(layer6); Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(rootEntity); layerFilter->setFilterMode(Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers); layerFilter->addLayer(layer5); layerFilter->addLayer(layer4); Qt3DRender::QLayerFilter *layerFilter2 = new Qt3DRender::QLayerFilter(rootEntity); layerFilter2->setFilterMode(Qt3DRender::QLayerFilter::AcceptAnyMatchingLayers); layerFilter2->addLayer(layer2); layerFilter2->addLayer(layer3); Qt3DRender::QLayerFilter *layerFilter3 = new Qt3DRender::QLayerFilter(rootEntity); layerFilter3->setFilterMode(Qt3DRender::QLayerFilter::AcceptAllMatchingLayers); layerFilter3->addLayer(layer); layerFilter3->addLayer(layer6); QTest::newRow("NestedFiltering-SelectAllNoneOfAnyLayer45AndAnyOf23AndAllOf16-ShouldSelectChild4-Step1") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id()) << (Qt3DCore::QNodeIdVector() << rootEntity->id() << childEntity1->id() << childEntity4->id() ); QTest::newRow("NestedFiltering-SelectAllNoneOfAnyLayer45AndAnyOf23AndAllOf16-ShouldSelectChild4-Step2") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id() << layerFilter2->id()) << (Qt3DCore::QNodeIdVector() << childEntity1->id() << childEntity4->id()); QTest::newRow("NestedFiltering-SelectAllNoneOfAnyLayer45AndAnyOf23AndAllOf16-ShouldSelectChild4-Step3") << rootEntity << (Qt3DCore::QNodeIdVector() << layerFilter->id() << layerFilter2->id() << layerFilter3->id()) << (Qt3DCore::QNodeIdVector() << childEntity4->id()); } }