mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[Panorama Viewer] Add pitch and roll properties
This commit is contained in:
parent
6799598933
commit
b6be11f39f
1 changed files with 27 additions and 60 deletions
|
@ -55,8 +55,8 @@ AliceVision.PanoramaViewer {
|
||||||
property var lastY: 0
|
property var lastY: 0
|
||||||
|
|
||||||
property double yaw: 0;
|
property double yaw: 0;
|
||||||
property int pitch: 0;
|
property double pitch: 0;
|
||||||
property int roll: 0;
|
property double roll: 0;
|
||||||
|
|
||||||
property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node
|
property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node
|
||||||
|
|
||||||
|
@ -65,14 +65,6 @@ AliceVision.PanoramaViewer {
|
||||||
property int pitchNode: activeNode.attribute("manualTransform.manualRotation.x").value;
|
property int pitchNode: activeNode.attribute("manualTransform.manualRotation.x").value;
|
||||||
property int rollNode: activeNode.attribute("manualTransform.manualRotation.z").value;
|
property int rollNode: activeNode.attribute("manualTransform.manualRotation.z").value;
|
||||||
|
|
||||||
function updateRotation(){
|
|
||||||
if (!isRotating) {
|
|
||||||
// for (var i = 0; i < repeater.model; i++) {
|
|
||||||
// repeater.itemAt(i).item.surface.setEulerAngles(yawNode, pitchNode, rollNode);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toDegrees(radians){
|
function toDegrees(radians){
|
||||||
return radians * (180/Math.PI)
|
return radians * (180/Math.PI)
|
||||||
}
|
}
|
||||||
|
@ -83,29 +75,26 @@ AliceVision.PanoramaViewer {
|
||||||
|
|
||||||
function fmod(a,b) { return Number((a - (Math.floor(a / b) * b)).toPrecision(8)); }
|
function fmod(a,b) { return Number((a - (Math.floor(a / b) * b)).toPrecision(8)); }
|
||||||
|
|
||||||
function limitAngle(angleDegrees){
|
// Limit angle between -180 and 180
|
||||||
var angleRadians = toRadians(angleDegrees)
|
function limitAngle(angle){
|
||||||
var power = Math.trunc(angleRadians / Math.PI);
|
if (angle > 180) angle = -180.0 + (angle - 180.0);
|
||||||
|
if (angle < -180) angle = 180.0 - (Math.abs(angle) - 180);
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
console.warn(power)
|
function limitPitch(angle)
|
||||||
|
{
|
||||||
angleRadians = fmod(angleRadians, Math.PI) * Math.pow(-1, power);
|
return (angle > 180 || angle < -180) ? root.pitch : angle;
|
||||||
// Radians to Degrees
|
|
||||||
var limitedAngleDegrees = toDegrees(angleRadians);
|
|
||||||
if (power % 2 != 0) limitedAngleDegrees = -180.0 - limitedAngleDegrees;
|
|
||||||
|
|
||||||
return limitedAngleDegrees;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onYawNodeChanged: {
|
onYawNodeChanged: {
|
||||||
//console.warn("[QML] Yaw node changed")
|
root.yaw = yawNode;
|
||||||
updateRotation()
|
|
||||||
}
|
}
|
||||||
onPitchNodeChanged: {
|
onPitchNodeChanged: {
|
||||||
updateRotation()
|
root.pitch = pitchNode;
|
||||||
}
|
}
|
||||||
onRollNodeChanged: {
|
onRollNodeChanged: {
|
||||||
updateRotation()
|
root.roll = rollNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -148,26 +137,19 @@ AliceVision.PanoramaViewer {
|
||||||
lastX = mouse.x;
|
lastX = mouse.x;
|
||||||
lastY = mouse.y;
|
lastY = mouse.y;
|
||||||
|
|
||||||
|
// Update Euler Angles
|
||||||
|
if (mouse.modifiers & Qt.AltModifier) {
|
||||||
|
root.roll = limitAngle(root.roll + toDegrees((xoffset / width) * mouseMultiplier))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
root.yaw = limitAngle(root.yaw + toDegrees((xoffset / width) * mouseMultiplier))
|
||||||
|
root.pitch = limitPitch(root.pitch + toDegrees(-(yoffset / height) * mouseMultiplier))
|
||||||
|
}
|
||||||
|
|
||||||
//Rotate roll if alt is pressed
|
// Update SfmTransform Node attribute TODO Undo Group Python
|
||||||
// if(mouse.modifiers & Qt.AltModifier){
|
_reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.x"), Math.round(root.pitch));
|
||||||
// for (var k = 0; k < repeater.model; k++) {
|
|
||||||
// repeater.itemAt(k).item.surface.incrementEulerAngles(0, 0, (xoffset / width) * mouseMultiplier);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//Default rotate
|
|
||||||
// else{
|
|
||||||
// for (var l = 0; l < repeater.model; l++) {
|
|
||||||
// repeater.itemAt(l).item.surface.incrementEulerAngles((xoffset / width) * mouseMultiplier, -(yoffset / height) * mouseMultiplier, 0);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
root.yaw += toDegrees((xoffset / width) * mouseMultiplier)
|
|
||||||
console.warn("Root yaw " + root.yaw)
|
|
||||||
if (root.yaw > 180) root.yaw = -180.0 + (root.yaw - 180.0);
|
|
||||||
if (root.yaw < -180) root.yaw = 180.0 - (Math.abs(root.yaw) - 180);
|
|
||||||
_reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.y"), Math.round(root.yaw));
|
_reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.y"), Math.round(root.yaw));
|
||||||
|
_reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.z"), Math.round(root.roll));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,23 +160,6 @@ AliceVision.PanoramaViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: {
|
||||||
if (isRotating)
|
|
||||||
{
|
|
||||||
// Update Euler angles
|
|
||||||
var activeNode = _reconstruction.activeNodes.get('SfMTransform').node;
|
|
||||||
|
|
||||||
// root.pitch = repeater.itemAt(0).item.surface.getPitch();
|
|
||||||
// root.yaw = repeater.itemAt(0).item.surface.getYaw();
|
|
||||||
// root.roll = repeater.itemAt(0).item.surface.getRoll();
|
|
||||||
|
|
||||||
// console.warn("Set QML yaw to " + root.yaw)
|
|
||||||
|
|
||||||
// _reconstruction.setAttribute(
|
|
||||||
// activeNode.attribute("manualTransform.manualRotation"),
|
|
||||||
// JSON.stringify([root.pitch, root.yaw, root.roll])
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
|
|
||||||
isRotating = false;
|
isRotating = false;
|
||||||
lastX = 0
|
lastX = 0
|
||||||
lastY = 0
|
lastY = 0
|
||||||
|
@ -290,7 +255,9 @@ AliceVision.PanoramaViewer {
|
||||||
'surface.viewerType': AliceVision.Surface.EViewerType.PANORAMA,
|
'surface.viewerType': AliceVision.Surface.EViewerType.PANORAMA,
|
||||||
'viewerTypeString': 'panorama',
|
'viewerTypeString': 'panorama',
|
||||||
'surface.subdivisions': Qt.binding(function() { return subdivisionsPano; }),
|
'surface.subdivisions': Qt.binding(function() { return subdivisionsPano; }),
|
||||||
|
'surface.pitch': Qt.binding(function() { return root.pitch; }),
|
||||||
'surface.yaw': Qt.binding(function() { return root.yaw; }),
|
'surface.yaw': Qt.binding(function() { return root.yaw; }),
|
||||||
|
'surface.roll': Qt.binding(function() { return root.roll; }),
|
||||||
'index' : index,
|
'index' : index,
|
||||||
'idView': Qt.binding(function() { return cId; }),
|
'idView': Qt.binding(function() { return cId; }),
|
||||||
'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }),
|
'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue