From 63ffb20819f6448b83edb52e23bd0bf89ebe0c20 Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Thu, 12 Dec 2019 19:10:08 +0100 Subject: [PATCH] [ui][3D] add EnvironmentMapEntity to display equirectangular images Load EXR files in the 3D viewport as environment maps mapped on a sphere "attached" to the camera. * improve exr loading strategy by considering depthmaps and env maps * update to DepthMapEntity 2.1 (required to get the loading status) --- meshroom/ui/qml/Viewer3D/DepthMapLoader.qml | 2 +- .../ui/qml/Viewer3D/EnvironmentMapEntity.qml | 48 +++++++++++++++++++ meshroom/ui/qml/Viewer3D/MediaLibrary.qml | 4 ++ meshroom/ui/qml/Viewer3D/MediaLoader.qml | 36 ++++++++++---- meshroom/ui/qml/Viewer3D/Viewer3D.qml | 1 + 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 meshroom/ui/qml/Viewer3D/EnvironmentMapEntity.qml diff --git a/meshroom/ui/qml/Viewer3D/DepthMapLoader.qml b/meshroom/ui/qml/Viewer3D/DepthMapLoader.qml index 32f7ae1a..0f07ff91 100644 --- a/meshroom/ui/qml/Viewer3D/DepthMapLoader.qml +++ b/meshroom/ui/qml/Viewer3D/DepthMapLoader.qml @@ -1,4 +1,4 @@ -import DepthMapEntity 2.0 +import DepthMapEntity 2.1 /** * Support for Depth Map files (EXR) in Qt3d. diff --git a/meshroom/ui/qml/Viewer3D/EnvironmentMapEntity.qml b/meshroom/ui/qml/Viewer3D/EnvironmentMapEntity.qml new file mode 100644 index 00000000..0bd8877b --- /dev/null +++ b/meshroom/ui/qml/Viewer3D/EnvironmentMapEntity.qml @@ -0,0 +1,48 @@ +import QtQuick 2.9 +import Qt3D.Core 2.1 +import Qt3D.Render 2.1 +import Qt3D.Extras 2.10 + + +/** + * EnvironmentMap maps an equirectangular image on a Sphere. + * The 'position' property can be used to virually attach it to a camera + * and get the impression of an environment at an infinite distance. + */ +Entity { + id: root + + /// Source of the equirectangular image + property url source + /// Radius of the sphere + property alias radius: sphereMesh.radius + /// Number of slices of the sphere + property alias slices: sphereMesh.slices + /// Number of rings of the sphere + property alias rings: sphereMesh.rings + /// Position of the sphere + property alias position: transform.translation + + components: [ + SphereMesh { + id: sphereMesh + radius: 1000 + slices: 50 + rings: 50 + }, + Transform { + id: transform + translation: root.position + }, + DiffuseMapMaterial { + ambient: "#FFF" + shininess: 0 + specular: "#000" + diffuse: TextureLoader { + magnificationFilter: Texture.Linear + mirrored: true + source: root.source + } + } + ] +} diff --git a/meshroom/ui/qml/Viewer3D/MediaLibrary.qml b/meshroom/ui/qml/Viewer3D/MediaLibrary.qml index 56af1866..6542e2db 100644 --- a/meshroom/ui/qml/Viewer3D/MediaLibrary.qml +++ b/meshroom/ui/qml/Viewer3D/MediaLibrary.qml @@ -16,6 +16,9 @@ Entity { property bool pickingEnabled: false readonly property alias count: instantiator.count // number of instantiated media delegates + /// Camera to consider for positionning + property Camera camera: null + /// True while at least one media is being loaded readonly property bool loading: { for(var i=0; i