From 174cd487b4644a69853de9007b90cba989afe344 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Thu, 30 Jul 2020 12:03:46 +0100 Subject: Make sample meshes geometry renderers again Introduce new geometry view class for each. Change-Id: I8e9a8f3a078d4cc63f9656ae8142e39f05d755c7 Reviewed-by: Paul Lemire --- examples/qt3d/3d-text/main.cpp | 5 +- examples/qt3d/anaglyph-rendering/main.qml | 24 +-- examples/qt3d/audio-visualizer-qml/Visualizer.qml | 18 +- examples/qt3d/basicshapes-cpp/scenemodifier.cpp | 25 +-- examples/qt3d/lights/PlaneEntity.qml | 15 +- examples/qt3d/lights/main.qml | 18 +- examples/qt3d/phong-cubes/CubeEntity.qml | 10 +- examples/qt3d/planets-qml/Planet.qml | 12 +- examples/qt3d/qardboard/main.qml | 24 +-- examples/qt3d/scene2d/main.qml | 3 +- examples/qt3d/scene3d/AnimatedEntity.qml | 18 +- examples/qt3d/scene3dview/AnimatedEntity.qml | 18 +- examples/qt3d/shadow-map-qml/GroundPlane.qml | 10 +- examples/qt3d/simple-cpp/main.cpp | 9 +- examples/qt3d/simple-qml/main.qml | 18 +- examples/qt3d/simplecustommaterial/PlaneModel.qml | 10 +- examples/qt3d/wave/Wave.qml | 10 +- src/extras/CMakeLists.txt | 6 + src/extras/defaults/qskyboxentity.cpp | 4 +- src/extras/geometries/geometries.pri | 16 +- src/extras/geometries/qconegeometryview.cpp | 240 +++++++++++++++++++++ src/extras/geometries/qconegeometryview.h | 108 ++++++++++ src/extras/geometries/qconemesh.cpp | 56 +++-- src/extras/geometries/qconemesh.h | 4 +- src/extras/geometries/qcuboidgeometryview.cpp | 227 +++++++++++++++++++ src/extras/geometries/qcuboidgeometryview.h | 108 ++++++++++ src/extras/geometries/qcuboidmesh.cpp | 44 ++-- src/extras/geometries/qcuboidmesh.h | 4 +- src/extras/geometries/qcylindergeometryview.cpp | 184 ++++++++++++++++ src/extras/geometries/qcylindergeometryview.h | 97 +++++++++ src/extras/geometries/qcylindermesh.cpp | 32 +-- src/extras/geometries/qcylindermesh.h | 4 +- src/extras/geometries/qplanegeometryview.cpp | 175 +++++++++++++++ src/extras/geometries/qplanegeometryview.h | 98 +++++++++ src/extras/geometries/qplanemesh.cpp | 32 +-- src/extras/geometries/qplanemesh.h | 4 +- src/extras/geometries/qspheregeometryview.cpp | 174 +++++++++++++++ src/extras/geometries/qspheregeometryview.h | 98 +++++++++ src/extras/geometries/qspheremesh.cpp | 32 +-- src/extras/geometries/qspheremesh.h | 4 +- src/extras/geometries/qtorusgeometryview.cpp | 177 +++++++++++++++ src/extras/geometries/qtorusgeometryview.h | 96 +++++++++ src/extras/geometries/qtorusmesh.cpp | 31 +-- src/extras/geometries/qtorusmesh.h | 4 +- src/plugins/sceneparsers/gltf/gltfimporter.cpp | 18 +- .../sceneparsers/gltfexport/gltfexporter.cpp | 13 +- .../imports/extras/qt3dquick3dextrasplugin.cpp | 12 ++ .../tst_aspects_startup_shutdown.cpp | 9 +- tests/auto/render/boundingsphere/cube.qml | 2 +- tests/auto/render/boundingsphere/sphere.qml | 2 +- tests/auto/render/gltfplugins/tst_gltfplugins.cpp | 71 +++--- .../testscene_cameraposition.qml | 2 +- .../testscene_childentity.qml | 2 +- .../testscene_dragdisabled.qml | 2 +- .../testscene_dragenabled.qml | 2 +- .../testscene_dragenabledhoverenabled.qml | 2 +- .../testscene_dragenabledoverlapping.qml | 2 +- .../testscene_improperframegraph.qml | 2 +- .../pickboundingvolumejob/testscene_nopicking.qml | 2 +- .../testscene_parententity.qml | 10 +- .../testscene_pickersdisabled.qml | 2 +- .../testscene_priorityoverlapping.qml | 2 +- .../pickboundingvolumejob/testscene_viewports.qml | 2 +- tests/auto/render/picking/tst_picking.cpp | 7 +- .../raycastingjob/testscene_screenraycasting.qml | 12 +- .../raycastingjob/testscene_worldraycasting.qml | 12 +- .../testscene_worldraycastingalllayers.qml | 12 +- .../testscene_worldraycastinglayer.qml | 12 +- .../testscene_worldraycastingparentlayer.qml | 12 +- tests/benchmarks/render/jobs/tst_bench_jobs.cpp | 5 +- tests/manual/animation-keyframe-blendtree/main.qml | 3 +- .../animation-keyframe-programmatic/main.qml | 3 +- tests/manual/animation-keyframe-simple/main.qml | 3 +- tests/manual/bigmodel-qml/MyEntity.qml | 6 +- tests/manual/bigscene-cpp/main.cpp | 5 +- tests/manual/bigscene-instanced-qml/main.qml | 17 +- tests/manual/blitframebuffer-qml/main.qml | 18 +- tests/manual/boundingvolumes/AnimatedEntity.qml | 12 +- tests/manual/clip-planes-qml/ClipPlaneEntity.qml | 10 +- tests/manual/clip-planes-qml/ClippingPlanes.qml | 10 +- tests/manual/component-changes/main.cpp | 8 +- tests/manual/compressed_textures/main.qml | 2 +- tests/manual/cylinder-cpp/main.cpp | 5 +- tests/manual/cylinder-parent-test/main.cpp | 75 ++++--- tests/manual/cylinder-qml/main.qml | 12 +- tests/manual/deferred-renderer-cpp/sceneentity.cpp | 7 +- .../deferred-renderer-cpp/screenquadentity.cpp | 5 +- .../deferred-renderer-qml/GBufferDebugger.qml | 10 +- tests/manual/deferred-renderer-qml/SceneEntity.qml | 8 +- .../deferred-renderer-qml/ScreenQuadEntity.qml | 10 +- tests/manual/dragging/main.qml | 20 +- .../dynamic-model-loader-qml/CuboidEntity.qml | 10 +- .../dynamic-model-loader-qml/SphereEntity.qml | 6 +- tests/manual/dynamic-model-loader-qml/main.qml | 15 +- tests/manual/dynamicscene-cpp/boxentity.cpp | 5 +- tests/manual/enabled-qml/main.qml | 14 +- tests/manual/keyboardinput-qml/SphereEntity.qml | 2 +- tests/manual/layerfilter-qml/main.qml | 8 +- tests/manual/loader-qml/CuboidEntity.qml | 10 +- tests/manual/loader-qml/SphereEntity.qml | 6 +- tests/manual/loader-qml/main.qml | 12 +- tests/manual/lod/ConeEntity.qml | 10 +- tests/manual/lod/CuboidEntity.qml | 10 +- tests/manual/lod/CylinderEntity.qml | 8 +- tests/manual/lod/SphereEntity.qml | 6 +- tests/manual/lod/main.qml | 16 +- tests/manual/manual-renderloop/main.cpp | 4 +- tests/manual/mesh-morphing/main.cpp | 12 +- tests/manual/mouseinput-qml/main.qml | 6 +- tests/manual/multiplewindows-qml/Scene.qml | 18 +- tests/manual/paintedtexture-cpp/scene.cpp | 5 +- tests/manual/picking-qml/main.qml | 6 +- tests/manual/plasma/main.qml | 10 +- tests/manual/proximityfilter/main.qml | 3 +- tests/manual/qtbug-72236/main.cpp | 5 +- tests/manual/qtbug-76766/PostProcess.qml | 10 +- tests/manual/qtbug-76766/SceneRoot.qml | 8 +- tests/manual/raster-cpp/main.cpp | 5 +- tests/manual/raster-qml/main.qml | 12 +- tests/manual/raycasting-qml/CylinderEntity.qml | 12 +- tests/manual/render-qml-to-texture-qml/main.qml | 10 +- tests/manual/render-qml-to-texture/main.cpp | 4 +- tests/manual/rendercapture-cpp/main.cpp | 9 +- .../manual/rendercapture-qml-fbo/CaptureScene.qml | 18 +- tests/manual/rendercapture-qml/CaptureScene.qml | 18 +- tests/manual/rendertarget-cpp/main.cpp | 13 +- tests/manual/scene3d-in-sync/main.qml | 10 +- tests/manual/scene3d-loader/AnimatedEntity.qml | 18 +- tests/manual/scene3d-loader/Scene2.qml | 12 +- tests/manual/scene3d-visibility/main.qml | 18 +- tests/manual/shader-image-qml/main.qml | 3 +- tests/manual/shared_texture_image/main.qml | 2 +- tests/manual/sharedtexture/main.cpp | 5 +- tests/manual/sharedtextureqml/main.qml | 2 +- tests/manual/simple-shaders-qml/main.qml | 12 +- tests/manual/skybox/Skybox.qml | 10 +- tests/manual/skybox/main.qml | 2 +- tests/manual/subtree-enabler-qml/main.qml | 4 +- tests/manual/texture-updates-cpp/scene.cpp | 5 +- tests/manual/texture_property_updates/main.qml | 2 +- tests/manual/transparency-qml-scene3d/Scene.qml | 18 +- tests/manual/transparency-qml/main.qml | 18 +- tests/manual/video-texture-qml/main.qml | 3 +- 143 files changed, 2392 insertions(+), 864 deletions(-) create mode 100644 src/extras/geometries/qconegeometryview.cpp create mode 100644 src/extras/geometries/qconegeometryview.h create mode 100644 src/extras/geometries/qcuboidgeometryview.cpp create mode 100644 src/extras/geometries/qcuboidgeometryview.h create mode 100644 src/extras/geometries/qcylindergeometryview.cpp create mode 100644 src/extras/geometries/qcylindergeometryview.h create mode 100644 src/extras/geometries/qplanegeometryview.cpp create mode 100644 src/extras/geometries/qplanegeometryview.h create mode 100644 src/extras/geometries/qspheregeometryview.cpp create mode 100644 src/extras/geometries/qspheregeometryview.h create mode 100644 src/extras/geometries/qtorusgeometryview.cpp create mode 100644 src/extras/geometries/qtorusgeometryview.h diff --git a/examples/qt3d/3d-text/main.cpp b/examples/qt3d/3d-text/main.cpp index e7da8af45..a9e1fc277 100644 --- a/examples/qt3d/3d-text/main.cpp +++ b/examples/qt3d/3d-text/main.cpp @@ -72,11 +72,8 @@ int main(int argc, char *argv[]) planeTransform->setTranslation(QVector3D(0, 0, 0)); planeMaterial->setDiffuse(QColor(150, 150, 150)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(planeMesh); - plane->addComponent(planeMaterial); - plane->addComponent(renderer); + plane->addComponent(planeMesh); plane->addComponent(planeTransform); } diff --git a/examples/qt3d/anaglyph-rendering/main.qml b/examples/qt3d/anaglyph-rendering/main.qml index 1301a510a..89e5c3664 100644 --- a/examples/qt3d/anaglyph-rendering/main.qml +++ b/examples/qt3d/anaglyph-rendering/main.qml @@ -92,13 +92,11 @@ Entity { // Cylinder Entity { - property GeometryRenderer cylinder: GeometryRenderer { - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + property CylinderMesh cylinder: CylinderMesh { + radius: 1 + length: 3 + rings: 100 + slices: 20 } property Transform transform: Transform { id: cylinderTransform @@ -198,13 +196,11 @@ Entity { readonly property real det: 1.0 / model delegate: Entity { components: [ - GeometryRenderer { - view: TorusMesh { - radius: 35 - minorRadius: 5 - rings: 100 - slices: 20 - } + TorusMesh { + radius: 35 + minorRadius: 5 + rings: 100 + slices: 20 }, Transform { id: transform diff --git a/examples/qt3d/audio-visualizer-qml/Visualizer.qml b/examples/qt3d/audio-visualizer-qml/Visualizer.qml index e6ba6891b..42373f950 100644 --- a/examples/qt3d/audio-visualizer-qml/Visualizer.qml +++ b/examples/qt3d/audio-visualizer-qml/Visualizer.qml @@ -157,13 +157,11 @@ Entity { //![1] // Bars - GeometryRenderer { + CuboidMesh { id: barMesh - view: CuboidMesh { - xExtent: 0.1 - yExtent: 0.1 - zExtent: 0.1 - } + xExtent: 0.1 + yExtent: 0.1 + zExtent: 0.1 } NodeInstantiator { @@ -191,12 +189,10 @@ Entity { Entity { id: titlePlane - GeometryRenderer { + PlaneMesh { id: titlePlaneMesh - view: PlaneMesh { - width: 550 - height: 100 - } + width: 550 + height: 100 } Transform { diff --git a/examples/qt3d/basicshapes-cpp/scenemodifier.cpp b/examples/qt3d/basicshapes-cpp/scenemodifier.cpp index fa268afa6..4946f1a48 100644 --- a/examples/qt3d/basicshapes-cpp/scenemodifier.cpp +++ b/examples/qt3d/basicshapes-cpp/scenemodifier.cpp @@ -82,9 +82,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) // Torus //! [3] m_torusEntity = new Qt3DCore::QEntity(m_rootEntity); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(m_torus); - m_torusEntity->addComponent(renderer); + m_torusEntity->addComponent(m_torus); m_torusEntity->addComponent(torusMaterial); m_torusEntity->addComponent(torusTransform); //! [3] @@ -110,9 +108,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) // Cone { m_coneEntity = new Qt3DCore::QEntity(m_rootEntity); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cone); - m_coneEntity->addComponent(renderer); + m_coneEntity->addComponent(cone); m_coneEntity->addComponent(coneMaterial); m_coneEntity->addComponent(coneTransform); } @@ -136,9 +132,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) // Cylinder { m_cylinderEntity = new Qt3DCore::QEntity(m_rootEntity); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cylinder); - m_cylinderEntity->addComponent(renderer); + m_cylinderEntity->addComponent(cylinder); m_cylinderEntity->addComponent(cylinderMaterial); m_cylinderEntity->addComponent(cylinderTransform); } @@ -157,9 +151,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) //Cuboid { m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cuboid); - m_cuboidEntity->addComponent(renderer); + m_cuboidEntity->addComponent(cuboid); m_cuboidEntity->addComponent(cuboidMaterial); m_cuboidEntity->addComponent(cuboidTransform); } @@ -181,9 +173,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) // Plane { m_planeEntity = new Qt3DCore::QEntity(m_rootEntity); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(planeMesh); - m_planeEntity->addComponent(renderer); + m_planeEntity->addComponent(planeMesh); m_planeEntity->addComponent(planeMaterial); m_planeEntity->addComponent(planeTransform); } @@ -203,12 +193,9 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) Qt3DExtras::QPhongMaterial *sphereMaterial = new Qt3DExtras::QPhongMaterial(); sphereMaterial->setDiffuse(QColor(QRgb(0xa69929))); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - // Sphere m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity); - m_sphereEntity->addComponent(renderer); + m_sphereEntity->addComponent(sphereMesh); m_sphereEntity->addComponent(sphereMaterial); m_sphereEntity->addComponent(sphereTransform); } diff --git a/examples/qt3d/lights/PlaneEntity.qml b/examples/qt3d/lights/PlaneEntity.qml index 1e84543f6..268c59add 100644 --- a/examples/qt3d/lights/PlaneEntity.qml +++ b/examples/qt3d/lights/PlaneEntity.qml @@ -61,17 +61,14 @@ Entity { property alias resolution: mesh.meshResolution property Material material - components: [ transform, renderer, root.material ] + components: [ transform, mesh, root.material ] Transform { id: transform } - GeometryRenderer { - id: renderer - view: PlaneMesh { - id: mesh - width: 1.0 - height: 1.0 - meshResolution: Qt.size(2, 2) - } + PlaneMesh { + id: mesh + width: 1.0 + height: 1.0 + meshResolution: Qt.size(2, 2) } } diff --git a/examples/qt3d/lights/main.qml b/examples/qt3d/lights/main.qml index c647788fe..fc7cca42c 100644 --- a/examples/qt3d/lights/main.qml +++ b/examples/qt3d/lights/main.qml @@ -95,10 +95,8 @@ Entity Entity { id: redLight components: [ - GeometryRenderer { - view: SphereMesh { - radius: 2 - } + SphereMesh { + radius: 2 }, Transform { translation: Qt.vector3d(2.0, 8.0, -2.0) @@ -120,10 +118,8 @@ Entity Entity { id: greenLight components: [ - GeometryRenderer { - view: SphereMesh { - radius: 2 - } + SphereMesh { + radius: 2 }, Transform { translation: Qt.vector3d(0.0, 3.0, 4.0) @@ -145,10 +141,8 @@ Entity Entity { id: spotLight components: [ - GeometryRenderer { - view: SphereMesh { - radius: 2 - } + SphereMesh { + radius: 2 }, Transform { translation: Qt.vector3d(-20.0, 40.0, 0.0) diff --git a/examples/qt3d/phong-cubes/CubeEntity.qml b/examples/qt3d/phong-cubes/CubeEntity.qml index 2c3939662..558f53327 100644 --- a/examples/qt3d/phong-cubes/CubeEntity.qml +++ b/examples/qt3d/phong-cubes/CubeEntity.qml @@ -60,13 +60,11 @@ Entity { components: [mesh, material, transform] - GeometryRenderer { + CuboidMesh { id: mesh - view: CuboidMesh { - xExtent: 0.5 - yExtent: xExtent - zExtent: xExtent - } + xExtent: 0.5 + yExtent: xExtent + zExtent: xExtent } Transform { diff --git a/examples/qt3d/planets-qml/Planet.qml b/examples/qt3d/planets-qml/Planet.qml index bbec74444..231cd7bac 100644 --- a/examples/qt3d/planets-qml/Planet.qml +++ b/examples/qt3d/planets-qml/Planet.qml @@ -51,7 +51,7 @@ import Qt3D.Render 2.0 import Qt3D.Extras 2.0 -GeometryRenderer { +SphereMesh { property real r: 0 property real x: 0 property real y: 0 @@ -59,10 +59,8 @@ GeometryRenderer { property real roll: 0 property real tilt: 0 - view: SphereMesh { - radius: 1.0 - generateTangents: true - rings: 64 - slices: 64 - } + radius: 1.0 + generateTangents: true + rings: 64 + slices: 64 } diff --git a/examples/qt3d/qardboard/main.qml b/examples/qt3d/qardboard/main.qml index 906b43232..a3be91ac6 100644 --- a/examples/qt3d/qardboard/main.qml +++ b/examples/qt3d/qardboard/main.qml @@ -122,13 +122,11 @@ QardboardRootEntity { // Cylinder Entity { - property GeometryRenderer cylinder: GeometryRenderer { - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + property GeometryRenderer cylinder: CylinderMesh { + radius: 1 + length: 3 + rings: 100 + slices: 20 } property Transform transform: Transform { id: cylinderTransform @@ -182,13 +180,11 @@ QardboardRootEntity { readonly property real det: 1.0 / model delegate: Entity { components: [ - GeometryRenderer { - view: TorusMesh { - radius: 35 - minorRadius: 5 - rings: 100 - slices: 20 - } + TorusMesh { + radius: 35 + minorRadius: 5 + rings: 100 + slices: 20 }, Transform { id: transform diff --git a/examples/qt3d/scene2d/main.qml b/examples/qt3d/scene2d/main.qml index 5ce70ba63..37727b952 100644 --- a/examples/qt3d/scene2d/main.qml +++ b/examples/qt3d/scene2d/main.qml @@ -135,9 +135,8 @@ Entity { rotation: fromAxisAndAngle(Qt.vector3d(0,1,0), cube.rotationAngle) } - GeometryRenderer { + CuboidMesh { id: cubeMesh - view: CuboidMesh { } } ObjectPicker { diff --git a/examples/qt3d/scene3d/AnimatedEntity.qml b/examples/qt3d/scene3d/AnimatedEntity.qml index 962317a6b..02e1148e2 100644 --- a/examples/qt3d/scene3d/AnimatedEntity.qml +++ b/examples/qt3d/scene3d/AnimatedEntity.qml @@ -93,14 +93,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -114,11 +112,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/examples/qt3d/scene3dview/AnimatedEntity.qml b/examples/qt3d/scene3dview/AnimatedEntity.qml index 774928f74..db27f3584 100644 --- a/examples/qt3d/scene3dview/AnimatedEntity.qml +++ b/examples/qt3d/scene3dview/AnimatedEntity.qml @@ -90,14 +90,12 @@ Entity { diffuse: sceneColor } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -111,11 +109,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/examples/qt3d/shadow-map-qml/GroundPlane.qml b/examples/qt3d/shadow-map-qml/GroundPlane.qml index 072e3663a..d78f5b07a 100644 --- a/examples/qt3d/shadow-map-qml/GroundPlane.qml +++ b/examples/qt3d/shadow-map-qml/GroundPlane.qml @@ -56,13 +56,11 @@ Entity { id: root property Material material - GeometryRenderer { + PlaneMesh { id: groundMesh - view: PlaneMesh { - width: 50 - height: width - meshResolution: Qt.size(2, 2) - } + width: 50 + height: width + meshResolution: Qt.size(2, 2) } Transform { diff --git a/examples/qt3d/simple-cpp/main.cpp b/examples/qt3d/simple-cpp/main.cpp index 80da0552a..4e689b4ac 100644 --- a/examples/qt3d/simple-cpp/main.cpp +++ b/examples/qt3d/simple-cpp/main.cpp @@ -91,9 +91,7 @@ Qt3DCore::QEntity *createScene() torusTransform->setScale3D(QVector3D(1.5, 1, 0.5)); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(torusMesh); - torusEntity->addComponent(renderer); + torusEntity->addComponent(torusMesh); torusEntity->addComponent(torusTransform); torusEntity->addComponent(material); @@ -117,10 +115,7 @@ Qt3DCore::QEntity *createScene() sphereRotateTransformAnimation->setLoopCount(-1); sphereRotateTransformAnimation->start(); - renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(sphereMesh); sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(material); diff --git a/examples/qt3d/simple-qml/main.qml b/examples/qt3d/simple-qml/main.qml index 60b9a0990..01910cffb 100644 --- a/examples/qt3d/simple-qml/main.qml +++ b/examples/qt3d/simple-qml/main.qml @@ -89,14 +89,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } @@ -111,11 +109,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/examples/qt3d/simplecustommaterial/PlaneModel.qml b/examples/qt3d/simplecustommaterial/PlaneModel.qml index bc95f8600..b5271fe0c 100644 --- a/examples/qt3d/simplecustommaterial/PlaneModel.qml +++ b/examples/qt3d/simplecustommaterial/PlaneModel.qml @@ -67,12 +67,10 @@ Entity { rotationX: 45 } - GeometryRenderer { + PlaneMesh { id: mesh - view: PlaneMesh { - width: 1.0 - height: 1.0 - meshResolution: Qt.size(2, 2) - } + width: 1.0 + height: 1.0 + meshResolution: Qt.size(2, 2) } } diff --git a/examples/qt3d/wave/Wave.qml b/examples/qt3d/wave/Wave.qml index 8614fee5b..2f297906d 100644 --- a/examples/qt3d/wave/Wave.qml +++ b/examples/qt3d/wave/Wave.qml @@ -81,12 +81,10 @@ Entity { diffuse: Qt.rgba( root.intensity, root.intensity, root.intensity, 1.0 ) // Set how bright the wave is } - GeometryRenderer { + PlaneMesh { id: mesh - view: PlaneMesh { - width: 25.0 - height: 5.0 - meshResolution: Qt.size( 125, 50 ) - } + width: 25.0 + height: 5.0 + meshResolution: Qt.size( 125, 50 ) } } diff --git a/src/extras/CMakeLists.txt b/src/extras/CMakeLists.txt index ec53dd79f..ad3d98148 100644 --- a/src/extras/CMakeLists.txt +++ b/src/extras/CMakeLists.txt @@ -32,16 +32,22 @@ qt_add_module(3DExtras defaults/qt3dwindow.cpp defaults/qt3dwindow.h defaults/qt3dwindow_p.h defaults/qtexturematerial.cpp defaults/qtexturematerial.h defaults/qtexturematerial_p.h geometries/qconegeometry.cpp geometries/qconegeometry.h geometries/qconegeometry_p.h + geometries/qconegeometryview.cpp geometries/qconegeometryview.h geometries/qconemesh.cpp geometries/qconemesh.h geometries/qcuboidgeometry.cpp geometries/qcuboidgeometry.h geometries/qcuboidgeometry_p.h + geometries/qcuboidgeometryview.cpp geometries/qcuboidgeometryview.h geometries/qcuboidmesh.cpp geometries/qcuboidmesh.h geometries/qcylindergeometry.cpp geometries/qcylindergeometry.h geometries/qcylindergeometry_p.h + geometries/qcylindergeometryview.cpp geometries/qcylindergeometryview.h geometries/qcylindermesh.cpp geometries/qcylindermesh.h geometries/qplanegeometry.cpp geometries/qplanegeometry.h geometries/qplanegeometry_p.h + geometries/qplanegeometryview.cpp geometries/qplanegeometryview.h geometries/qplanemesh.cpp geometries/qplanemesh.h geometries/qspheregeometry.cpp geometries/qspheregeometry.h geometries/qspheregeometry_p.h + geometries/qspheregeometryview.cpp geometries/qspheregeometryview.h geometries/qspheremesh.cpp geometries/qspheremesh.h geometries/qtorusgeometry.cpp geometries/qtorusgeometry.h geometries/qtorusgeometry_p.h + geometries/qtorusgeometryview.cpp geometries/qtorusgeometryview.h geometries/qtorusmesh.cpp geometries/qtorusmesh.h qt3dextras_global.h text/areaallocator.cpp text/areaallocator_p.h diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp index b12c0b304..163cf63a4 100644 --- a/src/extras/defaults/qskyboxentity.cpp +++ b/src/extras/defaults/qskyboxentity.cpp @@ -185,9 +185,7 @@ void QSkyboxEntityPrivate::init() m_skyboxTexture->addTextureImage(m_negYImage); m_skyboxTexture->addTextureImage(m_negZImage); - QGeometryRenderer *renderer = new QGeometryRenderer; - renderer->setView(m_mesh); - q_func()->addComponent(renderer); + q_func()->addComponent(m_mesh); q_func()->addComponent(m_material); } diff --git a/src/extras/geometries/geometries.pri b/src/extras/geometries/geometries.pri index 7a2932cb7..2e2efd24b 100644 --- a/src/extras/geometries/geometries.pri +++ b/src/extras/geometries/geometries.pri @@ -1,35 +1,47 @@ HEADERS += \ $$PWD/qconegeometry.h \ $$PWD/qconegeometry_p.h \ + $$PWD/qconegeometryview.h \ $$PWD/qconemesh.h \ $$PWD/qcuboidmesh.h \ $$PWD/qcylindergeometry.h \ $$PWD/qcylindergeometry_p.h \ + $$PWD/qcylindergeometryview.h \ $$PWD/qcylindermesh.h \ $$PWD/qplanemesh.h \ $$PWD/qspheremesh.h \ $$PWD/qtorusmesh.h \ $$PWD/qtorusgeometry.h \ $$PWD/qtorusgeometry_p.h \ + $$PWD/qtorusgeometryview.h \ $$PWD/qspheregeometry.h \ $$PWD/qspheregeometry_p.h \ + $$PWD/qspheregeometryview.h \ $$PWD/qcuboidgeometry.h \ $$PWD/qcuboidgeometry_p.h \ + $$PWD/qcuboidgeometryview.h \ $$PWD/qplanegeometry.h \ - $$PWD/qplanegeometry_p.h + $$PWD/qplanegeometry_p.h \ + $$PWD/qplanegeometryview.h SOURCES += \ $$PWD/qconegeometry.cpp \ + $$PWD/qconegeometryview.cpp \ $$PWD/qconemesh.cpp \ $$PWD/qcuboidmesh.cpp \ $$PWD/qcylindergeometry.cpp \ + $$PWD/qcylindergeometryview.cpp \ $$PWD/qcylindermesh.cpp \ $$PWD/qplanemesh.cpp \ $$PWD/qspheremesh.cpp \ $$PWD/qtorusmesh.cpp \ $$PWD/qtorusgeometry.cpp \ + $$PWD/qtorusgeometryview.cpp \ $$PWD/qspheregeometry.cpp \ + $$PWD/qspheregeometryview.cpp \ $$PWD/qcuboidgeometry.cpp \ - $$PWD/qplanegeometry.cpp + $$PWD/qcuboidgeometryview.cpp \ + $$PWD/qplanegeometry.cpp \ + $$PWD/qplanegeometryview.cpp INCLUDEPATH += $$PWD diff --git a/src/extras/geometries/qconegeometryview.cpp b/src/extras/geometries/qconegeometryview.cpp new file mode 100644 index 000000000..28707d043 --- /dev/null +++ b/src/extras/geometries/qconegeometryview.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qconegeometryview.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype ConeGeometryView + * \instantiates Qt3DExtras::QConeGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A conical mesh. + */ + +/*! + * \qmlproperty int ConeGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int ConeGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty bool ConeGeometryView::hasTopEndcap + * + * Determines if the cone top is capped or open. + */ + +/*! + * \qmlproperty bool ConeGeometryView::hasBottomEndcap + * + * Determines if the cone bottom is capped or open. + */ + +/*! + * \qmlproperty real ConeGeometryView::topRadius + * + * Holds the top radius of the cone. + */ + +/*! + * \qmlproperty real ConeGeometryView::bottomRadius + * + * Holds the bottom radius of the cone. + */ + +/*! + * \qmlproperty real ConeGeometryView::length + * + * Holds the length of the cone. + */ + +/*! + * \class Qt3DExtras::QConeGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QConeGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A conical mesh. + */ + +QConeGeometryView::QConeGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QConeGeometry *geometry = new QConeGeometry(this); + QObject::connect(geometry, &QConeGeometry::hasTopEndcapChanged, this, &QConeGeometryView::hasTopEndcapChanged); + QObject::connect(geometry, &QConeGeometry::hasBottomEndcapChanged, this, &QConeGeometryView::hasBottomEndcapChanged); + QObject::connect(geometry, &QConeGeometry::topRadiusChanged, this, &QConeGeometryView::topRadiusChanged); + QObject::connect(geometry, &QConeGeometry::bottomRadiusChanged, this, &QConeGeometryView::bottomRadiusChanged); + QObject::connect(geometry, &QConeGeometry::ringsChanged, this, &QConeGeometryView::ringsChanged); + QObject::connect(geometry, &QConeGeometry::slicesChanged, this, &QConeGeometryView::slicesChanged); + QObject::connect(geometry, &QConeGeometry::lengthChanged, this, &QConeGeometryView::lengthChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QConeGeometryView::~QConeGeometryView() +{ +} + +void QConeGeometryView::setHasTopEndcap(bool hasTopEndcap) +{ + static_cast(geometry())->setHasTopEndcap(hasTopEndcap); +} + +void QConeGeometryView::setHasBottomEndcap(bool hasBottomEndcap) +{ + static_cast(geometry())->setHasBottomEndcap(hasBottomEndcap); +} + +void QConeGeometryView::setTopRadius(float topRadius) +{ + static_cast(geometry())->setTopRadius(topRadius); +} + +void QConeGeometryView::setBottomRadius(float bottomRadius) +{ + static_cast(geometry())->setBottomRadius(bottomRadius); +} + +void QConeGeometryView::setRings(int rings) +{ + static_cast(geometry())->setRings(rings); +} + +void QConeGeometryView::setSlices(int slices) +{ + static_cast(geometry())->setSlices(slices); +} + +void QConeGeometryView::setLength(float length) +{ + static_cast(geometry())->setLength(length); +} + +/*! + * \property QConeGeometryView::hasTopEndcap + * + * Determines if the cone top is capped or open. + */ +bool QConeGeometryView::hasTopEndcap() const +{ + return static_cast(geometry())->hasTopEndcap(); +} + +/*! + * \property QConeGeometryView::hasBottomEndcap + * + * Determines if the cone bottom is capped or open. + */ +bool QConeGeometryView::hasBottomEndcap() const +{ + return static_cast(geometry())->hasBottomEndcap(); +} + +/*! + * \property QConeGeometryView::topRadius + * + * Holds the top radius of the cone. + */ +float QConeGeometryView::topRadius() const +{ + return static_cast(geometry())->topRadius(); +} + +/*! + * \property QConeGeometryView::bottomRadius + * + * Holds the bottom radius of the cone. + */ +float QConeGeometryView::bottomRadius() const +{ + return static_cast(geometry())->bottomRadius(); +} + +/*! + * \property QConeGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QConeGeometryView::rings() const +{ + return static_cast(geometry())->rings(); +} + +/*! + * \property QConeGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QConeGeometryView::slices() const +{ + return static_cast(geometry())->slices(); +} + +/*! + * \property QConeGeometryView::length + * + * Holds the length of the cone. + */ +float QConeGeometryView::length() const +{ + return static_cast(geometry())->length(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qconegeometryview.h b/src/extras/geometries/qconegeometryview.h new file mode 100644 index 000000000..cdeb3703e --- /dev/null +++ b/src/extras/geometries/qconegeometryview.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QCONEGEOMETRYVIEW_H +#define QT3DEXTRAS_QCONEGEOMETRYVIEW_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QConeGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY( bool hasTopEndcap READ hasTopEndcap WRITE setHasTopEndcap NOTIFY hasTopEndcapChanged ) + Q_PROPERTY( bool hasBottomEndcap READ hasBottomEndcap WRITE setHasBottomEndcap NOTIFY hasBottomEndcapChanged ) + Q_PROPERTY( float topRadius READ topRadius WRITE setTopRadius NOTIFY topRadiusChanged ) + Q_PROPERTY( float bottomRadius READ bottomRadius WRITE setBottomRadius NOTIFY bottomRadiusChanged ) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) +public: + explicit QConeGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QConeGeometryView(); + + int rings() const; + int slices() const; + bool hasTopEndcap() const; + bool hasBottomEndcap() const; + float topRadius() const; + float bottomRadius() const; + float length() const; + +public Q_SLOTS: + void setHasTopEndcap( bool hasTopEndcap ); + void setHasBottomEndcap( bool hasBottomEndcap ); + void setTopRadius( float topRadius ); + void setBottomRadius( float bottomRadius ); + void setRings( int rings ); + void setSlices( int slices ); + void setLength( float length ); + +Q_SIGNALS: + void hasTopEndcapChanged( bool hasTopEndcap ); + void hasBottomEndcapChanged( bool hasBottomEndcap ); + void topRadiusChanged( float topRadius ); + void bottomRadiusChanged( float bottomRadius ); + void ringsChanged( int rings ); + void slicesChanged( int slices ); + void lengthChanged( float length ); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QCONEGEOMETRYVIEW_H diff --git a/src/extras/geometries/qconemesh.cpp b/src/extras/geometries/qconemesh.cpp index 4a8ab05c8..5f4ebd369 100644 --- a/src/extras/geometries/qconemesh.cpp +++ b/src/extras/geometries/qconemesh.cpp @@ -37,13 +37,9 @@ ** ****************************************************************************/ -#ifndef _USE_MATH_DEFINES -# define _USE_MATH_DEFINES // For MSVC -#endif +#include "qconemesh.h" -#include "qconegeometry.h" - -#include +#include #include #include #include @@ -115,18 +111,18 @@ namespace Qt3DExtras { */ QConeMesh::QConeMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QConeGeometry *geometry = new QConeGeometry(this); - QObject::connect(geometry, &QConeGeometry::hasTopEndcapChanged, this, &QConeMesh::hasTopEndcapChanged); - QObject::connect(geometry, &QConeGeometry::hasBottomEndcapChanged, this, &QConeMesh::hasBottomEndcapChanged); - QObject::connect(geometry, &QConeGeometry::topRadiusChanged, this, &QConeMesh::topRadiusChanged); - QObject::connect(geometry, &QConeGeometry::bottomRadiusChanged, this, &QConeMesh::bottomRadiusChanged); - QObject::connect(geometry, &QConeGeometry::ringsChanged, this, &QConeMesh::ringsChanged); - QObject::connect(geometry, &QConeGeometry::slicesChanged, this, &QConeMesh::slicesChanged); - QObject::connect(geometry, &QConeGeometry::lengthChanged, this, &QConeMesh::lengthChanged); + QConeGeometryView *geometry = new QConeGeometryView(this); + QObject::connect(geometry, &QConeGeometryView::hasTopEndcapChanged, this, &QConeMesh::hasTopEndcapChanged); + QObject::connect(geometry, &QConeGeometryView::hasBottomEndcapChanged, this, &QConeMesh::hasBottomEndcapChanged); + QObject::connect(geometry, &QConeGeometryView::topRadiusChanged, this, &QConeMesh::topRadiusChanged); + QObject::connect(geometry, &QConeGeometryView::bottomRadiusChanged, this, &QConeMesh::bottomRadiusChanged); + QObject::connect(geometry, &QConeGeometryView::ringsChanged, this, &QConeMesh::ringsChanged); + QObject::connect(geometry, &QConeGeometryView::slicesChanged, this, &QConeMesh::slicesChanged); + QObject::connect(geometry, &QConeGeometryView::lengthChanged, this, &QConeMesh::lengthChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -136,37 +132,37 @@ QConeMesh::~QConeMesh() void QConeMesh::setHasTopEndcap(bool hasTopEndcap) { - static_cast(geometry())->setHasTopEndcap(hasTopEndcap); + static_cast(view())->setHasTopEndcap(hasTopEndcap); } void QConeMesh::setHasBottomEndcap(bool hasBottomEndcap) { - static_cast(geometry())->setHasBottomEndcap(hasBottomEndcap); + static_cast(view())->setHasBottomEndcap(hasBottomEndcap); } void QConeMesh::setTopRadius(float topRadius) { - static_cast(geometry())->setTopRadius(topRadius); + static_cast(view())->setTopRadius(topRadius); } void QConeMesh::setBottomRadius(float bottomRadius) { - static_cast(geometry())->setBottomRadius(bottomRadius); + static_cast(view())->setBottomRadius(bottomRadius); } void QConeMesh::setRings(int rings) { - static_cast(geometry())->setRings(rings); + static_cast(view())->setRings(rings); } void QConeMesh::setSlices(int slices) { - static_cast(geometry())->setSlices(slices); + static_cast(view())->setSlices(slices); } void QConeMesh::setLength(float length) { - static_cast(geometry())->setLength(length); + static_cast(view())->setLength(length); } /*! @@ -176,7 +172,7 @@ void QConeMesh::setLength(float length) */ bool QConeMesh::hasTopEndcap() const { - return static_cast(geometry())->hasTopEndcap(); + return static_cast(view())->hasTopEndcap(); } /*! @@ -186,7 +182,7 @@ bool QConeMesh::hasTopEndcap() const */ bool QConeMesh::hasBottomEndcap() const { - return static_cast(geometry())->hasBottomEndcap(); + return static_cast(view())->hasBottomEndcap(); } /*! @@ -196,7 +192,7 @@ bool QConeMesh::hasBottomEndcap() const */ float QConeMesh::topRadius() const { - return static_cast(geometry())->topRadius(); + return static_cast(view())->topRadius(); } /*! @@ -206,7 +202,7 @@ float QConeMesh::topRadius() const */ float QConeMesh::bottomRadius() const { - return static_cast(geometry())->bottomRadius(); + return static_cast(view())->bottomRadius(); } /*! @@ -216,7 +212,7 @@ float QConeMesh::bottomRadius() const */ int QConeMesh::rings() const { - return static_cast(geometry())->rings(); + return static_cast(view())->rings(); } /*! @@ -226,7 +222,7 @@ int QConeMesh::rings() const */ int QConeMesh::slices() const { - return static_cast(geometry())->slices(); + return static_cast(view())->slices(); } /*! @@ -236,7 +232,7 @@ int QConeMesh::slices() const */ float QConeMesh::length() const { - return static_cast(geometry())->length(); + return static_cast(view())->length(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qconemesh.h b/src/extras/geometries/qconemesh.h index ac7a7bf16..57fe0c0fc 100644 --- a/src/extras/geometries/qconemesh.h +++ b/src/extras/geometries/qconemesh.h @@ -41,13 +41,13 @@ #define QT3DEXTRAS_QCONEMESH_H #include -#include +#include QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QConeMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QConeMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qcuboidgeometryview.cpp b/src/extras/geometries/qcuboidgeometryview.cpp new file mode 100644 index 000000000..ee0977b71 --- /dev/null +++ b/src/extras/geometries/qcuboidgeometryview.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcuboidgeometryview.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype CuboidGeometryView + * \instantiates Qt3DExtras::QCuboidGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A cuboid mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::xExtent + * + * Holds the x extent of the mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::yExtent + * + * Holds the y extent of the mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::zExtent + * + * Holds the z extent of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::yzMeshResolution + * + * Holds the y-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the y-z faces of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::xzMeshResolution + * + * Holds the x-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-z faces of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::xyMeshResolution + * + * Holds the x-y resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-y faces of the mesh. + */ + +/*! + * \class Qt3DExtras::QCuboidGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QCuboidGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A cuboid mesh. + */ + +/*! + * Constructs a new QCuboidGeometryView with \a parent. + */ +QCuboidGeometryView::QCuboidGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QCuboidGeometry *geometry = new QCuboidGeometry(this); + QObject::connect(geometry, &QCuboidGeometry::xExtentChanged, this, &QCuboidGeometryView::xExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::yExtentChanged, this, &QCuboidGeometryView::yExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::zExtentChanged, this, &QCuboidGeometryView::zExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::xyMeshResolutionChanged, this, &QCuboidGeometryView::xyMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometry::xzMeshResolutionChanged, this, &QCuboidGeometryView::xzMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometry::yzMeshResolutionChanged, this, &QCuboidGeometryView::yzMeshResolutionChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QCuboidGeometryView::~QCuboidGeometryView() +{ +} + +void QCuboidGeometryView::setXExtent(float xExtent) +{ + static_cast(geometry())->setXExtent(xExtent); +} + +/*! + * \property QCuboidGeometryView::xExtent + * + * Holds the x extent of the mesh. + */ +float QCuboidGeometryView::xExtent() const +{ + return static_cast(geometry())->xExtent(); +} + +void QCuboidGeometryView::setYExtent(float yExtent) +{ + static_cast(geometry())->setYExtent(yExtent); +} + +/*! + * \property QCuboidGeometryView::yExtent + * + * Holds the y extent of the mesh. + */ +float QCuboidGeometryView::yExtent() const +{ + return static_cast(geometry())->yExtent(); +} + +void QCuboidGeometryView::setZExtent(float zExtent) +{ + static_cast(geometry())->setZExtent(zExtent); +} + +/*! + * \property QCuboidGeometryView::zExtent + * + * Holds the z extent of the mesh. + */ +float QCuboidGeometryView::zExtent() const +{ + return static_cast(geometry())->zExtent(); +} + +void QCuboidGeometryView::setYZMeshResolution(const QSize &resolution) +{ + static_cast(geometry())->setYZMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::yzMeshResolution + * + * Holds the y-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the y-z faces of the mesh. + */ +QSize QCuboidGeometryView::yzMeshResolution() const +{ + return static_cast(geometry())->yzMeshResolution(); +} + +void QCuboidGeometryView::setXZMeshResolution(const QSize &resolution) +{ + static_cast(geometry())->setXZMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::xzMeshResolution + * + * Holds the x-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-z faces of the mesh. + */ +QSize QCuboidGeometryView::xzMeshResolution() const +{ + return static_cast(geometry())->xzMeshResolution(); +} + +void QCuboidGeometryView::setXYMeshResolution(const QSize &resolution) +{ + static_cast(geometry())->setXYMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::xyMeshResolution + * + * Holds the x-y resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-y faces of the mesh. + */ +QSize QCuboidGeometryView::xyMeshResolution() const +{ + return static_cast(geometry())->xyMeshResolution(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qcuboidgeometryview.h b/src/extras/geometries/qcuboidgeometryview.h new file mode 100644 index 000000000..2925c6dd6 --- /dev/null +++ b/src/extras/geometries/qcuboidgeometryview.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H +#define QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QCuboidGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + + Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged) + Q_PROPERTY(float yExtent READ yExtent WRITE setYExtent NOTIFY yExtentChanged) + Q_PROPERTY(float zExtent READ zExtent WRITE setZExtent NOTIFY zExtentChanged) + Q_PROPERTY(QSize yzMeshResolution READ yzMeshResolution WRITE setYZMeshResolution NOTIFY yzMeshResolutionChanged) + Q_PROPERTY(QSize xzMeshResolution READ xzMeshResolution WRITE setXZMeshResolution NOTIFY xzMeshResolutionChanged) + Q_PROPERTY(QSize xyMeshResolution READ xyMeshResolution WRITE setXYMeshResolution NOTIFY xyMeshResolutionChanged) + +public: + explicit QCuboidGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QCuboidGeometryView(); + + float xExtent() const; + float yExtent() const; + float zExtent() const; + QSize yzMeshResolution() const; + QSize xzMeshResolution() const; + QSize xyMeshResolution() const; + +public Q_SLOTS: + void setXExtent(float xExtent); + void setYExtent(float yExtent); + void setZExtent(float zExtent); + void setYZMeshResolution(const QSize &resolution); + void setXZMeshResolution(const QSize &resolution); + void setXYMeshResolution(const QSize &resolution); + +Q_SIGNALS: + void xExtentChanged(float xExtent); + void yExtentChanged(float yExtent); + void zExtentChanged(float zExtent); + + void yzMeshResolutionChanged(const QSize &yzMeshResolution); + void xzMeshResolutionChanged(const QSize &xzMeshResolution); + void xyMeshResolutionChanged(const QSize &xyMeshResolution); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H diff --git a/src/extras/geometries/qcuboidmesh.cpp b/src/extras/geometries/qcuboidmesh.cpp index 8637f7a57..5440ef0ba 100644 --- a/src/extras/geometries/qcuboidmesh.cpp +++ b/src/extras/geometries/qcuboidmesh.cpp @@ -39,7 +39,7 @@ #include "qcuboidmesh.h" -#include +#include QT_BEGIN_NAMESPACE @@ -109,16 +109,16 @@ namespace Qt3DExtras { * Constructs a new QCuboidMesh with \a parent. */ QCuboidMesh::QCuboidMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QCuboidGeometry *geometry = new QCuboidGeometry(this); - QObject::connect(geometry, &QCuboidGeometry::xExtentChanged, this, &QCuboidMesh::xExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::yExtentChanged, this, &QCuboidMesh::yExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::zExtentChanged, this, &QCuboidMesh::zExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::xyMeshResolutionChanged, this, &QCuboidMesh::xyMeshResolutionChanged); - QObject::connect(geometry, &QCuboidGeometry::xzMeshResolutionChanged, this, &QCuboidMesh::xzMeshResolutionChanged); - QObject::connect(geometry, &QCuboidGeometry::yzMeshResolutionChanged, this, &QCuboidMesh::yzMeshResolutionChanged); - QGeometryView::setGeometry(geometry); + QCuboidGeometryView *geometry = new QCuboidGeometryView(this); + QObject::connect(geometry, &QCuboidGeometryView::xExtentChanged, this, &QCuboidMesh::xExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::yExtentChanged, this, &QCuboidMesh::yExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::zExtentChanged, this, &QCuboidMesh::zExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::xyMeshResolutionChanged, this, &QCuboidMesh::xyMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometryView::xzMeshResolutionChanged, this, &QCuboidMesh::xzMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometryView::yzMeshResolutionChanged, this, &QCuboidMesh::yzMeshResolutionChanged); + setView(geometry); } /*! \internal */ @@ -128,7 +128,7 @@ QCuboidMesh::~QCuboidMesh() void QCuboidMesh::setXExtent(float xExtent) { - static_cast(geometry())->setXExtent(xExtent); + static_cast(view())->setXExtent(xExtent); } /*! @@ -138,12 +138,12 @@ void QCuboidMesh::setXExtent(float xExtent) */ float QCuboidMesh::xExtent() const { - return static_cast(geometry())->xExtent(); + return static_cast(view())->xExtent(); } void QCuboidMesh::setYExtent(float yExtent) { - static_cast(geometry())->setYExtent(yExtent); + static_cast(view())->setYExtent(yExtent); } /*! @@ -153,12 +153,12 @@ void QCuboidMesh::setYExtent(float yExtent) */ float QCuboidMesh::yExtent() const { - return static_cast(geometry())->yExtent(); + return static_cast(view())->yExtent(); } void QCuboidMesh::setZExtent(float zExtent) { - static_cast(geometry())->setZExtent(zExtent); + static_cast(view())->setZExtent(zExtent); } /*! @@ -168,12 +168,12 @@ void QCuboidMesh::setZExtent(float zExtent) */ float QCuboidMesh::zExtent() const { - return static_cast(geometry())->zExtent(); + return static_cast(view())->zExtent(); } void QCuboidMesh::setYZMeshResolution(const QSize &resolution) { - static_cast(geometry())->setYZMeshResolution(resolution); + static_cast(view())->setYZMeshResolution(resolution); } /*! @@ -185,12 +185,12 @@ void QCuboidMesh::setYZMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::yzMeshResolution() const { - return static_cast(geometry())->yzMeshResolution(); + return static_cast(view())->yzMeshResolution(); } void QCuboidMesh::setXZMeshResolution(const QSize &resolution) { - static_cast(geometry())->setXZMeshResolution(resolution); + static_cast(view())->setXZMeshResolution(resolution); } /*! @@ -202,12 +202,12 @@ void QCuboidMesh::setXZMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::xzMeshResolution() const { - return static_cast(geometry())->xzMeshResolution(); + return static_cast(view())->xzMeshResolution(); } void QCuboidMesh::setXYMeshResolution(const QSize &resolution) { - static_cast(geometry())->setXYMeshResolution(resolution); + static_cast(view())->setXYMeshResolution(resolution); } /*! @@ -219,7 +219,7 @@ void QCuboidMesh::setXYMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::xyMeshResolution() const { - return static_cast(geometry())->xyMeshResolution(); + return static_cast(view())->xyMeshResolution(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qcuboidmesh.h b/src/extras/geometries/qcuboidmesh.h index 480ffaae3..a945dbe2b 100644 --- a/src/extras/geometries/qcuboidmesh.h +++ b/src/extras/geometries/qcuboidmesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_CUBOIDMESH_H #include -#include +#include #include QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QCuboidMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QCuboidMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT diff --git a/src/extras/geometries/qcylindergeometryview.cpp b/src/extras/geometries/qcylindergeometryview.cpp new file mode 100644 index 000000000..3a0fbfd81 --- /dev/null +++ b/src/extras/geometries/qcylindergeometryview.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES // For MSVC +#endif + +#include "qcylindergeometryview.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +using namespace Qt3DCore; + +namespace Qt3DExtras { + +/*! + * \qmltype CylinderGeometryView + * \instantiates Qt3DExtras::QCylinderGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A cylindrical mesh. + */ + +/*! + * \qmlproperty int CylinderMesh::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int CylinderMesh::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real CylinderMesh::radius + * + * Holds the radius of the cylinder. + */ + +/*! + * \qmlproperty real CylinderMesh::length + * + * Holds the length of the cylinder. + */ + +/*! + * \class Qt3DExtras::QCylinderGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QCylinderGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A cylindrical mesh. + */ + +/*! + * Constructs a new QCylinderGeometryView with \a parent. + */ +QCylinderGeometryView::QCylinderGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QCylinderGeometry *geometry = new QCylinderGeometry(this); + QObject::connect(geometry, &QCylinderGeometry::radiusChanged, this, &QCylinderGeometryView::radiusChanged); + QObject::connect(geometry, &QCylinderGeometry::ringsChanged, this, &QCylinderGeometryView::ringsChanged); + QObject::connect(geometry, &QCylinderGeometry::slicesChanged, this, &QCylinderGeometryView::slicesChanged); + QObject::connect(geometry, &QCylinderGeometry::lengthChanged, this, &QCylinderGeometryView::lengthChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QCylinderGeometryView::~QCylinderGeometryView() +{ +} + +void QCylinderGeometryView::setRings(int rings) +{ + static_cast(geometry())->setRings(rings); +} + +void QCylinderGeometryView::setSlices(int slices) +{ + static_cast(geometry())->setSlices(slices); +} + +void QCylinderGeometryView::setRadius(float radius) +{ + static_cast(geometry())->setRadius(radius); +} + +void QCylinderGeometryView::setLength(float length) +{ + static_cast(geometry())->setLength(length); +} + +/*! + * \property QCylinderGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QCylinderGeometryView::rings() const +{ + return static_cast(geometry())->rings(); +} + +/*! + * \property QCylinderGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QCylinderGeometryView::slices() const +{ + return static_cast(geometry())->slices(); +} + +/*! + * \property QCylinderGeometryView::radius + * + * Holds the radius of the cylinder. + */ +float QCylinderGeometryView::radius() const +{ + return static_cast(geometry())->radius(); +} + +/*! + * \property QCylinderGeometryView::length + * + * Holds the length of the cylinder. + */ +float QCylinderGeometryView::length() const +{ + return static_cast(geometry())->length(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qcylindergeometryview.h b/src/extras/geometries/qcylindergeometryview.h new file mode 100644 index 000000000..4a90c54d4 --- /dev/null +++ b/src/extras/geometries/qcylindergeometryview.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H +#define QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H + +#include +#include + +QT_BEGIN_NAMESPACE + + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QCylinderGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) +public: + explicit QCylinderGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QCylinderGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + float length() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setLength(float length); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void lengthChanged(float length); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H diff --git a/src/extras/geometries/qcylindermesh.cpp b/src/extras/geometries/qcylindermesh.cpp index 5aa3b90fd..2c2bb4d81 100644 --- a/src/extras/geometries/qcylindermesh.cpp +++ b/src/extras/geometries/qcylindermesh.cpp @@ -43,8 +43,8 @@ #endif #include "qcylindermesh.h" +#include "qcylindergeometryview.h" -#include #include #include #include @@ -103,15 +103,15 @@ namespace Qt3DExtras { * Constructs a new QCylinderMesh with \a parent. */ QCylinderMesh::QCylinderMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QCylinderGeometry *geometry = new QCylinderGeometry(this); - QObject::connect(geometry, &QCylinderGeometry::radiusChanged, this, &QCylinderMesh::radiusChanged); - QObject::connect(geometry, &QCylinderGeometry::ringsChanged, this, &QCylinderMesh::ringsChanged); - QObject::connect(geometry, &QCylinderGeometry::slicesChanged, this, &QCylinderMesh::slicesChanged); - QObject::connect(geometry, &QCylinderGeometry::lengthChanged, this, &QCylinderMesh::lengthChanged); + QCylinderGeometryView *geometry = new QCylinderGeometryView(this); + QObject::connect(geometry, &QCylinderGeometryView::radiusChanged, this, &QCylinderMesh::radiusChanged); + QObject::connect(geometry, &QCylinderGeometryView::ringsChanged, this, &QCylinderMesh::ringsChanged); + QObject::connect(geometry, &QCylinderGeometryView::slicesChanged, this, &QCylinderMesh::slicesChanged); + QObject::connect(geometry, &QCylinderGeometryView::lengthChanged, this, &QCylinderMesh::lengthChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -121,22 +121,22 @@ QCylinderMesh::~QCylinderMesh() void QCylinderMesh::setRings(int rings) { - static_cast(geometry())->setRings(rings); + static_cast(view())->setRings(rings); } void QCylinderMesh::setSlices(int slices) { - static_cast(geometry())->setSlices(slices); + static_cast(view())->setSlices(slices); } void QCylinderMesh::setRadius(float radius) { - static_cast(geometry())->setRadius(radius); + static_cast(view())->setRadius(radius); } void QCylinderMesh::setLength(float length) { - static_cast(geometry())->setLength(length); + static_cast(view())->setLength(length); } /*! @@ -146,7 +146,7 @@ void QCylinderMesh::setLength(float length) */ int QCylinderMesh::rings() const { - return static_cast(geometry())->rings(); + return static_cast(view())->rings(); } /*! @@ -156,7 +156,7 @@ int QCylinderMesh::rings() const */ int QCylinderMesh::slices() const { - return static_cast(geometry())->slices(); + return static_cast(view())->slices(); } /*! @@ -166,7 +166,7 @@ int QCylinderMesh::slices() const */ float QCylinderMesh::radius() const { - return static_cast(geometry())->radius(); + return static_cast(view())->radius(); } /*! @@ -176,7 +176,7 @@ float QCylinderMesh::radius() const */ float QCylinderMesh::length() const { - return static_cast(geometry())->length(); + return static_cast(view())->length(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qcylindermesh.h b/src/extras/geometries/qcylindermesh.h index 0117e5597..f2c8fb01b 100644 --- a/src/extras/geometries/qcylindermesh.h +++ b/src/extras/geometries/qcylindermesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_QCYLINDERMESH_H #include -#include +#include QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QCylinderMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QCylinderMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qplanegeometryview.cpp b/src/extras/geometries/qplanegeometryview.cpp new file mode 100644 index 000000000..dd1544b3b --- /dev/null +++ b/src/extras/geometries/qplanegeometryview.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplanegeometryview.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype PlaneGeometryView + * \instantiates Qt3DExtras::QPlaneGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A square planar mesh. + */ + +/*! + * \qmlproperty real PlaneGeometryView::width + * + * Holds the plane width. + */ + +/*! + * \qmlproperty real PlaneGeometryView::height + * + * Holds the plane height. + */ + +/*! + * \qmlproperty size PlaneGeometryView::meshResolution + * + * Holds the plane resolution. + * The width and height values of this property specify the number of vertices generated for + * the mesh in the respective dimensions. + */ + +/*! + * \qmlproperty bool PlaneGeometryView::mirrored + * + * Controls if the UV coordinates of the plane should be flipped vertically. + */ + +/*! + * \class Qt3DExtras::QPlaneGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QPlaneGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A square planar mesh. + */ + +/*! + * Constructs a new QPlaneGeometryView with \a parent. + */ +QPlaneGeometryView::QPlaneGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QPlaneGeometry *geometry = new QPlaneGeometry(this); + QObject::connect(geometry, &QPlaneGeometry::widthChanged, this, &QPlaneGeometryView::widthChanged); + QObject::connect(geometry, &QPlaneGeometry::heightChanged, this, &QPlaneGeometryView::heightChanged); + QObject::connect(geometry, &QPlaneGeometry::resolutionChanged, this, &QPlaneGeometryView::meshResolutionChanged); + QObject::connect(geometry, &QPlaneGeometry::mirroredChanged, this, &QPlaneGeometryView::mirroredChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QPlaneGeometryView::~QPlaneGeometryView() +{ +} + +void QPlaneGeometryView::setWidth(float width) +{ + static_cast(geometry())->setWidth(width); +} + +/*! + * \property QPlaneGeometryView::width + * + * Holds the plane width. + */ +float QPlaneGeometryView::width() const +{ + return static_cast(geometry())->width(); +} + +void QPlaneGeometryView::setHeight(float height) +{ + static_cast(geometry())->setHeight(height); +} + +/*! + * \property QPlaneGeometryView::height + * + * Holds the plane height. + */ +float QPlaneGeometryView::height() const +{ + return static_cast(geometry())->height(); +} + +void QPlaneGeometryView::setMeshResolution(const QSize &resolution) +{ + static_cast(geometry())->setResolution(resolution); +} + +/*! + * \property QPlaneGeometryView::meshResolution + * + * Holds the plane resolution. + * The width and height values of this property specify the number of vertices generated for + * the mesh in the respective dimensions. + */ +QSize QPlaneGeometryView::meshResolution() const +{ + return static_cast(geometry())->resolution(); +} + +void QPlaneGeometryView::setMirrored(bool mirrored) +{ + static_cast(geometry())->setMirrored(mirrored); +} + +/*! + * \property QPlaneGeometryView::mirrored + * + * Controls if the UV coordinates of the plane should be flipped vertically. + */ +bool QPlaneGeometryView::mirrored() const +{ + return static_cast(geometry())->mirrored(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qplanegeometryview.h b/src/extras/geometries/qplanegeometryview.h new file mode 100644 index 000000000..a268ded3a --- /dev/null +++ b/src/extras/geometries/qplanegeometryview.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QPLANEGEOMETRYVIEW_H +#define QT3DEXTRAS_QPLANEGEOMETRYVIEW_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QPlaneGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) + Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged) + Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged REVISION 9) + +public: + explicit QPlaneGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QPlaneGeometryView(); + + float width() const; + float height() const; + QSize meshResolution() const; + bool mirrored() const; + +public Q_SLOTS: + void setWidth(float width); + void setHeight(float height); + void setMeshResolution(const QSize &resolution); + void setMirrored(bool mirrored); + +Q_SIGNALS: + void meshResolutionChanged(const QSize &meshResolution); + void widthChanged(float width); + void heightChanged(float height); + void mirroredChanged(bool mirrored); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QPLANEGEOMETRYVIEW_H diff --git a/src/extras/geometries/qplanemesh.cpp b/src/extras/geometries/qplanemesh.cpp index 9dd5f70c5..ebcaa1d9c 100644 --- a/src/extras/geometries/qplanemesh.cpp +++ b/src/extras/geometries/qplanemesh.cpp @@ -39,7 +39,7 @@ #include "qplanemesh.h" -#include +#include QT_BEGIN_NAMESPACE @@ -94,14 +94,14 @@ namespace Qt3DExtras { * Constructs a new QPlaneMesh with \a parent. */ QPlaneMesh::QPlaneMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QPlaneGeometry *geometry = new QPlaneGeometry(this); - QObject::connect(geometry, &QPlaneGeometry::widthChanged, this, &QPlaneMesh::widthChanged); - QObject::connect(geometry, &QPlaneGeometry::heightChanged, this, &QPlaneMesh::heightChanged); - QObject::connect(geometry, &QPlaneGeometry::resolutionChanged, this, &QPlaneMesh::meshResolutionChanged); - QObject::connect(geometry, &QPlaneGeometry::mirroredChanged, this, &QPlaneMesh::mirroredChanged); - QGeometryView::setGeometry(geometry); + QPlaneGeometryView *geometry = new QPlaneGeometryView(this); + QObject::connect(geometry, &QPlaneGeometryView::widthChanged, this, &QPlaneMesh::widthChanged); + QObject::connect(geometry, &QPlaneGeometryView::heightChanged, this, &QPlaneMesh::heightChanged); + QObject::connect(geometry, &QPlaneGeometryView::meshResolutionChanged, this, &QPlaneMesh::meshResolutionChanged); + QObject::connect(geometry, &QPlaneGeometryView::mirroredChanged, this, &QPlaneMesh::mirroredChanged); + setView(geometry); } /*! \internal */ @@ -111,7 +111,7 @@ QPlaneMesh::~QPlaneMesh() void QPlaneMesh::setWidth(float width) { - static_cast(geometry())->setWidth(width); + static_cast(view())->setWidth(width); } /*! @@ -121,12 +121,12 @@ void QPlaneMesh::setWidth(float width) */ float QPlaneMesh::width() const { - return static_cast(geometry())->width(); + return static_cast(view())->width(); } void QPlaneMesh::setHeight(float height) { - static_cast(geometry())->setHeight(height); + static_cast(view())->setHeight(height); } /*! @@ -136,12 +136,12 @@ void QPlaneMesh::setHeight(float height) */ float QPlaneMesh::height() const { - return static_cast(geometry())->height(); + return static_cast(view())->height(); } void QPlaneMesh::setMeshResolution(const QSize &resolution) { - static_cast(geometry())->setResolution(resolution); + static_cast(view())->setMeshResolution(resolution); } /*! @@ -153,12 +153,12 @@ void QPlaneMesh::setMeshResolution(const QSize &resolution) */ QSize QPlaneMesh::meshResolution() const { - return static_cast(geometry())->resolution(); + return static_cast(view())->meshResolution(); } void QPlaneMesh::setMirrored(bool mirrored) { - static_cast(geometry())->setMirrored(mirrored); + static_cast(view())->setMirrored(mirrored); } /*! @@ -169,7 +169,7 @@ void QPlaneMesh::setMirrored(bool mirrored) */ bool QPlaneMesh::mirrored() const { - return static_cast(geometry())->mirrored(); + return static_cast(view())->mirrored(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qplanemesh.h b/src/extras/geometries/qplanemesh.h index fc71bd93a..923af8897 100644 --- a/src/extras/geometries/qplanemesh.h +++ b/src/extras/geometries/qplanemesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_QPLANEMESH_H #include -#include +#include #include QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QPlaneMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QPlaneMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) diff --git a/src/extras/geometries/qspheregeometryview.cpp b/src/extras/geometries/qspheregeometryview.cpp new file mode 100644 index 000000000..6ac72ad82 --- /dev/null +++ b/src/extras/geometries/qspheregeometryview.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qspheregeometryview.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype SphereGeometryView + * \instantiates Qt3DExtras::QSphereGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A spherical mesh. + */ + +/*! + * \qmlproperty int SphereGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int SphereGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real SphereGeometryView::radius + * + * Holds the radius of the sphere. + */ + +/*! + * \qmlproperty bool SphereGeometryView::generateTangents + * + * Holds the value of the automatic tangent vectors generation flag. + * Tangent vectors are orthogonal to normal vectors. + */ + +/*! + * \class Qt3DExtras::QSphereGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QSphereGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A spherical mesh. + */ + +/*! + * Constructs a new QSphereGeometryView with \a parent. + */ +QSphereGeometryView::QSphereGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QSphereGeometry *geometry = new QSphereGeometry(this); + QObject::connect(geometry, &QSphereGeometry::radiusChanged, this, &QSphereGeometryView::radiusChanged); + QObject::connect(geometry, &QSphereGeometry::ringsChanged, this, &QSphereGeometryView::ringsChanged); + QObject::connect(geometry, &QSphereGeometry::slicesChanged, this, &QSphereGeometryView::slicesChanged); + QObject::connect(geometry, &QSphereGeometry::generateTangentsChanged, this, &QSphereGeometryView::generateTangentsChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QSphereGeometryView::~QSphereGeometryView() +{ +} + +void QSphereGeometryView::setRings(int rings) +{ + static_cast(geometry())->setRings(rings); +} + +void QSphereGeometryView::setSlices(int slices) +{ + static_cast(geometry())->setSlices(slices); +} + +void QSphereGeometryView::setRadius(float radius) +{ + static_cast(geometry())->setRadius(radius); +} + +void QSphereGeometryView::setGenerateTangents(bool gen) +{ + static_cast(geometry())->setGenerateTangents(gen); +} + +/*! + * \property QSphereGeometryView::generateTangents + * + * Holds the value of the automatic tangent vectors generation flag. + * Tangent vectors are orthogonal to normal vectors. + */ +bool QSphereGeometryView::generateTangents() const +{ + return static_cast(geometry())->generateTangents(); +} + +/*! + * \property QSphereGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QSphereGeometryView::rings() const +{ + return static_cast(geometry())->rings(); +} + +/*! + * \property QSphereGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QSphereGeometryView::slices() const +{ + return static_cast(geometry())->slices(); +} + +/*! + * \property QSphereGeometryView::radius + * + * Holds the radius of the sphere. + */ +float QSphereGeometryView::radius() const +{ + return static_cast(geometry())->radius(); +} + +} // Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qspheregeometryview.h b/src/extras/geometries/qspheregeometryview.h new file mode 100644 index 000000000..b31fa941b --- /dev/null +++ b/src/extras/geometries/qspheregeometryview.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H +#define QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class QSphereMeshPrivate; + +class Q_3DEXTRASSHARED_EXPORT QSphereGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(bool generateTangents READ generateTangents WRITE setGenerateTangents NOTIFY generateTangentsChanged) + +public: + explicit QSphereGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QSphereGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + bool generateTangents() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setGenerateTangents(bool gen); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void generateTangentsChanged(bool generateTangents); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H diff --git a/src/extras/geometries/qspheremesh.cpp b/src/extras/geometries/qspheremesh.cpp index 13b8ecf5e..fa2b795c8 100644 --- a/src/extras/geometries/qspheremesh.cpp +++ b/src/extras/geometries/qspheremesh.cpp @@ -40,7 +40,7 @@ #include "qspheremesh.h" -#include +#include QT_BEGIN_NAMESPACE @@ -93,14 +93,14 @@ namespace Qt3DExtras { * Constructs a new QSphereMesh with \a parent. */ QSphereMesh::QSphereMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QSphereGeometry *geometry = new QSphereGeometry(this); - QObject::connect(geometry, &QSphereGeometry::radiusChanged, this, &QSphereMesh::radiusChanged); - QObject::connect(geometry, &QSphereGeometry::ringsChanged, this, &QSphereMesh::ringsChanged); - QObject::connect(geometry, &QSphereGeometry::slicesChanged, this, &QSphereMesh::slicesChanged); - QObject::connect(geometry, &QSphereGeometry::generateTangentsChanged, this, &QSphereMesh::generateTangentsChanged); - QGeometryView::setGeometry(geometry); + QSphereGeometryView *geometry = new QSphereGeometryView(this); + QObject::connect(geometry, &QSphereGeometryView::radiusChanged, this, &QSphereMesh::radiusChanged); + QObject::connect(geometry, &QSphereGeometryView::ringsChanged, this, &QSphereMesh::ringsChanged); + QObject::connect(geometry, &QSphereGeometryView::slicesChanged, this, &QSphereMesh::slicesChanged); + QObject::connect(geometry, &QSphereGeometryView::generateTangentsChanged, this, &QSphereMesh::generateTangentsChanged); + setView(geometry); } /*! \internal */ @@ -110,22 +110,22 @@ QSphereMesh::~QSphereMesh() void QSphereMesh::setRings(int rings) { - static_cast(geometry())->setRings(rings); + static_cast(view())->setRings(rings); } void QSphereMesh::setSlices(int slices) { - static_cast(geometry())->setSlices(slices); + static_cast(view())->setSlices(slices); } void QSphereMesh::setRadius(float radius) { - static_cast(geometry())->setRadius(radius); + static_cast(view())->setRadius(radius); } void QSphereMesh::setGenerateTangents(bool gen) { - static_cast(geometry())->setGenerateTangents(gen); + static_cast(view())->setGenerateTangents(gen); } /*! @@ -136,7 +136,7 @@ void QSphereMesh::setGenerateTangents(bool gen) */ bool QSphereMesh::generateTangents() const { - return static_cast(geometry())->generateTangents(); + return static_cast(view())->generateTangents(); } /*! @@ -146,7 +146,7 @@ bool QSphereMesh::generateTangents() const */ int QSphereMesh::rings() const { - return static_cast(geometry())->rings(); + return static_cast(view())->rings(); } /*! @@ -156,7 +156,7 @@ int QSphereMesh::rings() const */ int QSphereMesh::slices() const { - return static_cast(geometry())->slices(); + return static_cast(view())->slices(); } /*! @@ -166,7 +166,7 @@ int QSphereMesh::slices() const */ float QSphereMesh::radius() const { - return static_cast(geometry())->radius(); + return static_cast(view())->radius(); } } // Qt3DExtras diff --git a/src/extras/geometries/qspheremesh.h b/src/extras/geometries/qspheremesh.h index 170f70215..998cd7c0e 100644 --- a/src/extras/geometries/qspheremesh.h +++ b/src/extras/geometries/qspheremesh.h @@ -41,7 +41,7 @@ #define QT3DEXTRAS_QSPHEREMESH_H #include -#include +#include QT_BEGIN_NAMESPACE @@ -49,7 +49,7 @@ namespace Qt3DExtras { class QSphereMeshPrivate; -class Q_3DEXTRASSHARED_EXPORT QSphereMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QSphereMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qtorusgeometryview.cpp b/src/extras/geometries/qtorusgeometryview.cpp new file mode 100644 index 000000000..958d17974 --- /dev/null +++ b/src/extras/geometries/qtorusgeometryview.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES // For MSVC +#endif + +#include "qtorusgeometryview.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype TorusGeometryView + * \instantiates Qt3DExtras::QTorusGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A toroidal mesh. + */ + +/*! + * \qmlproperty int TorusGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int TorusGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real TorusGeometryView::radius + * + * Holds the outer radius of the torus. + */ + +/*! + * \qmlproperty real TorusGeometryView::minorRadius + * + * Holds the inner radius of the torus. + */ + +/*! + * \class Qt3DExtras::QTorusGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QTorusGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A toroidal mesh. + */ + +/*! + * Constructs a new QTorusGeometryView with \a parent. + */ +QTorusGeometryView::QTorusGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QTorusGeometry *geometry = new QTorusGeometry(this); + QObject::connect(geometry, &QTorusGeometry::radiusChanged, this, &QTorusGeometryView::radiusChanged); + QObject::connect(geometry, &QTorusGeometry::ringsChanged, this, &QTorusGeometryView::ringsChanged); + QObject::connect(geometry, &QTorusGeometry::slicesChanged, this, &QTorusGeometryView::slicesChanged); + QObject::connect(geometry, &QTorusGeometry::minorRadiusChanged, this, &QTorusGeometryView::minorRadiusChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QTorusGeometryView::~QTorusGeometryView() +{ +} + +void QTorusGeometryView::setRings(int rings) +{ + static_cast(geometry())->setRings(rings); +} + +void QTorusGeometryView::setSlices(int slices) +{ + static_cast(geometry())->setSlices(slices); +} + +void QTorusGeometryView::setRadius(float radius) +{ + static_cast(geometry())->setRadius(radius); +} + +void QTorusGeometryView::setMinorRadius(float minorRadius) +{ + static_cast(geometry())->setMinorRadius(minorRadius); +} + +/*! + * \property QTorusGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QTorusGeometryView::rings() const +{ + return static_cast(geometry())->rings(); +} + +/*! + * \property QTorusGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QTorusGeometryView::slices() const +{ + return static_cast(geometry())->slices(); +} + +/*! + * \property QTorusGeometryView::radius + * + * Holds the outer radius of the torus. + */ +float QTorusGeometryView::radius() const +{ + return static_cast(geometry())->radius(); +} + +/*! + * \property QTorusGeometryView::minorRadius + * + * Holds the inner radius of the torus. + */ +float QTorusGeometryView::minorRadius() const +{ + return static_cast(geometry())->minorRadius(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qtorusgeometryview.h b/src/extras/geometries/qtorusgeometryview.h new file mode 100644 index 000000000..c8c6fd5ad --- /dev/null +++ b/src/extras/geometries/qtorusgeometryview.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QTORUSGEOMETRYVIEW_H +#define QT3DEXTRAS_QTORUSGEOMETRYVIEW_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QTorusGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float minorRadius READ minorRadius WRITE setMinorRadius NOTIFY minorRadiusChanged) +public: + explicit QTorusGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QTorusGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + float minorRadius() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setMinorRadius(float minorRadius); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void minorRadiusChanged(float minorRadius); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QTORUSGEOMETRYVIEW_H diff --git a/src/extras/geometries/qtorusmesh.cpp b/src/extras/geometries/qtorusmesh.cpp index b195ef631..ddcec3ece 100644 --- a/src/extras/geometries/qtorusmesh.cpp +++ b/src/extras/geometries/qtorusmesh.cpp @@ -43,6 +43,7 @@ #endif #include "qtorusmesh.h" +#include "qtorusgeometryview.h" #include @@ -96,15 +97,15 @@ namespace Qt3DExtras { * Constructs a new QTorusMesh with \a parent. */ QTorusMesh::QTorusMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QTorusGeometry *geometry = new QTorusGeometry(this); - QObject::connect(geometry, &QTorusGeometry::radiusChanged, this, &QTorusMesh::radiusChanged); - QObject::connect(geometry, &QTorusGeometry::ringsChanged, this, &QTorusMesh::ringsChanged); - QObject::connect(geometry, &QTorusGeometry::slicesChanged, this, &QTorusMesh::slicesChanged); - QObject::connect(geometry, &QTorusGeometry::minorRadiusChanged, this, &QTorusMesh::minorRadiusChanged); + QTorusGeometryView *geometry = new QTorusGeometryView(this); + QObject::connect(geometry, &QTorusGeometryView::radiusChanged, this, &QTorusMesh::radiusChanged); + QObject::connect(geometry, &QTorusGeometryView::ringsChanged, this, &QTorusMesh::ringsChanged); + QObject::connect(geometry, &QTorusGeometryView::slicesChanged, this, &QTorusMesh::slicesChanged); + QObject::connect(geometry, &QTorusGeometryView::minorRadiusChanged, this, &QTorusMesh::minorRadiusChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -114,22 +115,22 @@ QTorusMesh::~QTorusMesh() void QTorusMesh::setRings(int rings) { - static_cast(geometry())->setRings(rings); + static_cast(view())->setRings(rings); } void QTorusMesh::setSlices(int slices) { - static_cast(geometry())->setSlices(slices); + static_cast(view())->setSlices(slices); } void QTorusMesh::setRadius(float radius) { - static_cast(geometry())->setRadius(radius); + static_cast(view())->setRadius(radius); } void QTorusMesh::setMinorRadius(float minorRadius) { - static_cast(geometry())->setMinorRadius(minorRadius); + static_cast(view())->setMinorRadius(minorRadius); } /*! @@ -139,7 +140,7 @@ void QTorusMesh::setMinorRadius(float minorRadius) */ int QTorusMesh::rings() const { - return static_cast(geometry())->rings(); + return static_cast(view())->rings(); } /*! @@ -149,7 +150,7 @@ int QTorusMesh::rings() const */ int QTorusMesh::slices() const { - return static_cast(geometry())->slices(); + return static_cast(view())->slices(); } /*! @@ -159,7 +160,7 @@ int QTorusMesh::slices() const */ float QTorusMesh::radius() const { - return static_cast(geometry())->radius(); + return static_cast(view())->radius(); } /*! @@ -169,7 +170,7 @@ float QTorusMesh::radius() const */ float QTorusMesh::minorRadius() const { - return static_cast(geometry())->minorRadius(); + return static_cast(view())->minorRadius(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qtorusmesh.h b/src/extras/geometries/qtorusmesh.h index e36d94097..2fd9f0a23 100644 --- a/src/extras/geometries/qtorusmesh.h +++ b/src/extras/geometries/qtorusmesh.h @@ -41,13 +41,13 @@ #define QT3DEXTRAS_QTORUSMESH_H #include -#include +#include QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QTorusMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QTorusMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp index bd87f7da8..a03afec59 100644 --- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp +++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp @@ -1817,23 +1817,17 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json) } else { QGeometryRenderer *mesh = nullptr; if (meshType == QStringLiteral("cone")) { - mesh = new QGeometryRenderer; - mesh->setView(new QConeMesh); + mesh = new QConeMesh; } else if (meshType == QStringLiteral("cuboid")) { - mesh = new QGeometryRenderer; - mesh->setView(new QCuboidMesh); + mesh = new QCuboidMesh; } else if (meshType == QStringLiteral("cylinder")) { - mesh = new QGeometryRenderer; - mesh->setView(new QCylinderMesh); + mesh = new QCylinderMesh; } else if (meshType == QStringLiteral("plane")) { - mesh = new QGeometryRenderer; - mesh->setView(new QPlaneMesh); + mesh = new QPlaneMesh; } else if (meshType == QStringLiteral("sphere")) { - mesh = new QGeometryRenderer; - mesh->setView(new QSphereMesh); + mesh = new QSphereMesh; } else if (meshType == QStringLiteral("torus")) { - mesh = new QGeometryRenderer; - mesh->setView(new QTorusMesh); + mesh = new QTorusMesh; } else { qCWarning(GLTFImporterLog, "Invalid mesh type: %ls for mesh: %ls", diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index d7424831a..a8eb10116 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -734,13 +734,10 @@ void GLTFExporter::parseMeshes() int meshCount = 0; for (auto it = m_meshMap.constBegin(); it != m_meshMap.constEnd(); ++it) { Node *node = it.key(); - QGeometryRenderer *renderer = it.value(); - QGeometryView *mesh = renderer->view(); - if (!mesh) - continue; + QGeometryRenderer *mesh = it.value(); MeshInfo meshInfo; - meshInfo.originalName = mesh->objectName().isEmpty() ? renderer->objectName() : mesh->objectName(); + meshInfo.originalName = mesh->objectName(); meshInfo.name = newMeshName(); meshInfo.materialName = m_materialInfo.value(m_materialMap.value(node)).name; @@ -767,7 +764,7 @@ void GLTFExporter::parseMeshes() } if (meshInfo.meshType != TypeNone) { - meshInfo.meshComponent = renderer; + meshInfo.meshComponent = mesh; cacheDefaultProperties(meshInfo.meshType); if (GLTFExporterLog().isDebugEnabled()) { @@ -976,7 +973,7 @@ void GLTFExporter::parseMeshes() } meshCount++; - m_meshInfo.insert(renderer, meshInfo); + m_meshInfo.insert(mesh, meshInfo); } qCDebug(GLTFExporterLog, "Total buffer size: %i", m_buffer.size()); @@ -1252,7 +1249,7 @@ bool GLTFExporter::saveScene() mesh["name"] = meshInfo.originalName; if (meshInfo.meshType != TypeNone) { QJsonObject properties; - exportGenericProperties(properties, meshInfo.meshType, meshInfo.meshComponent->view()); + exportGenericProperties(properties, meshInfo.meshType, meshInfo.meshComponent); mesh["type"] = meshInfo.meshTypeStr; mesh["properties"] = properties; mesh["material"] = meshInfo.materialName; diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp index 515f9545c..a7bdd62db 100644 --- a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp @@ -40,10 +40,13 @@ #include "qt3dquick3dextrasplugin.h" #include +#include #include #include +#include #include #include +#include #include #include #include @@ -63,15 +66,18 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -122,18 +128,24 @@ void Qt3DQuick3DExtrasPlugin::registerTypes(const char *uri) // Meshes qmlRegisterType(uri, 2, 0, "ConeMesh"); qmlRegisterType(uri, 2, 0, "ConeGeometry"); + qmlRegisterType(uri, 2, 16, "ConeGeometryView"); qmlRegisterType(uri, 2, 0, "CuboidMesh"); qmlRegisterType(uri, 2, 0, "CuboidGeometry"); + qmlRegisterType(uri, 2, 16, "CuboidGeometryView"); qmlRegisterType(uri, 2, 0, "CylinderMesh"); qmlRegisterType(uri, 2, 0, "CylinderGeometry"); + qmlRegisterType(uri, 2, 16, "CylinderGeometryView"); qmlRegisterType(uri, 2, 0, "PlaneMesh"); qmlRegisterType(uri, 2, 9, "PlaneMesh"); qmlRegisterType(uri, 2, 0, "PlaneGeometry"); + qmlRegisterType(uri, 2, 16, "PlaneGeometryView"); qmlRegisterType(uri, 2, 9, "PlaneGeometry"); qmlRegisterType(uri, 2, 0, "TorusMesh"); qmlRegisterType(uri, 2, 0, "TorusGeometry"); + qmlRegisterType(uri, 2, 16, "TorusGeometryView"); qmlRegisterType(uri, 2, 0, "SphereMesh"); qmlRegisterType(uri, 2, 0, "SphereGeometry"); + qmlRegisterType(uri, 2, 16, "SphereGeometryView"); // 3D Text qmlRegisterType(uri, 2, 9, "ExtrudedTextGeometry"); diff --git a/tests/auto/global/aspects_startup_shutdown/tst_aspects_startup_shutdown.cpp b/tests/auto/global/aspects_startup_shutdown/tst_aspects_startup_shutdown.cpp index c765947ae..ba245cb34 100644 --- a/tests/auto/global/aspects_startup_shutdown/tst_aspects_startup_shutdown.cpp +++ b/tests/auto/global/aspects_startup_shutdown/tst_aspects_startup_shutdown.cpp @@ -114,9 +114,7 @@ Qt3DCore::QEntity *createScene(QWindow *w) torusTransform->setScale3D(QVector3D(1.5, 1, 0.5)); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(torusMesh); - torusEntity->addComponent(renderer); + torusEntity->addComponent(torusMesh); torusEntity->addComponent(torusTransform); torusEntity->addComponent(material); @@ -127,10 +125,7 @@ Qt3DCore::QEntity *createScene(QWindow *w) Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform; - renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(sphereMesh); sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(material); diff --git a/tests/auto/render/boundingsphere/cube.qml b/tests/auto/render/boundingsphere/cube.qml index eb437404a..11d6d4db1 100644 --- a/tests/auto/render/boundingsphere/cube.qml +++ b/tests/auto/render/boundingsphere/cube.qml @@ -61,7 +61,7 @@ Entity { Entity { components: [ - GeometryRenderer { id: testMesh; objectName: "testMesh"; view: CuboidMesh { } }, + CuboidMesh { id: testMesh; objectName: "testMesh" }, PhongMaterial { id: material } ] } diff --git a/tests/auto/render/boundingsphere/sphere.qml b/tests/auto/render/boundingsphere/sphere.qml index c4b78824d..1f0e2245a 100644 --- a/tests/auto/render/boundingsphere/sphere.qml +++ b/tests/auto/render/boundingsphere/sphere.qml @@ -61,7 +61,7 @@ Entity { Entity { components: [ - GeometryRenderer { id: testMesh; objectName: "testMesh"; view: SphereMesh { } }, + SphereMesh { id: testMesh; objectName: "testMesh" }, PhongMaterial { id: material } ] } diff --git a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp index 813157251..a167fc140 100644 --- a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp +++ b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp @@ -327,9 +327,7 @@ void tst_gltfPlugins::createTestScene() mesh->setYZMeshResolution(QSize(2, 2)); mesh->setYZMeshResolution(QSize(2, 3)); mesh->setYZMeshResolution(QSize(3, 2)); - Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - createAndAddEntity(QStringLiteral("Cube with DiffuseMap"), renderer, material, transform); + createAndAddEntity(QStringLiteral("Cube with DiffuseMap"), mesh, material, transform); } // Cone with PhongAlpha { @@ -353,9 +351,7 @@ void tst_gltfPlugins::createTestScene() mesh->setTopRadius(0.5f); mesh->setBottomRadius(1.5f); mesh->setLength(0.9f); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - createAndAddEntity(QStringLiteral("Cone with PhongAlpha"), renderer, material, transform); + createAndAddEntity(QStringLiteral("Cone with PhongAlpha"), mesh, material, transform); } // Cylinder with Phong { @@ -372,9 +368,7 @@ void tst_gltfPlugins::createTestScene() mesh->setRings(3); mesh->setLength(1.2f); mesh->setSlices(16); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - createAndAddEntity(QStringLiteral("Cylinder with Phong"), renderer, material, transform); + createAndAddEntity(QStringLiteral("Cylinder with Phong"), mesh, material, transform); } // Plane with DiffuseSpecularMap { @@ -399,10 +393,8 @@ void tst_gltfPlugins::createTestScene() mesh->setMeshResolution(QSize(3, 3)); mesh->setHeight(1.5f); mesh->setWidth(1.2f); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); createAndAddEntity(QStringLiteral("Plane with DiffuseSpecularMap"), - renderer, material, transform); + mesh, material, transform); } // Sphere with NormalDiffuseMap { @@ -430,10 +422,8 @@ void tst_gltfPlugins::createTestScene() mesh->setRings(16); mesh->setSlices(16); mesh->setGenerateTangents(true); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); createAndAddEntity(QStringLiteral("Sphere with NormalDiffuseMap"), - renderer, material, transform); + mesh, material, transform); } // Sphere with NormalDiffuseMapAlpha { @@ -461,10 +451,8 @@ void tst_gltfPlugins::createTestScene() mesh->setRings(16); mesh->setSlices(16); mesh->setGenerateTangents(true); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); createAndAddEntity(QStringLiteral("Sphere with NormalDiffuseMapAlpha"), - renderer, material, transform); + mesh, material, transform); } // Sphere with NormalDiffuseSpecularMap { @@ -495,10 +483,8 @@ void tst_gltfPlugins::createTestScene() mesh->setRings(16); mesh->setSlices(16); mesh->setGenerateTangents(true); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); createAndAddEntity(QStringLiteral("Sphere with NormalDiffuseSpecularMap"), - renderer, material, transform); + mesh, material, transform); } // Torus with Gooch { @@ -520,9 +506,7 @@ void tst_gltfPlugins::createTestScene() mesh->setMinorRadius(0.5f); mesh->setRings(16); mesh->setSlices(16); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - createAndAddEntity(QStringLiteral("Torus with Gooch"), renderer, material, transform); + createAndAddEntity(QStringLiteral("Torus with Gooch"), mesh, material, transform); } // Custom cube with per-vertex colors { @@ -533,7 +517,7 @@ void tst_gltfPlugins::createTestScene() Qt3DRender::QGeometryRenderer *boxMesh = createCustomCube(); Qt3DCore::QBuffer *colorDataBuffer = - new Qt3DCore::QBuffer(boxMesh->view()->geometry()); + new Qt3DCore::QBuffer(boxMesh->geometry()); QByteArray colorBufferData; colorBufferData.resize(8 * 4 * sizeof(float)); @@ -547,7 +531,7 @@ void tst_gltfPlugins::createTestScene() colorDataBuffer->setData(colorBufferData); - addColorAttributeToGeometry(boxMesh->view()->geometry(), colorDataBuffer, 8); + addColorAttributeToGeometry(boxMesh->geometry(), colorDataBuffer, 8); createAndAddEntity(QStringLiteral("Custom cube with per-vertex colors"), boxMesh, material, transform); @@ -568,10 +552,8 @@ void tst_gltfPlugins::createTestScene() mesh->setRings(3); mesh->setLength(1.5f); mesh->setSlices(16); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); createAndAddEntity(QStringLiteral("Child with Phong"), - renderer, material, transform, parentEntity); + mesh, material, transform, parentEntity); } // Cube with custom material { @@ -590,7 +572,7 @@ void tst_gltfPlugins::createTestScene() transform->setRotation(Qt3DCore::QTransform::fromAxisAndAngle(1.0f, 2.0f, 3.0f, 90.0f)); Qt3DRender::QGeometryRenderer *boxMesh = createCustomCube(); Qt3DCore::QBuffer *offsetBuffer = - new Qt3DCore::QBuffer(boxMesh->view()->geometry()); + new Qt3DCore::QBuffer(boxMesh->geometry()); QByteArray offsetBufferData; offsetBufferData.resize(8 * 3 * sizeof(float)); @@ -613,7 +595,7 @@ void tst_gltfPlugins::createTestScene() customAttribute->setCount(8); customAttribute->setName(QStringLiteral("vertexOffset")); - boxMesh->view()->geometry()->addAttribute(customAttribute); + boxMesh->geometry()->addAttribute(customAttribute); createAndAddEntity(QStringLiteral("Custom cube with on-top material"), boxMesh, material, transform); @@ -751,8 +733,12 @@ void tst_gltfPlugins::compareComponents(Qt3DCore::QComponent *c1, Qt3DCore::QCom if (auto mesh1 = qobject_cast(c1)) { auto mesh2 = qobject_cast(c2); QVERIFY(mesh2 != nullptr); - auto geometry1 = mesh1->view()->geometry(); - auto geometry2 = mesh2->view()->geometry(); + auto geometry1 = mesh1->geometry(); + if (!geometry1 && mesh1->view()) + geometry1 = mesh1->view()->geometry(); + auto geometry2 = mesh2->geometry(); + if (!geometry2 && mesh2->view()) + geometry2 = mesh2->view()->geometry(); // Check that attributes match. compareAttributes( findAttribute(Qt3DCore::QAttribute::defaultPositionAttributeName(), @@ -980,8 +966,8 @@ QUrl tst_gltfPlugins::getTextureUrl(Qt3DRender::QAbstractTexture *tex) Qt3DRender::QGeometryRenderer *tst_gltfPlugins::createCustomCube() { - Qt3DCore::QGeometryView *boxView = new Qt3DCore::QGeometryView(); - Qt3DCore::QGeometry *boxGeometry = new Qt3DCore::QGeometry(boxView); + Qt3DRender::QGeometryRenderer *boxMesh = new Qt3DRender::QGeometryRenderer; + Qt3DCore::QGeometry *boxGeometry = new Qt3DCore::QGeometry(boxMesh); Qt3DCore::QBuffer *boxDataBuffer = new Qt3DCore::QBuffer(boxGeometry); Qt3DCore::QBuffer *indexDataBuffer = @@ -1024,15 +1010,13 @@ Qt3DRender::QGeometryRenderer *tst_gltfPlugins::createCustomCube() addPositionAttributeToGeometry(boxGeometry, boxDataBuffer, 8); addIndexAttributeToGeometry(boxGeometry, indexDataBuffer, 36); - boxView->setInstanceCount(1); - boxView->setIndexOffset(0); - boxView->setFirstInstance(0); - boxView->setVertexCount(36); - boxView->setPrimitiveType(Qt3DCore::QGeometryView::Triangles); - boxView->setGeometry(boxGeometry); + boxMesh->setInstanceCount(1); + boxMesh->setIndexOffset(0); + boxMesh->setFirstInstance(0); + boxMesh->setVertexCount(36); + boxMesh->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles); + boxMesh->setGeometry(boxGeometry); - Qt3DRender::QGeometryRenderer *boxMesh = new Qt3DRender::QGeometryRenderer; - boxMesh->setView(boxView); return boxMesh; } @@ -1218,6 +1202,7 @@ void tst_gltfPlugins::exportAndImport() Qt3DCore::QEntity *importedEntity = findChildEntity(importedScene, name); QVERIFY(importedEntity != nullptr); if (importedEntity) { + qDebug() << importedEntity->objectName(); compareComponents(transformComponent(exportedEntity), transformComponent(importedEntity)); compareComponents(lightComponent(exportedEntity), diff --git a/tests/auto/render/pickboundingvolumejob/testscene_cameraposition.qml b/tests/auto/render/pickboundingvolumejob/testscene_cameraposition.qml index 9e56d7641..87e7a8aac 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_cameraposition.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_cameraposition.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } Entity { diff --git a/tests/auto/render/pickboundingvolumejob/testscene_childentity.qml b/tests/auto/render/pickboundingvolumejob/testscene_childentity.qml index 29094d8e3..7376b53e5 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_childentity.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_childentity.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Parent Entity diff --git a/tests/auto/render/pickboundingvolumejob/testscene_dragdisabled.qml b/tests/auto/render/pickboundingvolumejob/testscene_dragdisabled.qml index a2cbd7117..9b7f973a9 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_dragdisabled.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_dragdisabled.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_dragenabled.qml b/tests/auto/render/pickboundingvolumejob/testscene_dragenabled.qml index 73f1108b4..747b7e858 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_dragenabled.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_dragenabled.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_dragenabledhoverenabled.qml b/tests/auto/render/pickboundingvolumejob/testscene_dragenabledhoverenabled.qml index cdacf849d..f80726068 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_dragenabledhoverenabled.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_dragenabledhoverenabled.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_dragenabledoverlapping.qml b/tests/auto/render/pickboundingvolumejob/testscene_dragenabledoverlapping.qml index d54470119..4280b8555 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_dragenabledoverlapping.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_dragenabledoverlapping.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_improperframegraph.qml b/tests/auto/render/pickboundingvolumejob/testscene_improperframegraph.qml index 37140494d..f0b88acba 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_improperframegraph.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_improperframegraph.qml @@ -79,7 +79,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_nopicking.qml b/tests/auto/render/pickboundingvolumejob/testscene_nopicking.qml index bb360c1bc..86471f8b2 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_nopicking.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_nopicking.qml @@ -99,7 +99,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_parententity.qml b/tests/auto/render/pickboundingvolumejob/testscene_parententity.qml index ce171de9e..759544bb9 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_parententity.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_parententity.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Parent Entity @@ -104,11 +104,9 @@ Entity { Entity { components: [ - GeometryRenderer { - view: PlaneMesh { - width: 100 - height: 100 - } + PlaneMesh { + width: 100 + height: 100 }, PhongMaterial { } diff --git a/tests/auto/render/pickboundingvolumejob/testscene_pickersdisabled.qml b/tests/auto/render/pickboundingvolumejob/testscene_pickersdisabled.qml index 860fc2400..a24289835 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_pickersdisabled.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_pickersdisabled.qml @@ -96,7 +96,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_priorityoverlapping.qml b/tests/auto/render/pickboundingvolumejob/testscene_priorityoverlapping.qml index be83fc75f..7cacb3d2d 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_priorityoverlapping.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_priorityoverlapping.qml @@ -100,7 +100,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PhongMaterial { id: material } // Entity 1 diff --git a/tests/auto/render/pickboundingvolumejob/testscene_viewports.qml b/tests/auto/render/pickboundingvolumejob/testscene_viewports.qml index 0b9c20a94..daafc0edd 100644 --- a/tests/auto/render/pickboundingvolumejob/testscene_viewports.qml +++ b/tests/auto/render/pickboundingvolumejob/testscene_viewports.qml @@ -127,7 +127,7 @@ Entity { } ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } Entity { readonly property ObjectPicker objectPicker: ObjectPicker { diff --git a/tests/auto/render/picking/tst_picking.cpp b/tests/auto/render/picking/tst_picking.cpp index f89463776..9fe15c334 100644 --- a/tests/auto/render/picking/tst_picking.cpp +++ b/tests/auto/render/picking/tst_picking.cpp @@ -71,18 +71,15 @@ public: , clickedCalled(0) { mesh->setRadius(radius); - QSphereGeometry *g = static_cast(mesh->geometry()); + QSphereGeometry *g = static_cast(mesh->view()->geometry()); QAttribute *positionAttr = static_cast(g->attributes().first()); Qt3DCore::QBuffer *vertexBuffer = static_cast(positionAttr->buffer()); Q_UNUSED(vertexBuffer); transform->setTranslation(position); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - addComponent(picker); - addComponent(renderer); + addComponent(mesh); addComponent(transform); QObject::connect(picker, &QObjectPicker::pressed, this, &PickableEntity::onPressed); diff --git a/tests/auto/render/raycastingjob/testscene_screenraycasting.qml b/tests/auto/render/raycastingjob/testscene_screenraycasting.qml index 198148560..47221aec8 100644 --- a/tests/auto/render/raycastingjob/testscene_screenraycasting.qml +++ b/tests/auto/render/raycastingjob/testscene_screenraycasting.qml @@ -112,14 +112,12 @@ Entity { onReleased: { caster.trigger(Qt.point(mouse.x, mouse.y)); } } - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + radius: 1 + length: 3 + rings: 100 + slices: 20 } PhongMaterial { id: material } diff --git a/tests/auto/render/raycastingjob/testscene_worldraycasting.qml b/tests/auto/render/raycastingjob/testscene_worldraycasting.qml index aea697fba..cdb6b9234 100644 --- a/tests/auto/render/raycastingjob/testscene_worldraycasting.qml +++ b/tests/auto/render/raycastingjob/testscene_worldraycasting.qml @@ -105,14 +105,12 @@ Entity { } ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 10 - slices: 10 - } + radius: 1 + length: 3 + rings: 10 + slices: 10 } PhongMaterial { id: material } diff --git a/tests/auto/render/raycastingjob/testscene_worldraycastingalllayers.qml b/tests/auto/render/raycastingjob/testscene_worldraycastingalllayers.qml index a8db4e5c0..efcc31e8f 100644 --- a/tests/auto/render/raycastingjob/testscene_worldraycastingalllayers.qml +++ b/tests/auto/render/raycastingjob/testscene_worldraycastingalllayers.qml @@ -107,14 +107,12 @@ Entity { } ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 10 - slices: 10 - } + radius: 1 + length: 3 + rings: 10 + slices: 10 } PhongMaterial { id: material } diff --git a/tests/auto/render/raycastingjob/testscene_worldraycastinglayer.qml b/tests/auto/render/raycastingjob/testscene_worldraycastinglayer.qml index ff6c413cb..5c6170ae6 100644 --- a/tests/auto/render/raycastingjob/testscene_worldraycastinglayer.qml +++ b/tests/auto/render/raycastingjob/testscene_worldraycastinglayer.qml @@ -107,14 +107,12 @@ Entity { } ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 10 - slices: 10 - } + radius: 1 + length: 3 + rings: 10 + slices: 10 } PhongMaterial { id: material } diff --git a/tests/auto/render/raycastingjob/testscene_worldraycastingparentlayer.qml b/tests/auto/render/raycastingjob/testscene_worldraycastingparentlayer.qml index 54d2586f7..99ca26d6f 100644 --- a/tests/auto/render/raycastingjob/testscene_worldraycastingparentlayer.qml +++ b/tests/auto/render/raycastingjob/testscene_worldraycastingparentlayer.qml @@ -107,14 +107,12 @@ Entity { } ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 10 - slices: 10 - } + radius: 1 + length: 3 + rings: 10 + slices: 10 } PhongMaterial { id: material } diff --git a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp index ae6add27c..d1cbf2e34 100644 --- a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp +++ b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp @@ -223,11 +223,8 @@ Qt3DCore::QEntity *buildBigScene() m.rotate(45.0f * i, QVector3D(0.0f, 0.0f, 1.0f)); transform->setMatrix(m); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - e->addComponent(transform); - e->addComponent(renderer); + e->addComponent(mesh); e->addComponent(material); e->setParent(root); } diff --git a/tests/manual/animation-keyframe-blendtree/main.qml b/tests/manual/animation-keyframe-blendtree/main.qml index b11118cd6..74413b4e2 100644 --- a/tests/manual/animation-keyframe-blendtree/main.qml +++ b/tests/manual/animation-keyframe-blendtree/main.qml @@ -75,8 +75,7 @@ DefaultSceneEntity { translation: Qt.vector3d(5, 0, 0) onTranslationChanged: console.log("t = " + translation) }, - GeometryRenderer { - view: CuboidMesh { } + CuboidMesh { }, PhongMaterial { id: cubeMaterial diff --git a/tests/manual/animation-keyframe-programmatic/main.qml b/tests/manual/animation-keyframe-programmatic/main.qml index 8c9d3d3f7..c34e44d51 100644 --- a/tests/manual/animation-keyframe-programmatic/main.qml +++ b/tests/manual/animation-keyframe-programmatic/main.qml @@ -66,8 +66,7 @@ DefaultSceneEntity { onTranslationChanged: console.log("t = " + translation) }, - GeometryRenderer { - view: CuboidMesh { } + CuboidMesh { }, PhongMaterial { id: cubeMaterial diff --git a/tests/manual/animation-keyframe-simple/main.qml b/tests/manual/animation-keyframe-simple/main.qml index 247048b2f..9246f2467 100644 --- a/tests/manual/animation-keyframe-simple/main.qml +++ b/tests/manual/animation-keyframe-simple/main.qml @@ -66,8 +66,7 @@ DefaultSceneEntity { onTranslationChanged: console.log("t = " + translation) }, - GeometryRenderer { - view: CuboidMesh { } + CuboidMesh { }, PhongMaterial { id: cubeMaterial diff --git a/tests/manual/bigmodel-qml/MyEntity.qml b/tests/manual/bigmodel-qml/MyEntity.qml index d340e088f..0289295cf 100644 --- a/tests/manual/bigmodel-qml/MyEntity.qml +++ b/tests/manual/bigmodel-qml/MyEntity.qml @@ -61,10 +61,10 @@ Entity { components: [ Transform { id: transform }, - GeometryRenderer { view: SphereMesh { radius: 2 } }, + SphereMesh { radius: 2 }, PhongMaterial { id: material }, ObjectPicker { - onClicked: console.log("Clicked", root.name, pick.distance, pick.triangleIndex) - } + onClicked: console.log("Clicked", root.name, pick.distance, pick.triangleIndex) + } ] } diff --git a/tests/manual/bigscene-cpp/main.cpp b/tests/manual/bigscene-cpp/main.cpp index 5a66cb213..e8a4aed7c 100644 --- a/tests/manual/bigscene-cpp/main.cpp +++ b/tests/manual/bigscene-cpp/main.cpp @@ -133,9 +133,6 @@ int main(int ac, char **av) mesh->setRadius(2.5f); mesh->setLength(5.0f); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - // Material auto phongMaterial = new Qt3DExtras::QPhongMaterial(root); auto effect = phongMaterial->effect(); @@ -158,7 +155,7 @@ int main(int ac, char **av) // Scene for (int i = 0; i < max; i++) { Entity *e = new Entity(effect, root); - e->addComponent(renderer); + e->addComponent(mesh); const double angle = M_PI * 2.0 * double(i) * det * 10.; e->setDiffuseColor(QColor(int(qFabs(qCos(angle)) * 255.0), 204, 75)); diff --git a/tests/manual/bigscene-instanced-qml/main.qml b/tests/manual/bigscene-instanced-qml/main.qml index 65273b1ab..506f882da 100644 --- a/tests/manual/bigscene-instanced-qml/main.qml +++ b/tests/manual/bigscene-instanced-qml/main.qml @@ -109,19 +109,16 @@ Entity { } } } - parameters: Parameter { name: "instanceCount"; value: cylinderMeshInstanced.instanceCount } + parameters: Parameter { name: "instanceCount"; value: cylinderMeshRenderer.instanceCount } } - GeometryRenderer { + CylinderMesh { id: cylinderMeshRenderer - view: CylinderMesh { - id: cylinderMeshInstanced - instanceCount: 2000 - rings: 50 - slices: 30 - radius: 2.5 - length: 5.0 - } + view.instanceCount: 2000 + rings: 50 + slices: 30 + radius: 2.5 + length: 5.0 } Entity { diff --git a/tests/manual/blitframebuffer-qml/main.qml b/tests/manual/blitframebuffer-qml/main.qml index 4ca7b7e23..4b3c1915b 100644 --- a/tests/manual/blitframebuffer-qml/main.qml +++ b/tests/manual/blitframebuffer-qml/main.qml @@ -220,14 +220,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -241,11 +239,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/boundingvolumes/AnimatedEntity.qml b/tests/manual/boundingvolumes/AnimatedEntity.qml index 3cd8195f5..e3724968e 100644 --- a/tests/manual/boundingvolumes/AnimatedEntity.qml +++ b/tests/manual/boundingvolumes/AnimatedEntity.qml @@ -87,7 +87,7 @@ Entity { Entity { id: sphereEntity1 components: [ - GeometryRenderer { view: SphereMesh { radius: 4 } }, + SphereMesh { radius: 4 }, PhongMaterial { diffuse: "blue" }, Transform { translation: Qt.vector3d(mainAnimation.x, 9, 0) } ] @@ -97,7 +97,7 @@ Entity { Entity { id: sphereEntity2 components: [ - GeometryRenderer { view: SphereMesh { radius: 4 } }, + SphereMesh { radius: 4 }, PhongMaterial { diffuse: "red" }, Transform { translation: Qt.vector3d(mainAnimation.x, -9, 0) }, BoundingVolume { view: SphereMesh { radius: 2 } } @@ -108,10 +108,10 @@ Entity { Entity { id: sphereEntity3 components: [ - GeometryRenderer { - view: SphereMesh { radius: 4 } - minPoint: Qt.vector3d(-.5, -.5, -.5) - maxPoint: Qt.vector3d(.5, .5, .5) + SphereMesh { + radius: 4 + view.minPoint: Qt.vector3d(-.5, -.5, -.5) + view.maxPoint: Qt.vector3d(.5, .5, .5) }, PhongMaterial { diffuse: "green" }, Transform { translation: Qt.vector3d(mainAnimation.x, 0 , 0) } diff --git a/tests/manual/clip-planes-qml/ClipPlaneEntity.qml b/tests/manual/clip-planes-qml/ClipPlaneEntity.qml index 90dada071..4bd2028b6 100644 --- a/tests/manual/clip-planes-qml/ClipPlaneEntity.qml +++ b/tests/manual/clip-planes-qml/ClipPlaneEntity.qml @@ -67,13 +67,11 @@ Entity { normal.y * center.y + normal.z * center.z)) - GeometryRenderer { + PlaneMesh { id: mesh - view: PlaneMesh { - width: 20.0 - height: 20.0 - meshResolution: Qt.size(2, 2) - } + width: 20.0 + height: 20.0 + meshResolution: Qt.size(2, 2) } Transform { diff --git a/tests/manual/clip-planes-qml/ClippingPlanes.qml b/tests/manual/clip-planes-qml/ClippingPlanes.qml index 7813dc770..e8f90f5e7 100644 --- a/tests/manual/clip-planes-qml/ClippingPlanes.qml +++ b/tests/manual/clip-planes-qml/ClippingPlanes.qml @@ -83,12 +83,10 @@ Entity { } } - property GeometryRenderer mesh: GeometryRenderer { - view: PlaneMesh { - width: 20.0 - height: 20.0 - meshResolution: Qt.size(2, 2) - } + property GeometryRenderer mesh: PlaneMesh { + width: 20.0 + height: 20.0 + meshResolution: Qt.size(2, 2) } components: [cappingMaterial, mesh, root.capsLayer] diff --git a/tests/manual/component-changes/main.cpp b/tests/manual/component-changes/main.cpp index 095065ad4..88804b80a 100644 --- a/tests/manual/component-changes/main.cpp +++ b/tests/manual/component-changes/main.cpp @@ -128,17 +128,11 @@ int main(int argc, char **argv) cylinderMesh->setRings(5); cylinderMesh->setSlices(40); - auto cylinderRenderer = new Qt3DRender::QGeometryRenderer; - cylinderRenderer->setView(cylinderMesh); - // Sphere mesh data Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh(); sphereMesh->setRings(20); sphereMesh->setSlices(40); - auto sphereRenderer = new Qt3DRender::QGeometryRenderer; - sphereRenderer->setView(sphereMesh); - // Transform for cylinder Qt3DCore::QTransform *transform = new Qt3DCore::QTransform; transform->setScale(1.5f); @@ -157,7 +151,7 @@ int main(int argc, char **argv) view.setRootEntity(rootEntity); view.show(); - ComponentSwapper *swapper = new ComponentSwapper(cylinder, cylinderRenderer, sphereRenderer); + ComponentSwapper *swapper = new ComponentSwapper(cylinder, cylinderMesh, sphereMesh); QTimer *timer = new QTimer; QObject::connect(timer, SIGNAL(timeout()), swapper, SLOT(swapComponents())); timer->start(2000); diff --git a/tests/manual/compressed_textures/main.qml b/tests/manual/compressed_textures/main.qml index bd83a4836..cf0e11bc6 100644 --- a/tests/manual/compressed_textures/main.qml +++ b/tests/manual/compressed_textures/main.qml @@ -99,7 +99,7 @@ QQ2.Item { ] Entity { - readonly property GeometryRenderer mesh: GeometryRenderer { view: CuboidMesh { } } + readonly property GeometryRenderer mesh: CuboidMesh { } readonly property DiffuseMapMaterial material: DiffuseMapMaterial { diffuse: TextureLoader { source: textureSource diff --git a/tests/manual/cylinder-cpp/main.cpp b/tests/manual/cylinder-cpp/main.cpp index f80bf2e8b..33a85f32b 100644 --- a/tests/manual/cylinder-cpp/main.cpp +++ b/tests/manual/cylinder-cpp/main.cpp @@ -106,12 +106,9 @@ int main(int argc, char **argv) Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity); material->setDiffuse(Qt::red); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - // Cylinder Qt3DCore::QEntity *cylinder = new Qt3DCore::QEntity(rootEntity); - cylinder->addComponent(renderer); + cylinder->addComponent(mesh); cylinder->addComponent(transform); cylinder->addComponent(material); diff --git a/tests/manual/cylinder-parent-test/main.cpp b/tests/manual/cylinder-parent-test/main.cpp index 09c5f32bb..441530e89 100644 --- a/tests/manual/cylinder-parent-test/main.cpp +++ b/tests/manual/cylinder-parent-test/main.cpp @@ -59,12 +59,12 @@ int main(int argc, char **argv) QGuiApplication app(argc, argv); Qt3DExtras::Qt3DWindow view; - QLoggingCategory::setFilterRules("Qt3D.Renderer.RenderNodes=true"); + QLoggingCategory::setFilterRules(QLatin1String("Qt3D.Renderer.RenderNodes=true")); // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); view.setRootEntity(rootEntity); - rootEntity->setObjectName("Root Entity"); + rootEntity->setObjectName(QLatin1String("Root Entity")); // Set root object of the scene view.show(); @@ -83,9 +83,6 @@ int main(int argc, char **argv) // Cylinder shape data Qt3DExtras::QCylinderMesh *mesh = new Qt3DExtras::QCylinderMesh(); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - qDebug() << "Setup complete. Creating cylinders\n"; // simple setParent from nullptr (OK for QTBUG-73905) @@ -93,20 +90,20 @@ int main(int argc, char **argv) { Qt3DCore::QTransform *leftTransform = new Qt3DCore::QTransform; leftTransform->setTranslation(QVector3D(-5, -2, 0)); - leftTransform->setObjectName("Green transform"); + leftTransform->setObjectName(QLatin1String("Green transform")); Qt3DExtras::QPhongMaterial *greenMaterial = new Qt3DExtras::QPhongMaterial(rootEntity); - greenMaterial->setObjectName("Green Material"); + greenMaterial->setObjectName(QLatin1String("Green Material")); greenMaterial->setDiffuse(Qt::green); Qt3DCore::QEntity *grandParentNode = new Qt3DCore::QEntity(); Qt3DCore::QEntity *parentNode = new Qt3DCore::QEntity(); Qt3DCore::QEntity *leafNode = new Qt3DCore::QEntity(); - grandParentNode->setObjectName("Green Grandparent"); - parentNode->setObjectName("Green Parent"); - leafNode->setObjectName("Green Leaf"); + grandParentNode->setObjectName(QLatin1String("Green Grandparent")); + parentNode->setObjectName(QLatin1String("Green Parent")); + leafNode->setObjectName(QLatin1String("Green Leaf")); - leafNode->addComponent(renderer); + leafNode->addComponent(mesh); leafNode->addComponent(greenMaterial); parentNode->addComponent(leftTransform); @@ -120,20 +117,20 @@ int main(int argc, char **argv) { Qt3DCore::QTransform *leftTransform = new Qt3DCore::QTransform; leftTransform->setTranslation(QVector3D(-5, 2, 0)); - leftTransform->setObjectName("Yellow Transform"); + leftTransform->setObjectName(QLatin1String("Yellow Transform")); Qt3DExtras::QPhongMaterial *yellowMaterial = new Qt3DExtras::QPhongMaterial(rootEntity); - yellowMaterial->setObjectName("Yellow Material"); + yellowMaterial->setObjectName(QLatin1String("Yellow Material")); yellowMaterial->setDiffuse(Qt::yellow); Qt3DCore::QEntity *grandParentNode = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *parentNode = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QEntity *leafNode = new Qt3DCore::QEntity(rootEntity); - leafNode->setObjectName("Yellow Leaf"); - grandParentNode->setObjectName("Yellow Grandparent"); - parentNode->setObjectName("Yellow Parent"); + leafNode->setObjectName(QLatin1String("Yellow Leaf")); + grandParentNode->setObjectName(QLatin1String("Yellow Grandparent")); + parentNode->setObjectName(QLatin1String("Yellow Parent")); - leafNode->addComponent(renderer); + leafNode->addComponent(mesh); leafNode->addComponent(yellowMaterial); parentNode->addComponent(leftTransform); @@ -151,31 +148,31 @@ int main(int argc, char **argv) Qt3DCore::QNode *tree1node1 = new Qt3DCore::QNode(); Qt3DCore::QEntity *tree1node2 = new Qt3DCore::QEntity(); Qt3DCore::QNode *tree1node3 = new Qt3DCore::QNode(); - tree1node1->setObjectName("Red Tree1-Node1"); - tree1node2->setObjectName("Red Tree1-Node2"); - tree1node3->setObjectName("Red Tree1-Node3"); + tree1node1->setObjectName(QLatin1String("Red Tree1-Node1")); + tree1node2->setObjectName(QLatin1String("Red Tree1-Node2")); + tree1node3->setObjectName(QLatin1String("Red Tree1-Node3")); Qt3DCore::QNode *tree2node1 = new Qt3DCore::QNode(); Qt3DCore::QEntity *tree2node2 = new Qt3DCore::QEntity(); Qt3DCore::QNode *tree2node3 = new Qt3DCore::QNode(); - tree2node1->setObjectName("Red Tree2-Node1"); - tree2node2->setObjectName("Red Tree2-Node2"); - tree2node3->setObjectName("Red Tree2-Node3"); + tree2node1->setObjectName(QLatin1String("Red Tree2-Node1")); + tree2node2->setObjectName(QLatin1String("Red Tree2-Node2")); + tree2node3->setObjectName(QLatin1String("Red Tree2-Node3")); Qt3DCore::QTransform *wrongRedTransform = new Qt3DCore::QTransform; wrongRedTransform->setTranslation(QVector3D(1, -1, 0)); Qt3DCore::QTransform *bottomRightTransform = new Qt3DCore::QTransform; bottomRightTransform->setTranslation(QVector3D(5, -2, 0)); - bottomRightTransform->setObjectName("Red BR Transform"); - wrongRedTransform->setObjectName("Red Wrong Transform"); + bottomRightTransform->setObjectName(QLatin1String("Red BR Transform")); + wrongRedTransform->setObjectName(QLatin1String("Red Wrong Transform")); Qt3DExtras::QPhongMaterial *redMaterial = new Qt3DExtras::QPhongMaterial(rootEntity); redMaterial->setDiffuse(Qt::red); - redMaterial->setObjectName("Red Material"); + redMaterial->setObjectName(QLatin1String("Red Material")); Qt3DCore::QEntity *leafNode = new Qt3DCore::QEntity(); - leafNode->setObjectName("Red Leaf"); - leafNode->addComponent(renderer); + leafNode->setObjectName(QLatin1String("Red Leaf")); + leafNode->addComponent(mesh); leafNode->addComponent(redMaterial); tree1node2->addComponent(wrongRedTransform); @@ -199,31 +196,31 @@ int main(int argc, char **argv) Qt3DCore::QNode *tree1node1 = new Qt3DCore::QNode(rootEntity); Qt3DCore::QEntity *tree1node2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QNode *tree1node3 = new Qt3DCore::QNode(rootEntity); - tree1node1->setObjectName("Blue Tree1-Node1"); - tree1node2->setObjectName("Blue Tree1-Node2"); - tree1node3->setObjectName("Blue Tree1-Node3"); + tree1node1->setObjectName(QLatin1String("Blue Tree1-Node1")); + tree1node2->setObjectName(QLatin1String("Blue Tree1-Node2")); + tree1node3->setObjectName(QLatin1String("Blue Tree1-Node3")); Qt3DCore::QNode *tree2node1 = new Qt3DCore::QNode(rootEntity); Qt3DCore::QEntity *tree2node2 = new Qt3DCore::QEntity(rootEntity); Qt3DCore::QNode *tree2node3 = new Qt3DCore::QNode(rootEntity); - tree2node1->setObjectName("Blue Tree2-Node1"); - tree2node2->setObjectName("Blue Tree2-Node2"); - tree2node3->setObjectName("Blue Tree2-Node3"); + tree2node1->setObjectName(QLatin1String("Blue Tree2-Node1")); + tree2node2->setObjectName(QLatin1String("Blue Tree2-Node2")); + tree2node3->setObjectName(QLatin1String("Blue Tree2-Node3")); Qt3DCore::QTransform *wrongBlueTransform = new Qt3DCore::QTransform; wrongBlueTransform->setTranslation(QVector3D(1, 1, 0)); Qt3DCore::QTransform *topRightTransform = new Qt3DCore::QTransform; topRightTransform->setTranslation(QVector3D(5, 2, 0)); - wrongBlueTransform->setObjectName("Blue Wrong Transform"); - topRightTransform->setObjectName("Blue TR Transform"); + wrongBlueTransform->setObjectName(QLatin1String("Blue Wrong Transform")); + topRightTransform->setObjectName(QLatin1String("Blue TR Transform")); Qt3DExtras::QPhongMaterial *blueMaterial = new Qt3DExtras::QPhongMaterial(rootEntity); - blueMaterial->setObjectName("Blue Material"); + blueMaterial->setObjectName(QLatin1String("Blue Material")); blueMaterial->setDiffuse(Qt::blue); Qt3DCore::QEntity *leafNode = new Qt3DCore::QEntity(rootEntity); - leafNode->addComponent(renderer); + leafNode->addComponent(mesh); leafNode->addComponent(blueMaterial); - leafNode->setObjectName("Blue Leaf"); + leafNode->setObjectName(QLatin1String("Blue Leaf")); // sometimes this can change things //QCoreApplication::processEvents(); diff --git a/tests/manual/cylinder-qml/main.qml b/tests/manual/cylinder-qml/main.qml index e821479cb..a5df8af44 100644 --- a/tests/manual/cylinder-qml/main.qml +++ b/tests/manual/cylinder-qml/main.qml @@ -83,14 +83,12 @@ Entity { components: [external_forward_renderer, inputSettings] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + radius: 1 + length: 3 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/deferred-renderer-cpp/sceneentity.cpp b/tests/manual/deferred-renderer-cpp/sceneentity.cpp index 98b83402d..3694b113e 100644 --- a/tests/manual/deferred-renderer-cpp/sceneentity.cpp +++ b/tests/manual/deferred-renderer-cpp/sceneentity.cpp @@ -58,9 +58,6 @@ SceneEntity::SceneEntity(Qt3DCore::QNode *parent) sphereMesh->setRings(50); sphereMesh->setSlices(100); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - { Qt3DRender::QPointLight *light1 = new Qt3DRender::QPointLight(this); light1->setColor(Qt::white); @@ -85,7 +82,7 @@ SceneEntity::SceneEntity(Qt3DCore::QNode *parent) sphereOne->addComponent(sphereOneTransform); sphereOne->addComponent(sphereOneMaterial); - sphereOne->addComponent(renderer); + sphereOne->addComponent(sphereMesh); sphereOne->addComponent(m_layer); sphereOne->addComponent(light2); } @@ -100,7 +97,7 @@ SceneEntity::SceneEntity(Qt3DCore::QNode *parent) light3->setColor(Qt::blue); light3->setIntensity(0.5f); - sphereTwo->addComponent(renderer); + sphereTwo->addComponent(sphereMesh); sphereTwo->addComponent(m_layer); sphereTwo->addComponent(sphereTwoMaterial); sphereTwo->addComponent(light3); diff --git a/tests/manual/deferred-renderer-cpp/screenquadentity.cpp b/tests/manual/deferred-renderer-cpp/screenquadentity.cpp index 507a22588..08f8c7346 100644 --- a/tests/manual/deferred-renderer-cpp/screenquadentity.cpp +++ b/tests/manual/deferred-renderer-cpp/screenquadentity.cpp @@ -64,13 +64,10 @@ ScreenQuadEntity::ScreenQuadEntity(Qt3DCore::QNode *parent) planeMesh->setWidth(2.0f); planeMesh->setHeight(2.0f); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(planeMesh); - addComponent(m_layer); addComponent(screenPlaneTransform); addComponent(screenQuadMaterial); - addComponent(renderer); + addComponent(planeMesh); } Qt3DRender::QLayer *ScreenQuadEntity::layer() const diff --git a/tests/manual/deferred-renderer-qml/GBufferDebugger.qml b/tests/manual/deferred-renderer-qml/GBufferDebugger.qml index 423f9104d..7f148099e 100644 --- a/tests/manual/deferred-renderer-qml/GBufferDebugger.qml +++ b/tests/manual/deferred-renderer-qml/GBufferDebugger.qml @@ -47,12 +47,10 @@ Entity { components : [ Layer { id: debugLayer }, - GeometryRenderer { - view: PlaneMesh { - width: 2.0 - height: 2.0 - meshResolution: Qt.size(2, 2) - } + PlaneMesh { + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) }, Transform { // We rotate the plane so that it faces us diff --git a/tests/manual/deferred-renderer-qml/SceneEntity.qml b/tests/manual/deferred-renderer-qml/SceneEntity.qml index 03d9c0cb7..6a34be7fb 100644 --- a/tests/manual/deferred-renderer-qml/SceneEntity.qml +++ b/tests/manual/deferred-renderer-qml/SceneEntity.qml @@ -81,12 +81,10 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 10.0 ) } - GeometryRenderer { + SphereMesh { id : sphereMesh - view: SphereMesh { - rings: 50 - slices: 100 - } + rings: 50 + slices: 100 } SceneEffect { id : sceneMaterialEffect } diff --git a/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml b/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml index af242c970..3dae2b79a 100644 --- a/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml +++ b/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml @@ -118,12 +118,10 @@ Entity { components : [ Layer { id: screenQuadLayer }, - GeometryRenderer { - view: PlaneMesh { - width: 2.0 - height: 2.0 - meshResolution: Qt.size(2, 2) - } + PlaneMesh { + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) }, Transform { // We rotate the plane so that it faces us diff --git a/tests/manual/dragging/main.qml b/tests/manual/dragging/main.qml index c02fa594b..844b5066d 100644 --- a/tests/manual/dragging/main.qml +++ b/tests/manual/dragging/main.qml @@ -96,11 +96,9 @@ Entity { id: mainEntity objectName: "mainEntity" - GeometryRenderer { + ConeMesh { id: coneMesh - view: ConeMesh { - length: 4 - } + length: 4 } PhongMaterial { @@ -124,14 +122,12 @@ Entity { objectName: "draggerEntity" property vector3d position: Qt.vector3d(0, 0, 0) - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: .5 - length: 3 - rings: 2 - slices: 20 - } + radius: .5 + length: 3 + rings: 2 + slices: 20 } Transform { @@ -170,7 +166,7 @@ Entity { id: obstructionEntity components: [ - GeometryRenderer { view: CuboidMesh { } }, + CuboidMesh { }, PhongMaterial { diffuse: "blue" }, Transform { scale: 2 diff --git a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml index a21c50237..d9b33c511 100644 --- a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml +++ b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml @@ -56,13 +56,11 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, phongMaterial, transform ] - GeometryRenderer { + CuboidMesh { id: mesh - view: CuboidMesh { - yzMeshResolution: Qt.size(2, 2) - xzMeshResolution: Qt.size(2, 2) - xyMeshResolution: Qt.size(2, 2) - } + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) } GoochMaterial { diff --git a/tests/manual/dynamic-model-loader-qml/SphereEntity.qml b/tests/manual/dynamic-model-loader-qml/SphereEntity.qml index 14100f31f..8e11de99e 100644 --- a/tests/manual/dynamic-model-loader-qml/SphereEntity.qml +++ b/tests/manual/dynamic-model-loader-qml/SphereEntity.qml @@ -56,11 +56,9 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, material, transform ] - GeometryRenderer { + SphereMesh { id: mesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/dynamic-model-loader-qml/main.qml b/tests/manual/dynamic-model-loader-qml/main.qml index a403d2829..dc6b929cf 100644 --- a/tests/manual/dynamic-model-loader-qml/main.qml +++ b/tests/manual/dynamic-model-loader-qml/main.qml @@ -128,9 +128,8 @@ Entity { QQ2.Component { id: cylEntityCmp Entity { - GeometryRenderer { + CylinderMesh { id: cylMesh - view: CylinderMesh { } } PhongMaterial { id: phong @@ -143,14 +142,12 @@ Entity { QQ2.Component { id: torusEntityCmp Entity { - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/dynamicscene-cpp/boxentity.cpp b/tests/manual/dynamicscene-cpp/boxentity.cpp index 56b41c5f0..5952b04ec 100644 --- a/tests/manual/dynamicscene-cpp/boxentity.cpp +++ b/tests/manual/dynamicscene-cpp/boxentity.cpp @@ -67,11 +67,8 @@ BoxEntity::BoxEntity(QNode *parent) m_material->setSpecular(Qt::white); m_material->setShininess(150.0f); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(m_mesh); - addComponent(m_transform); - addComponent(renderer); + addComponent(m_mesh); addComponent(m_material); } diff --git a/tests/manual/enabled-qml/main.qml b/tests/manual/enabled-qml/main.qml index 6191fde1b..8ee933eb6 100644 --- a/tests/manual/enabled-qml/main.qml +++ b/tests/manual/enabled-qml/main.qml @@ -111,11 +111,9 @@ Entity { // Sphere Entity { - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - enabled: counter !== 0 - } + enabled: counter !== 0 } PhongMaterial { @@ -186,12 +184,10 @@ Entity { // Floor Entity { - GeometryRenderer { + PlaneMesh { id: planeMesh - view: PlaneMesh { - width: 25.0 - height: 10 - } + width: 25.0 + height: 10 } PhongMaterial { diff --git a/tests/manual/keyboardinput-qml/SphereEntity.qml b/tests/manual/keyboardinput-qml/SphereEntity.qml index 91f40230d..2b7b449d7 100644 --- a/tests/manual/keyboardinput-qml/SphereEntity.qml +++ b/tests/manual/keyboardinput-qml/SphereEntity.qml @@ -62,7 +62,7 @@ Entity { PhongMaterial { id: material } - GeometryRenderer { id: sphereMesh; view: SphereMesh { } } + SphereMesh { id: sphereMesh } Transform { id: transform diff --git a/tests/manual/layerfilter-qml/main.qml b/tests/manual/layerfilter-qml/main.qml index acc4dae08..c883d5745 100644 --- a/tests/manual/layerfilter-qml/main.qml +++ b/tests/manual/layerfilter-qml/main.qml @@ -148,12 +148,10 @@ Entity { components: [external_forward_renderer, inputSettings] - GeometryRenderer { + PlaneMesh { id: backgroundMesh - view: PlaneMesh { - width: 0.5 - height: 0.5 - } + width: 0.5 + height: 0.5 } Transform { diff --git a/tests/manual/loader-qml/CuboidEntity.qml b/tests/manual/loader-qml/CuboidEntity.qml index 580daa94b..d9b33c511 100644 --- a/tests/manual/loader-qml/CuboidEntity.qml +++ b/tests/manual/loader-qml/CuboidEntity.qml @@ -56,13 +56,11 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, phongMaterial, transform ] - GeometryRenderer { + CuboidMesh { id: mesh - view: CuboidMesh { - yzMeshResolution: Qt.size(2, 2) - xzMeshResolution: Qt.size(2, 2) - xyMeshResolution: Qt.size(2, 2) - } + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) } GoochMaterial { diff --git a/tests/manual/loader-qml/SphereEntity.qml b/tests/manual/loader-qml/SphereEntity.qml index 14100f31f..8e11de99e 100644 --- a/tests/manual/loader-qml/SphereEntity.qml +++ b/tests/manual/loader-qml/SphereEntity.qml @@ -56,11 +56,9 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, material, transform ] - GeometryRenderer { + SphereMesh { id: mesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/loader-qml/main.qml b/tests/manual/loader-qml/main.qml index 276883103..272331911 100644 --- a/tests/manual/loader-qml/main.qml +++ b/tests/manual/loader-qml/main.qml @@ -87,14 +87,12 @@ Entity { diffuse: "yellow" } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/lod/ConeEntity.qml b/tests/manual/lod/ConeEntity.qml index d80834bcf..bfe6703b6 100644 --- a/tests/manual/lod/ConeEntity.qml +++ b/tests/manual/lod/ConeEntity.qml @@ -56,12 +56,10 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, phongMaterial, transform ] - GeometryRenderer { - view: ConeMesh { - id: mesh - bottomRadius: 1.5 - length: 3 - } + ConeMesh { + id: mesh + bottomRadius: 1.5 + length: 3 } PhongMaterial { diff --git a/tests/manual/lod/CuboidEntity.qml b/tests/manual/lod/CuboidEntity.qml index 2b8acbabf..875d98b32 100644 --- a/tests/manual/lod/CuboidEntity.qml +++ b/tests/manual/lod/CuboidEntity.qml @@ -56,13 +56,11 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, phongMaterial, transform ] - GeometryRenderer { + CuboidMesh { id: mesh - view: CuboidMesh { - yzMeshResolution: Qt.size(2, 2) - xzMeshResolution: Qt.size(2, 2) - xyMeshResolution: Qt.size(2, 2) - } + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) } PhongMaterial { diff --git a/tests/manual/lod/CylinderEntity.qml b/tests/manual/lod/CylinderEntity.qml index 3066f7b75..f89bd3eeb 100644 --- a/tests/manual/lod/CylinderEntity.qml +++ b/tests/manual/lod/CylinderEntity.qml @@ -56,12 +56,10 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, phongMaterial, transform ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - } + radius: 1 + length: 3 } PhongMaterial { diff --git a/tests/manual/lod/SphereEntity.qml b/tests/manual/lod/SphereEntity.qml index 7e3df2cc3..3671921b8 100644 --- a/tests/manual/lod/SphereEntity.qml +++ b/tests/manual/lod/SphereEntity.qml @@ -56,11 +56,9 @@ import Qt3D.Extras 2.0 Entity { components: [ mesh, material, transform ] - GeometryRenderer { + SphereMesh { id: mesh - SphereMesh { - radius: 1 - } + radius: 1 } PhongMaterial { diff --git a/tests/manual/lod/main.qml b/tests/manual/lod/main.qml index 98cbc7aaa..80547dcff 100644 --- a/tests/manual/lod/main.qml +++ b/tests/manual/lod/main.qml @@ -104,16 +104,14 @@ Entity { Entity { components: [ - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 2 - slices: sliceValues[lod.currentIndex] - - property var sliceValues: [20, 10, 6, 4] - } + radius: 1 + length: 3 + rings: 2 + slices: sliceValues[lod.currentIndex] + + property var sliceValues: [20, 10, 6, 4] }, Transform { scale: 1.5 diff --git a/tests/manual/manual-renderloop/main.cpp b/tests/manual/manual-renderloop/main.cpp index b8382fde2..024693a90 100644 --- a/tests/manual/manual-renderloop/main.cpp +++ b/tests/manual/manual-renderloop/main.cpp @@ -130,9 +130,7 @@ private: torusTransform->setScale3D(QVector3D(1.5, 1, 0.5)); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(torusMesh); - torusEntity->addComponent(renderer); + torusEntity->addComponent(torusMesh); torusEntity->addComponent(material); torusEntity->addComponent(torusTransform); diff --git a/tests/manual/mesh-morphing/main.cpp b/tests/manual/mesh-morphing/main.cpp index 79f6eee60..489ac196f 100644 --- a/tests/manual/mesh-morphing/main.cpp +++ b/tests/manual/mesh-morphing/main.cpp @@ -120,11 +120,8 @@ int main(int argc, char **argv) Qt3DAnimation::QVertexBlendAnimation *animation = new Qt3DAnimation::QVertexBlendAnimation; const QList times = { 0.0f, 5.0f, 8.0f, 12.0f }; - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - animation->setTargetPositions(times); - animation->setTarget(renderer); + animation->setTarget(mesh); animation->setMorphTargets(morphTargets); // Material @@ -136,7 +133,7 @@ int main(int argc, char **argv) // Cylinder Qt3DCore::QEntity *morphingEntity = new Qt3DCore::QEntity(rootEntity); - morphingEntity->addComponent(renderer); + morphingEntity->addComponent(mesh); morphingEntity->addComponent(transform); morphingEntity->addComponent(material); @@ -157,11 +154,8 @@ int main(int argc, char **argv) cylinderMaterial->setDiffuse(Qt::red); // Cylinder - renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cylinderMesh); - Qt3DCore::QEntity *cylinder = new Qt3DCore::QEntity(rootEntity); - cylinder->addComponent(renderer); + cylinder->addComponent(cylinderMesh); cylinder->addComponent(cylinderTransform); cylinder->addComponent(cylinderMaterial); diff --git a/tests/manual/mouseinput-qml/main.qml b/tests/manual/mouseinput-qml/main.qml index e0cc8f73e..38ad847ed 100644 --- a/tests/manual/mouseinput-qml/main.qml +++ b/tests/manual/mouseinput-qml/main.qml @@ -81,11 +81,9 @@ Entity { InputSettings {} ] - GeometryRenderer{ + SphereMesh{ id: sphereMesh - SphereMesh { - radius: 3 - } + radius: 3 } PhongMaterial { diff --git a/tests/manual/multiplewindows-qml/Scene.qml b/tests/manual/multiplewindows-qml/Scene.qml index 89fd2794d..06107667d 100644 --- a/tests/manual/multiplewindows-qml/Scene.qml +++ b/tests/manual/multiplewindows-qml/Scene.qml @@ -99,14 +99,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -120,11 +118,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/paintedtexture-cpp/scene.cpp b/tests/manual/paintedtexture-cpp/scene.cpp index 83ba172f7..e5ef6730f 100644 --- a/tests/manual/paintedtexture-cpp/scene.cpp +++ b/tests/manual/paintedtexture-cpp/scene.cpp @@ -123,12 +123,9 @@ Scene::Scene(Qt3DCore::QEntity *rootEntity) mat->setSpecular(QColor(255, 255, 255)); mat->setDiffuse(tex); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cuboid); - //Cuboid m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity); - m_cuboidEntity->addComponent(renderer); + m_cuboidEntity->addComponent(cuboid); m_cuboidEntity->addComponent(mat); m_cuboidEntity->addComponent(m_transform); diff --git a/tests/manual/picking-qml/main.qml b/tests/manual/picking-qml/main.qml index 8de39a66f..10f6a76e8 100644 --- a/tests/manual/picking-qml/main.qml +++ b/tests/manual/picking-qml/main.qml @@ -152,7 +152,7 @@ Entity { InputSettings {} ] - GeometryRenderer { id: cubeMesh; view: CuboidMesh { } } + CuboidMesh { id: cubeMesh } PickableEntity { id: cube1 @@ -260,7 +260,7 @@ Entity { } readonly property PhongMaterial material: PhongMaterial { diffuse: "yellow" } - readonly property GeometryRenderer sphereMesh: GeometryRenderer { view: SphereMesh { } } + readonly property GeometryRenderer sphereMesh: SphereMesh { } components: [sphereMesh, transform, material, sceneRoot.contentLayer, objectPicker] } @@ -288,7 +288,7 @@ Entity { } readonly property PhongMaterial material: PhongMaterial { diffuse: "green" } - readonly property GeometryRenderer sphereMesh: GeometryRenderer { view: SphereMesh { } } + readonly property GeometryRenderer sphereMesh: SphereMesh { } components: [sphereMesh, transform, material, sceneRoot.contentLayer, objectPicker, pickingProxy] } diff --git a/tests/manual/plasma/main.qml b/tests/manual/plasma/main.qml index f93970405..0a01f699b 100644 --- a/tests/manual/plasma/main.qml +++ b/tests/manual/plasma/main.qml @@ -60,12 +60,10 @@ Entity { Entity { components: [ - GeometryRenderer { - view: PlaneMesh { - width: 2.0 - height: 2.0 - meshResolution: Qt.size(2, 2) - } + PlaneMesh { + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) }, Transform { // Rotate the plane so that it faces us diff --git a/tests/manual/proximityfilter/main.qml b/tests/manual/proximityfilter/main.qml index ec66f8e5d..d55d3a90e 100644 --- a/tests/manual/proximityfilter/main.qml +++ b/tests/manual/proximityfilter/main.qml @@ -99,9 +99,8 @@ Entity { InputSettings { } ] - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { } } PhongMaterial { diff --git a/tests/manual/qtbug-72236/main.cpp b/tests/manual/qtbug-72236/main.cpp index 06313c122..2bf90c03f 100644 --- a/tests/manual/qtbug-72236/main.cpp +++ b/tests/manual/qtbug-72236/main.cpp @@ -114,12 +114,9 @@ int main(int argc, char **argv) Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity); material->setDiffuse(Qt::red); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - // Cylinder Qt3DCore::QEntity *cylinder = new Qt3DCore::QEntity(rootEntity); - cylinder->addComponent(renderer); + cylinder->addComponent(mesh); cylinder->addComponent(transform); cylinder->addComponent(material); diff --git a/tests/manual/qtbug-76766/PostProcess.qml b/tests/manual/qtbug-76766/PostProcess.qml index 3e9218451..cd4c9c0c6 100644 --- a/tests/manual/qtbug-76766/PostProcess.qml +++ b/tests/manual/qtbug-76766/PostProcess.qml @@ -103,13 +103,11 @@ Entity { effect: materialEffect } - GeometryRenderer { + PlaneMesh { id: planeMesh - view: PlaneMesh { - width: 2.0 - height: 2.0 - meshResolution: Qt.size(2, 2) - } + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) } components : [ diff --git a/tests/manual/qtbug-76766/SceneRoot.qml b/tests/manual/qtbug-76766/SceneRoot.qml index 93e96a43d..d05c54cf4 100644 --- a/tests/manual/qtbug-76766/SceneRoot.qml +++ b/tests/manual/qtbug-76766/SceneRoot.qml @@ -111,7 +111,7 @@ Entity { Material1 { color: "red" }, - GeometryRenderer { view: SphereMesh { } } + SphereMesh { } ] } @@ -124,7 +124,7 @@ Entity { Material2 { color: "green" }, - GeometryRenderer { view: SphereMesh { } } + SphereMesh { } ] } } @@ -147,7 +147,7 @@ Entity { loops: Animation.Infinite } }, - GeometryRenderer { view: SphereMesh { } } + SphereMesh { } ] } @@ -161,7 +161,7 @@ Entity { Material2 { color: "orange" }, - GeometryRenderer { view: SphereMesh { } } + SphereMesh { } ] } } diff --git a/tests/manual/raster-cpp/main.cpp b/tests/manual/raster-cpp/main.cpp index 4f902cad8..2eaeea6ec 100644 --- a/tests/manual/raster-cpp/main.cpp +++ b/tests/manual/raster-cpp/main.cpp @@ -117,12 +117,9 @@ int main(int argc, char **argv) Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity); material->setDiffuse(Qt::red); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(mesh); - // Cylinder Qt3DCore::QEntity *cylinder = new Qt3DCore::QEntity(rootEntity); - cylinder->addComponent(renderer); + cylinder->addComponent(mesh); cylinder->addComponent(transform); cylinder->addComponent(material); diff --git a/tests/manual/raster-qml/main.qml b/tests/manual/raster-qml/main.qml index 35d414771..91fc288d0 100644 --- a/tests/manual/raster-qml/main.qml +++ b/tests/manual/raster-qml/main.qml @@ -90,14 +90,12 @@ Entity { components: [external_forward_renderer, inputSettings] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + radius: 1 + length: 3 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/raycasting-qml/CylinderEntity.qml b/tests/manual/raycasting-qml/CylinderEntity.qml index 08fed9434..4bae3c207 100644 --- a/tests/manual/raycasting-qml/CylinderEntity.qml +++ b/tests/manual/raycasting-qml/CylinderEntity.qml @@ -61,14 +61,12 @@ Entity { components: [ mesh, material, transform ] - GeometryRenderer { + CylinderMesh { id: mesh - view: CylinderMesh { - radius: 1 - length: 3 - rings: 100 - slices: 20 - } + radius: 1 + length: 3 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/render-qml-to-texture-qml/main.qml b/tests/manual/render-qml-to-texture-qml/main.qml index 047906973..38a0259ee 100644 --- a/tests/manual/render-qml-to-texture-qml/main.qml +++ b/tests/manual/render-qml-to-texture-qml/main.qml @@ -116,13 +116,11 @@ QQ2.Item { InputSettings {} ] - GeometryRenderer { + PlaneMesh { id: planeMesh - view: PlaneMesh { - width: 4 - height: 4 - mirrored: true - } + width: 4 + height: 4 + mirrored: true } Entity { diff --git a/tests/manual/render-qml-to-texture/main.cpp b/tests/manual/render-qml-to-texture/main.cpp index 880b1b8cb..284514827 100644 --- a/tests/manual/render-qml-to-texture/main.cpp +++ b/tests/manual/render-qml-to-texture/main.cpp @@ -113,9 +113,7 @@ int main(int argc, char *argv[]) Qt3DExtras::QPlaneMesh* planeMesh = new Qt3DExtras::QPlaneMesh(planeEntity); planeMesh->setWidth(4); planeMesh->setHeight(4); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(planeMesh); - planeEntity->addComponent(renderer); + planeEntity->addComponent(planeMesh); PlaneMaterial* material = new PlaneMaterial(offscreenTexture, planeEntity); planeEntity->addComponent(material); diff --git a/tests/manual/rendercapture-cpp/main.cpp b/tests/manual/rendercapture-cpp/main.cpp index ac8d74787..da03fa7d6 100644 --- a/tests/manual/rendercapture-cpp/main.cpp +++ b/tests/manual/rendercapture-cpp/main.cpp @@ -95,9 +95,7 @@ Qt3DCore::QEntity *createScene() torusTransform->setScale3D(QVector3D(1.5, 1, 0.5)); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(torusMesh); - torusEntity->addComponent(renderer); + torusEntity->addComponent(torusMesh); torusEntity->addComponent(torusTransform); torusEntity->addComponent(material); @@ -120,10 +118,7 @@ Qt3DCore::QEntity *createScene() sphereRotateTransformAnimation->setLoopCount(-1); sphereRotateTransformAnimation->start(); - renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(sphereMesh); sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(material); diff --git a/tests/manual/rendercapture-qml-fbo/CaptureScene.qml b/tests/manual/rendercapture-qml-fbo/CaptureScene.qml index ad1fae793..9c6cb1431 100644 --- a/tests/manual/rendercapture-qml-fbo/CaptureScene.qml +++ b/tests/manual/rendercapture-qml-fbo/CaptureScene.qml @@ -157,14 +157,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -178,11 +176,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/rendercapture-qml/CaptureScene.qml b/tests/manual/rendercapture-qml/CaptureScene.qml index 0ebfaf5be..ea355042a 100644 --- a/tests/manual/rendercapture-qml/CaptureScene.qml +++ b/tests/manual/rendercapture-qml/CaptureScene.qml @@ -96,14 +96,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -117,11 +115,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/rendertarget-cpp/main.cpp b/tests/manual/rendertarget-cpp/main.cpp index 7e621a591..601392011 100644 --- a/tests/manual/rendertarget-cpp/main.cpp +++ b/tests/manual/rendertarget-cpp/main.cpp @@ -224,9 +224,7 @@ Qt3DCore::QEntity *createScene(const Renderer& renderer) torusTransform->setScale3D(QVector3D(1.5, 1, 0.5)); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f)); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(torusMesh); - torusEntity->addComponent(renderer); + torusEntity->addComponent(torusMesh); torusEntity->addComponent(torusTransform); torusEntity->addComponent(childMaterial); @@ -250,10 +248,7 @@ Qt3DCore::QEntity *createScene(const Renderer& renderer) sphereRotateTransformAnimation->setLoopCount(-1); sphereRotateTransformAnimation->start(); - renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(sphereMesh); - - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(sphereMesh); sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(childMaterial); } @@ -266,14 +261,12 @@ Qt3DCore::QEntity *createScene(const Renderer& renderer) auto cubeMesh = new Qt3DExtras::QCuboidMesh; auto sphereTransform = new Qt3DCore::QTransform; sphereTransform->setRotationY(100); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cubeMesh); cubeMesh->setXExtent(10); cubeMesh->setYExtent(10); cubeMesh->setZExtent(10); - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(cubeMesh); sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(mainMaterial); } diff --git a/tests/manual/scene3d-in-sync/main.qml b/tests/manual/scene3d-in-sync/main.qml index 45b68dcb7..31d4096a7 100644 --- a/tests/manual/scene3d-in-sync/main.qml +++ b/tests/manual/scene3d-in-sync/main.qml @@ -113,12 +113,10 @@ Item { Entity { id: trackingCube components: [ - GeometryRenderer { - view: CuboidMesh { - xExtent: 100 - yExtent: 100 - zExtent: 2 - } + CuboidMesh { + xExtent: 100 + yExtent: 100 + zExtent: 2 }, PhongMaterial { diff --git a/tests/manual/scene3d-loader/AnimatedEntity.qml b/tests/manual/scene3d-loader/AnimatedEntity.qml index 5c406dbf6..0f6b7da1a 100644 --- a/tests/manual/scene3d-loader/AnimatedEntity.qml +++ b/tests/manual/scene3d-loader/AnimatedEntity.qml @@ -84,14 +84,12 @@ Entity { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { @@ -105,11 +103,9 @@ Entity { components: [ torusMesh, material, torusTransform ] } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/scene3d-loader/Scene2.qml b/tests/manual/scene3d-loader/Scene2.qml index ee6aabe58..072d8f798 100644 --- a/tests/manual/scene3d-loader/Scene2.qml +++ b/tests/manual/scene3d-loader/Scene2.qml @@ -83,14 +83,12 @@ Scene3D { components: [renderSettings] - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Transform { diff --git a/tests/manual/scene3d-visibility/main.qml b/tests/manual/scene3d-visibility/main.qml index f7a49a8b3..ccfa3227f 100644 --- a/tests/manual/scene3d-visibility/main.qml +++ b/tests/manual/scene3d-visibility/main.qml @@ -106,21 +106,17 @@ Item { id: material } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/shader-image-qml/main.qml b/tests/manual/shader-image-qml/main.qml index 960b10e0e..3ed71a892 100644 --- a/tests/manual/shader-image-qml/main.qml +++ b/tests/manual/shader-image-qml/main.qml @@ -200,9 +200,8 @@ Entity { // Preview Texture Scene Entity { - GeometryRenderer { + PlaneMesh { id: planeMesh - view: PlaneMesh { } } components: Transform { diff --git a/tests/manual/shared_texture_image/main.qml b/tests/manual/shared_texture_image/main.qml index b21a07bb9..4d5f15742 100644 --- a/tests/manual/shared_texture_image/main.qml +++ b/tests/manual/shared_texture_image/main.qml @@ -93,7 +93,7 @@ Entity { source: "qrc:/image.png" } - readonly property GeometryRenderer mesh: GeometryRenderer { view: CuboidMesh {} } + readonly property GeometryRenderer mesh: CuboidMesh { } Entity { id: leftCube diff --git a/tests/manual/sharedtexture/main.cpp b/tests/manual/sharedtexture/main.cpp index c4b0df9ca..b4e5b57a8 100644 --- a/tests/manual/sharedtexture/main.cpp +++ b/tests/manual/sharedtexture/main.cpp @@ -98,10 +98,7 @@ Qt3DCore::QEntity *createScene(Qt3DExtras::Qt3DWindow *view, Qt3DRender::QAbstra cubeRotateTransformAnimation->setLoopCount(-1); cubeRotateTransformAnimation->start(); - auto renderer = new Qt3DRender::QGeometryRenderer; - renderer->setView(cuboidMesh); - - sphereEntity->addComponent(renderer); + sphereEntity->addComponent(cuboidMesh); sphereEntity->addComponent(transform); sphereEntity->addComponent(material); diff --git a/tests/manual/sharedtextureqml/main.qml b/tests/manual/sharedtextureqml/main.qml index 5db5b1ea1..4eea4c752 100644 --- a/tests/manual/sharedtextureqml/main.qml +++ b/tests/manual/sharedtextureqml/main.qml @@ -115,7 +115,7 @@ Item { Entity { id: cubeEntity - readonly property GeometryRenderer cuboid: GeometryRenderer { view: CuboidMesh {} } + readonly property GeometryRenderer cuboid: CuboidMesh { } readonly property DiffuseMapMaterial material: DiffuseMapMaterial { diffuse: shaderGLTexture } diff --git a/tests/manual/simple-shaders-qml/main.qml b/tests/manual/simple-shaders-qml/main.qml index d45ff4cdb..38758d500 100644 --- a/tests/manual/simple-shaders-qml/main.qml +++ b/tests/manual/simple-shaders-qml/main.qml @@ -82,14 +82,12 @@ Entity { InputSettings { } ] - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } Entity { diff --git a/tests/manual/skybox/Skybox.qml b/tests/manual/skybox/Skybox.qml index e2c9b6b68..f8a77bd65 100644 --- a/tests/manual/skybox/Skybox.qml +++ b/tests/manual/skybox/Skybox.qml @@ -86,13 +86,11 @@ Entity { fragmentShaderCode: loadSource("qrc:/shaders/es2/skybox.frag") } - GeometryRenderer { + CuboidMesh { id: cuboidMesh - view: CuboidMesh { - yzMeshResolution: Qt.size(2, 2) - xzMeshResolution: Qt.size(2, 2) - xyMeshResolution: Qt.size(2, 2) - } + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) } Transform { diff --git a/tests/manual/skybox/main.qml b/tests/manual/skybox/main.qml index 69c837121..af476a1ca 100644 --- a/tests/manual/skybox/main.qml +++ b/tests/manual/skybox/main.qml @@ -91,7 +91,7 @@ Entity { Entity { components: [ - GeometryRenderer { view: SphereMesh { radius: 5 } }, + SphereMesh { radius: 5 }, PhongMaterial { diffuse: "dodgerblue" } ] } diff --git a/tests/manual/subtree-enabler-qml/main.qml b/tests/manual/subtree-enabler-qml/main.qml index 03c9beff6..226c2a84a 100644 --- a/tests/manual/subtree-enabler-qml/main.qml +++ b/tests/manual/subtree-enabler-qml/main.qml @@ -102,8 +102,8 @@ Entity { Transform { rotation: fromAxisAndAngle(Qt.vector3d(0, 0, 1), -sceneRoot.rotationAngle) }, - GeometryRenderer { view: CylinderMesh {} }, - MetalRoughMaterial {} + CylinderMesh { }, + MetalRoughMaterial { } ] } } // sceneRoot diff --git a/tests/manual/texture-updates-cpp/scene.cpp b/tests/manual/texture-updates-cpp/scene.cpp index 65277227c..a68052653 100644 --- a/tests/manual/texture-updates-cpp/scene.cpp +++ b/tests/manual/texture-updates-cpp/scene.cpp @@ -86,12 +86,9 @@ Scene::Scene(Qt3DCore::QEntity *rootEntity) mat->setSpecular(QColor(255, 255, 255)); mat->setDiffuse(m_texture); - auto renderer = new Qt3DRender::QGeometryRenderer(); - renderer->setView(cuboid); - //Cuboid m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity); - m_cuboidEntity->addComponent(renderer); + m_cuboidEntity->addComponent(cuboid); m_cuboidEntity->addComponent(mat); m_cuboidEntity->addComponent(m_transform); } diff --git a/tests/manual/texture_property_updates/main.qml b/tests/manual/texture_property_updates/main.qml index 4ea241f63..7794dab55 100644 --- a/tests/manual/texture_property_updates/main.qml +++ b/tests/manual/texture_property_updates/main.qml @@ -131,7 +131,7 @@ QQ2.Item { InputSettings { } ] - GeometryRenderer { id: mesh; view: CuboidMesh { } } + CuboidMesh { id: mesh } NodeInstantiator { id: instantiator diff --git a/tests/manual/transparency-qml-scene3d/Scene.qml b/tests/manual/transparency-qml-scene3d/Scene.qml index 94801d8ed..43d49dc54 100644 --- a/tests/manual/transparency-qml-scene3d/Scene.qml +++ b/tests/manual/transparency-qml-scene3d/Scene.qml @@ -103,21 +103,17 @@ Entity { extension: ".webp" } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/transparency-qml/main.qml b/tests/manual/transparency-qml/main.qml index 3c7d8fd07..6d2b20fe8 100644 --- a/tests/manual/transparency-qml/main.qml +++ b/tests/manual/transparency-qml/main.qml @@ -98,21 +98,17 @@ Entity { components: [transform, light] } - GeometryRenderer { + TorusMesh { id: torusMesh - view: TorusMesh { - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 } - GeometryRenderer { + SphereMesh { id: sphereMesh - view: SphereMesh { - radius: 3 - } + radius: 3 } Transform { diff --git a/tests/manual/video-texture-qml/main.qml b/tests/manual/video-texture-qml/main.qml index 1a31dae2f..93110ef2a 100644 --- a/tests/manual/video-texture-qml/main.qml +++ b/tests/manual/video-texture-qml/main.qml @@ -109,9 +109,8 @@ Entity { InputSettings {} ] - GeometryRenderer { + CuboidMesh { id: mesh - view: CuboidMesh { } } Entity { -- cgit v1.2.3