Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alicevision/meshroom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Castan <fabcastan@gmail.com>2022-11-03 03:07:01 +0300
committerGitHub <noreply@github.com>2022-11-03 03:07:01 +0300
commit4911ec9ce94644f84529f068913316e94cad7573 (patch)
tree5394f3a141a0e86cd1acf1b02ec01c0bc548aa19
parent3822bc847e1f1bb5a98d525dc0631aec035d6d8d (diff)
parentd0331d3d2e51d2a64f9dce54f780934862d1ca5d (diff)
Merge pull request #1805 from alicevision/dev/boundingBoxFrame
Update bounding box display to use the correct geometric frame
-rw-r--r--meshroom/ui/components/scene3D.py17
-rw-r--r--meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml50
2 files changed, 56 insertions, 11 deletions
diff --git a/meshroom/ui/components/scene3D.py b/meshroom/ui/components/scene3D.py
index b4569c19..ef91b853 100644
--- a/meshroom/ui/components/scene3D.py
+++ b/meshroom/ui/components/scene3D.py
@@ -123,7 +123,7 @@ class Transformations3DHelper(QObject):
viewMatrix = camera.transform().matrix().inverted()
projectedPoint = (camera.projectionMatrix() * viewMatrix[0]).map(point)
projectedPoint2D = QVector2D(
- projectedPoint.x()/projectedPoint.w(),
+ projectedPoint.x()/projectedPoint.w(),
projectedPoint.y()/projectedPoint.w()
)
@@ -145,7 +145,7 @@ class Transformations3DHelper(QObject):
initialScaleMat (QMatrix4x4): initial scale matrix
translateVec (QVector3D): vector used for the local translation
"""
- # Compute the translation transformation matrix
+ # Compute the translation transformation matrix
translationMat = QMatrix4x4()
translationMat.translate(translateVec)
@@ -245,6 +245,19 @@ class Transformations3DHelper(QObject):
return modelMat
+ @Slot(QVector3D, result=QVector3D)
+ def convertRotationFromCV2GL(self, rotation):
+ """ Convert rotation (euler angles) from Computer Vision
+ to Computer Graphics coordinate system (like opengl).
+ """
+ M = QQuaternion.fromAxisAndAngle(QVector3D(1, 0, 0), 180.0)
+
+ quaternion = QQuaternion.fromEulerAngles(rotation)
+
+ U = M * quaternion * M
+
+ return U.toEulerAngles()
+
@Slot(QVector3D, QMatrix4x4, Qt3DRender.QCamera, QSize, result=float)
def computeScaleUnitFromModelMatrix(self, axis, modelMat, camera, windowSize):
""" Compute the length of the screen projected vector axis unit transformed by the model matrix.
diff --git a/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml b/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml
index 4baf4121..7925f2cf 100644
--- a/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml
+++ b/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml
@@ -24,18 +24,22 @@ Entity {
// Update node meshing slider values when the gizmo has changed: translation, rotation, scale, type
transformGizmo.onGizmoChanged: {
+
+ var rotationEuler_cv = Qt.vector3d(rotation.x, rotation.y, rotation.z)
+ var rotation_gl = Transformations3DHelper.convertRotationFromCV2GL(rotationEuler_cv)
+
switch(type) {
case TransformGizmo.Type.TRANSLATION: {
_reconstruction.setAttribute(
root.currentMeshingNode.attribute("boundingBox.bboxTranslation"),
- JSON.stringify([translation.x, translation.y, translation.z])
+ JSON.stringify([translation.x, -translation.y, -translation.z])
)
break
}
case TransformGizmo.Type.ROTATION: {
_reconstruction.setAttribute(
root.currentMeshingNode.attribute("boundingBox.bboxRotation"),
- JSON.stringify([rotation.x, rotation.y, rotation.z])
+ JSON.stringify([rotation_gl.x, rotation_gl.y, rotation_gl.z])
)
break
}
@@ -50,8 +54,8 @@ Entity {
_reconstruction.setAttribute(
root.currentMeshingNode.attribute("boundingBox"),
JSON.stringify([
- [translation.x, translation.y, translation.z],
- [rotation.x, rotation.y, rotation.z],
+ [translation.x, -translation.y, -translation.z],
+ [rotation_gl.x, rotation_gl.y, rotation_gl.z],
[scale.x, scale.y, scale.z]
])
)
@@ -63,13 +67,41 @@ Entity {
// Translation values from node (vector3d because this is the type of QTransform.translation)
property var nodeTranslation : Qt.vector3d(
root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxTranslation.x").value : 0,
- root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxTranslation.y").value : 0,
- root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxTranslation.z").value : 0
+ root.currentMeshingNode ? -root.currentMeshingNode.attribute("boundingBox.bboxTranslation.y").value : 0,
+ root.currentMeshingNode ? -root.currentMeshingNode.attribute("boundingBox.bboxTranslation.z").value : 0
)
+
// Rotation values from node (3 separated values because QTransform stores Euler angles like this)
- property var nodeRotationX: root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.x").value : 0
- property var nodeRotationY: root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.y").value : 0
- property var nodeRotationZ: root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.z").value : 0
+ property var nodeRotationX: {
+ var rx = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.x").value : 0
+ var ry = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.y").value : 0
+ var rz = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.z").value : 0
+
+ var rotationEuler_cv = Qt.vector3d(rx, ry, rz)
+ var rotation_gl = Transformations3DHelper.convertRotationFromCV2GL(rotationEuler_cv)
+ return rotation_gl.x
+ }
+
+ property var nodeRotationY: {
+ var rx = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.x").value : 0
+ var ry = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.y").value : 0
+ var rz = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.z").value : 0
+
+ var rotationEuler_cv = Qt.vector3d(rx, ry, rz)
+ var rotation_gl = Transformations3DHelper.convertRotationFromCV2GL(rotationEuler_cv)
+ return rotation_gl.y
+ }
+
+ property var nodeRotationZ: {
+ var rx = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.x").value : 0
+ var ry = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.y").value : 0
+ var rz = root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxRotation.z").value : 0
+
+ var rotationEuler_cv = Qt.vector3d(rx, ry, rz)
+ var rotation_gl = Transformations3DHelper.convertRotationFromCV2GL(rotationEuler_cv)
+ return rotation_gl.z
+ }
+
// Scale values from node (vector3d because this is the type of QTransform.scale3D)
property var nodeScale: Qt.vector3d(
root.currentMeshingNode ? root.currentMeshingNode.attribute("boundingBox.bboxScale.x").value : 1,