Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Viewer3D] Input bounding box (Meshing) & manual transformation (SfMTransform) thanks to a new 3D Gizmo #978

Merged
merged 51 commits into from
Aug 24, 2020

Conversation

julien-hdev
Copy link
Contributor

@julien-hdev julien-hdev commented Jul 7, 2020

Description

  • Add a Transform Gizmo to control Qt3D entities inside the 3D Viewer (generic).
  • Add an input Bounding Box inside the Meshing node to customize the area to reconstruct.
  • Add a new transformation mode to SfMTransform using the Transform Gizmo.

Needs alicevision/AliceVision#846

Features list

  • 3D Gizmo
    • Basic visual entity
    • Picking interaction & object transformations
    • Mouse handling orientation
    • Display on top of everything
    • Improve performances
    • Attach the Gizmo directly inside an object (using a special container entity)
    • Adjust manipulator sensitivity
  • Bounding Box
    • New bounding box parameter in AliceVision
    • New bounding box parameter in Meshroom's Meshing node
    • Display BBox edges/faces
  • SfMTransform
    • New transformation mode (manual) + new manualTransform parameter in AliceVision
    • New transformation mode (manual) + new manualTransform parameter in Meshroom's SfMTransform node
  • Integrate Transform/BoundingBox input in the 3D Inspector

To do later: use BoundingBox struct instead of Hexah in AliceVision meshing process.

Transform Gizmo

TransformGizmo_Complete_01

Implementation remarks

The gizmo is entirely done with Qt3D in QML. To be able to get local transformations (and not global ones), we have to deal with matrix operations. Not all the methods/functions exist in QML, so we have to implement our own functions using PySide2 in Python.
The gizmo is made with meshes. Maybe it would be better to draw it on screen directly?

The controls are pretty similar to the Blender's gizmo ones. By the way, the visual is strongly inspired by the Blender 2.8+ gizmo.
It is quite user-friendly.

How to use

EntityWithGizmo

Inside Viewer3D.qml :

EntityWithGizmo {
    id: entityWithGizmoID
    sceneCameraController: cameraController // The id of the current DefaultCameraController
    frontLayerComponent: drawOnFront // The id of the Layer we want to draw on top of everything
    window: root // The id of the current FocusScope Item (acting as a window)

    // The entity
    Entity { components: [entityWithGizmoID.objectTransform, ...] } // The Transform of the Entity needs to be this attribute
}

Bounding Box

MeshingWithBBoxComparison

On the left, Meshing with default option. On the right, Meshing with the custom Bounding Box.

Implementation remarks

The Bounding Box is a simple Qt3D entity representing a box in the style of Blender. The transformations of this box are stored in the Meshing node. When we use the gizmo inside the 3D Viewer to adjust the box, the changes are sent to the Meshing node when we release the mouse button. Like this, we ensure data is stored in Python and not in QML. We can activate the use of the custom Bounding Box in the node and then adjust the parameters. In the 3D Inspector, on the right, we can show/hide the Bounding Box.

SfMTransform

To activate the gizmo, you must choose the manual mode inside method parameter. You can then adjust the parameters with the sliders and/or the gizmo.

Implementation remarks

When manual mode is set, the point cloud you see in the 3D Viewer is actually the input with a real-time Transform applied to it. Even when the node is computed, this is the transformed input which is displayed.
Fix #994

@natowi
Copy link
Member

natowi commented Jul 7, 2020

This will (partially) solve #616 & #617 & #744

@fabiencastan fabiencastan changed the title [ui] Viewer3D: add a Transform Gizmo Meshing: Add an input bounding box with a new 3D Gizmo Jul 17, 2020
@fabiencastan fabiencastan added this to the Meshroom 2020.1.0 milestone Jul 21, 2020
@julien-hdev julien-hdev changed the title Meshing: Add an input bounding box with a new 3D Gizmo [Viewer3D] Input bounding box (Meshing) & manual transformation (SfMTransform) thanks to a new 3D Gizmo Jul 29, 2020
@julien-hdev julien-hdev marked this pull request as ready for review July 30, 2020 09:54
- Visual entity is done
- Need to make it pickable and to apply changes
- Add Quaternions functions
- Add Matrices computation functions
- For now, transformations do not take well in count the orientation of the mouse but gizmo is functional.
- Use only one global FrameAction instead of having one per axis
- Translations are computed using the dot product between the mouse vector (picked position to current position) and the projected picked axis vector. Like this, the behaviour is a lot more natural and user-friendly.
- Scale is computed using the distance between the gizmo's center and the mouse. The scale unit (where nothing changes) is defined by the distance between the gizmo's center and the picked position.
- Rotation is the result angle of the mouse rotation around the gizmo's center. It is quite user-friendly.
- Special entity acting as an object container: we can add the entities we want to control with a gizmo inside it.
- Drawing the gizmo always on top of the object to make sure to see it every time.
- Right clicking on the gizmo allows to reset the specific transformation.
- Moving the mouse's dependent events inside the MouseHandler and removing the FrameAction.
- MouseHandler is only enabled when the gizmo is selected. There is no infinite loop waiting for an event.
- Apply the same control handling as the TransformGizmo.
- Moving transform operations from QML to Python to get access to more Qt functionalities and to make a better separation of logic/display.
- Now, we can set the transformation with a position vector, Euler angles and a scale vector.
- Checkbox in optional settings.
- Parameters in advanced settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SfMTransform: New manual mode based on 3D gizmo
3 participants