Skip to content

Commit

Permalink
[ui] Viewer3D: Use directional light & add light controller
Browse files Browse the repository at this point in the history
Use a single light entity instead of one per camera.
Use directional light instead of point light.
Add camera relative directional light controller.
  • Loading branch information
gregoire-dl authored and cbentejac committed Jul 4, 2024
1 parent 9b1b277 commit 49819dc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
6 changes: 6 additions & 0 deletions meshroom/ui/qml/Viewer3D/Inspector3D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ FloatingPane {
checked: Viewer3DSettings.displayOrigin
onClicked: Viewer3DSettings.displayOrigin = !Viewer3DSettings.displayOrigin
}
MaterialToolButton {
text: MaterialIcons.light_mode
ToolTip.text: "Display Light Controller"
checked: Viewer3DSettings.displayLightController
onClicked: Viewer3DSettings.displayLightController = !Viewer3DSettings.displayLightController
}
}
MaterialLabel {
text: MaterialIcons.grain
Expand Down
29 changes: 20 additions & 9 deletions meshroom/ui/qml/Viewer3D/Viewer3D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ FocusScope {
upVector: defaultCamUpVector
viewCenter: defaultCamViewCenter
aspectRatio: width/height

// Scene light, attached to the camera
Entity {
components: [
PointLight {
color: "white"
}
]
}
}

ViewpointCamera {
Expand All @@ -127,6 +118,15 @@ FocusScope {
camera.aspectRatio: width/height
}

Entity {
components: [
DirectionalLight{
color: "white"
worldDirection: Transformations3DHelper.getRotatedCameraViewVector(cameraSelector.camera.viewVector, cameraSelector.camera.upVector, directionalLightPane.lightPitchValue, directionalLightPane.lightYawValue).normalized()
}
]
}

TrackballGizmo {
beamRadius: 4.0/root.height
alpha: cameraController.moving ? 1.0 : 0.7
Expand Down Expand Up @@ -330,6 +330,17 @@ FocusScope {
}
}

// Directional light controller
DirectionalLightPane {
id: directionalLightPane
anchors {
bottom: parent.bottom
right: parent.right
margins: 2
}
visible: Viewer3DSettings.displayLightController
}

// Menu
Menu {
id: contextMenu
Expand Down
1 change: 1 addition & 0 deletions meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Item {
property bool displayGrid: true
property bool displayGizmo: true
property bool displayOrigin: false
property bool displayLightController: false
// Camera
property bool syncViewpointCamera: false
property bool syncWithPickedViewId: false // Sync active camera with picked view ID from sequence player if the setting is enabled
Expand Down
9 changes: 0 additions & 9 deletions meshroom/ui/qml/Viewer3D/ViewpointCamera.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ Entity {
nearPlane : 0.1
farPlane : 10000.0
viewCenter: Qt.vector3d(0.0, 0.0, -1.0)

// Scene light, attached to the camera
Entity {
components: [
PointLight {
color: "white"
}
]
}
}

components: [
Expand Down

0 comments on commit 49819dc

Please sign in to comment.