Use qmlSfmData

This commit is contained in:
Fabien SERVANT 2023-09-26 14:51:27 +02:00 committed by Candice Bentéjac
parent ec70373c7b
commit aee197e063
4 changed files with 110 additions and 8 deletions

View file

@ -36,7 +36,7 @@ Tags
- Merge "rcMAJOR.MINOR" into "develop"
- Push "develop" into "master"
- Create branch: vMAJOR.MINOR
- Create tag: vMAJOR.MINOR.PATCH on Meshroom, qtAliceVision, qmlAlembic
- Create tag: vMAJOR.MINOR.PATCH on Meshroom, qtAliceVision
- Create branch from develop: "startMAJOR.MINOR"
- Upload binaries on fosshub
- Fill up Github release note

View file

@ -46,7 +46,14 @@ import Utils 1.0
}
switch(Filepath.extension(source)) {
case ".abc": if(Viewer3DSettings.supportAlembic) component = abcLoaderEntityComponent; break;
case ".abc":
case ".json":
case ".sfm":
if(Viewer3DSettings.supportSfmData)
{
component = sfmDataLoaderEntityComponent;
}
break;
case ".exr": if(Viewer3DSettings.supportDepthMap) component = exrLoaderComponent; break;
case ".obj":
case ".stl":
@ -81,12 +88,12 @@ import Utils 1.0
}
Component {
id: abcLoaderEntityComponent
id: sfmDataLoaderEntityComponent
MediaLoaderEntity {
id: abcLoaderEntity
id: sfmDataLoaderEntity
Component.onCompleted: {
var obj = Viewer3DSettings.abcLoaderComp.createObject(abcLoaderEntity, {
var obj = Viewer3DSettings.sfmDataLoaderComp.createObject(sfmDataLoaderEntity, {
'source': source,
'pointSize': Qt.binding(function() { return 0.01 * Viewer3DSettings.pointSize }),
'locatorScale': Qt.binding(function() { return Viewer3DSettings.cameraScale }),
@ -94,6 +101,7 @@ import Utils 1.0
});
obj.statusChanged.connect(function() {
if(obj.status === SceneLoader.Ready) {
for(var i = 0; i < obj.pointClouds.length; ++i) {
vertexCount += Scene3DHelper.vertexCount(obj.pointClouds[i]);

View file

@ -0,0 +1,90 @@
import SfmDataEntity 1.0
import QtQuick 2.15
import Qt3D.Core 2.15
import Qt3D.Render 2.15
import Qt3D.Extras 2.15
/**
* Support for sfmdata files in Qt3d.
* Create this component dynamically to test for SfmDataEntity plugin availability.
*/
SfmDataEntity {
id: root
property bool cameraPickingEnabled: true
// filter out non-reconstructed cameras
skipHidden: true
signal cameraSelected(var viewId)
function spawnCameraSelectors() {
var validCameras = 0;
// spawn camera selector for each camera
for(var i = 0; i < root.cameras.length; ++i)
{
var cam = root.cameras[i];
// retrieve view id
var viewId = cam.viewId;
if(viewId === undefined)
continue;
camSelectionComponent.createObject(cam, {"viewId": viewId});
validCameras++;
}
return validCameras;
}
SystemPalette {
id: activePalette
}
// Camera selection picking and display
Component {
id: camSelectionComponent
Entity {
id: camSelector
property string viewId
// Qt 5.13: binding cameraPicker.enabled to cameraPickerEnabled
// causes rendering issues when entity gets disabled.
// set CuboidMesh extent to 0 to disable picking.
property color customColor: Qt.hsva((parseInt(viewId) / 255.0) % 1.0, 0.3, 1.0, 1.0)
property real extent: cameraPickingEnabled ? 0.2 : 0
components: [
// Use cuboid to represent the camera
Transform {
translation: Qt.vector3d(0, 0, 0.5 * cameraBack.zExtent)
},
CuboidMesh { id: cameraBack; xExtent: parent.extent; yExtent: xExtent; zExtent: xExtent * 0.2 },
/*
// Use a stick to represent the camera
Transform {
translation: Qt.vector3d(0, 0, 0.5 * cameraStick.zExtent)
},
CuboidMesh { id: cameraStick; xExtent: parent.extent * 0.2; yExtent: xExtent; zExtent: xExtent * 50.0 },
*/
PhongMaterial{
id: mat
ambient: _reconstruction && viewId === _reconstruction.selectedViewId ? activePalette.highlight : customColor // "#CCC"
diffuse: cameraPicker.containsMouse ? Qt.lighter(activePalette.highlight, 1.2) : ambient
},
ObjectPicker {
id: cameraPicker
property point pos
onPressed: {
pos = pick.position;
pick.accepted = (pick.buttons & Qt.LeftButton) && cameraPickingEnabled
}
onReleased: {
const delta = Qt.point(Math.abs(pos.x - pick.position.x), Math.abs(pos.y - pick.position.y));
// only trigger picking when mouse has not moved between press and release
if(delta.x + delta.y < 4)
{
_reconstruction.selectedViewId = camSelector.viewId;
}
}
}
]
}
}
}

View file

@ -6,16 +6,20 @@ import MaterialIcons 2.2
* Viewer3DSettings singleton gathers properties related to the 3D Viewer capabilities, state and display options.
*/
Item {
readonly property Component abcLoaderComp: Qt.createComponent("AlembicLoader.qml")
readonly property bool supportAlembic: abcLoaderComp.status == Component.Ready
readonly property Component sfmDataLoaderComp: Qt.createComponent("SfmDataLoader.qml")
readonly property bool supportSfmData: sfmDataLoaderComp.status == Component.Ready
readonly property Component depthMapLoaderComp: Qt.createComponent("DepthMapLoader.qml")
readonly property bool supportDepthMap: depthMapLoaderComp.status == Component.Ready
// supported 3D files extensions
readonly property var supportedExtensions: {
var exts = ['.obj', '.stl', '.fbx', '.gltf'];
if(supportAlembic)
if(supportSfmData)
{
exts.push('.abc');
exts.push('.json');
exts.push('.sfm');
}
if(supportDepthMap)
exts.push('.exr');
return exts;