| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- // Copyright (C) 2021 The Qt Company Ltd.
- // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
- import QtQuick 2.15
- import QtQuick.Layouts 1.15
- import HelperWidgets 2.0
- import StudioTheme 1.0 as StudioTheme
- Column {
- width: parent.width
- Section {
- width: parent.width
- caption: qsTr("Dynamic Rigid Body")
- SectionLayout {
- id: baseSectionLayout
- property bool isDefaultDensityMode: massModeComboBox.currentIndex === 0
- property bool isCustomDensityMode: massModeComboBox.currentIndex === 1
- property bool isMassMode: massModeComboBox.currentIndex === 2
- property bool isMassAndInertiaTensorMode: massModeComboBox.currentIndex === 3
- property bool isMassAndInertiaMatrixMode: massModeComboBox.currentIndex === 4
- PropertyLabel {
- text: "Mass Mode"
- tooltip: "Describes how mass and inertia are calculated for this body."
- }
- SecondColumnLayout {
- ComboBox {
- id: massModeComboBox
- scope: "DynamicRigidBody"
- model: ["DefaultDensity", "CustomDensity", "Mass", "MassAndInertiaTensor", "MassAndInertiaMatrix"]
- backendValue: backendValues.massMode
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: baseSectionLayout.isMassAndInertiaMatrixMode || baseSectionLayout.isMassAndInertiaTensorMode
- }
- SecondColumnLayout {
- visible: baseSectionLayout.isMassAndInertiaMatrixMode || baseSectionLayout.isMassAndInertiaTensorMode
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- Label {
- text: qsTr("Tensor and Matrix modes require QML code.")
- Layout.fillWidth: true
- Layout.preferredWidth: StudioTheme.Values.singleControlColumnWidth
- Layout.minimumWidth: StudioTheme.Values.singleControlColumnWidth
- Layout.maximumWidth: StudioTheme.Values.singleControlColumnWidth
- }
- }
- PropertyLabel {
- visible: !baseSectionLayout.isDefaultDensityMode && !baseSectionLayout.isCustomDensityMode
- text: "Mass"
- tooltip: "The mass of the body."
- }
- SecondColumnLayout {
- visible: !baseSectionLayout.isDefaultDensityMode && !baseSectionLayout.isCustomDensityMode
- SpinBox {
- minimumValue: 0
- maximumValue: 9999999
- decimals: 2
- stepSize: 0.01
- backendValue: backendValues.mass
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: baseSectionLayout.isCustomDensityMode
- text: "Density"
- tooltip: "The density of the body."
- }
- SecondColumnLayout {
- visible: baseSectionLayout.isCustomDensityMode
- SpinBox {
- minimumValue: -1
- maximumValue: 9999999
- decimals: 2
- stepSize: 0.01
- backendValue: backendValues.density
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- text: "Enable Gravity"
- tooltip: "Sets if the body affected by gravity."
- }
- SecondColumnLayout {
- CheckBox {
- text: backendValues.gravityEnabled.valueToString
- backendValue: backendValues.gravityEnabled
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- text: "Linear Axis Lock"
- tooltip: "Lock the linear axis of the body."
- }
- SecondColumnLayout {
- ActionIndicator {
- id: linearAxisLockController
- icon.color: extFuncLogic.color
- icon.text: extFuncLogic.glyph
- onClicked: extFuncLogic.show()
- forceVisible: extFuncLogic.menuVisible
- visible: true
- property var enableLockX: { "value": false, "isInModel": false}
- property var enableLockY: { "value": false, "isInModel": false}
- property var enableLockZ: { "value": false, "isInModel": false}
- property variant backendValue: backendValues.linearAxisLock
- property variant valueFromBackend: backendValue === undefined ? 0 : backendValue.value
- property bool blockLocks: false
- onBackendValueChanged: evaluateLocks()
- onValueFromBackendChanged: evaluateLocks()
- Connections {
- target: modelNodeBackend
- function onSelectionChanged() {
- evaluateLevels()
- }
- }
- Component.onCompleted: evaluateLocks()
- function evaluateLocks() {
- blockLocks = true
- enableLockX = { "value": valueFromBackend & 1, "isInModel": false}
- enableLockY = { "value": valueFromBackend & 2, "isInModel": false}
- enableLockZ = { "value": valueFromBackend & 4, "isInModel": false}
- blockLocks = false
- }
- function composeExpressionString() {
- if (blockLocks)
- return
- let expressionStr = "";
- if (enableLockX.value || enableLockY.value || enableLockY.value) {
- if (enableLockX.value)
- expressionStr += " | DynamicRigidBody.LockX";
- if (enableLockY.value)
- expressionStr += " | DynamicRigidBody.LockY";
- if (enableLockZ.value)
- expressionStr += " | DynamicRigidBody.LockZ";
- expressionStr = expressionStr.substring(3);
- backendValue.expression = expressionStr
- } else {
- expressionStr = "DynamicRigidBody.None";
- backendValue.expression = expressionStr
- }
- }
- ExtendedFunctionLogic {
- id: extFuncLogic
- backendValue: backendValues.linearAxisLock
- onReseted: {
- linearAxisLockController.enableLockX = { "value": false, "isInModel": false}
- linearAxisLockController.enableLockY = { "value": false, "isInModel": false}
- linearAxisLockController.enableLockZ = { "value": false, "isInModel": false}
- linearAxisLockController.evaluateLocks()
- }
- }
- }
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock X")
- backendValue: linearAxisLockController.enableLockX
- actionIndicatorVisible: false
- onCheckedChanged: linearAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock Y")
- backendValue: linearAxisLockController.enableLockY
- actionIndicatorVisible: false
- onCheckedChanged: linearAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock Z")
- backendValue: linearAxisLockController.enableLockZ
- actionIndicatorVisible: false
- onCheckedChanged: linearAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- text: "Angular Axis Lock"
- tooltip: "Lock the angular axis of the body."
- }
- SecondColumnLayout {
- ActionIndicator {
- id: angularAxisLockController
- icon.color: extFuncLogicAngular.color
- icon.text: extFuncLogicAngular.glyph
- onClicked: extFuncLogicAngular.show()
- forceVisible: extFuncLogic.menuVisible
- visible: true
- property var enableLockX: { "value": false, "isInModel": false}
- property var enableLockY: { "value": false, "isInModel": false}
- property var enableLockZ: { "value": false, "isInModel": false}
- property variant backendValue: backendValues.angularAxisLock
- property variant valueFromBackend: backendValue === undefined ? 0 : backendValue.value
- property bool blockLocks: false
- onBackendValueChanged: evaluateLocks()
- onValueFromBackendChanged: evaluateLocks()
- Connections {
- target: modelNodeBackend
- function onSelectionChanged() {
- evaluateLevels()
- }
- }
- Component.onCompleted: evaluateLocks()
- function evaluateLocks() {
- blockLocks = true
- enableLockX = { "value": valueFromBackend & 1, "isInModel": false}
- enableLockY = { "value": valueFromBackend & 2, "isInModel": false}
- enableLockZ = { "value": valueFromBackend & 4, "isInModel": false}
- blockLocks = false
- }
- function composeExpressionString() {
- if (blockLocks)
- return
- let expressionStr = "";
- if (enableLockX.value || enableLockY.value || enableLockY.value) {
- if (enableLockX.value)
- expressionStr += " | DynamicRigidBody.LockX";
- if (enableLockY.value)
- expressionStr += " | DynamicRigidBody.LockY";
- if (enableLockZ.value)
- expressionStr += " | DynamicRigidBody.LockZ";
- expressionStr = expressionStr.substring(3);
- backendValue.expression = expressionStr
- } else {
- expressionStr = "DynamicRigidBody.None";
- backendValue.expression = expressionStr
- }
- }
- ExtendedFunctionLogic {
- id: extFuncLogicAngular
- backendValue: backendValues.angularAxisLock
- onReseted: {
- angularAxisLockController.enableLockX = { "value": false, "isInModel": false}
- angularAxisLockController.enableLockY = { "value": false, "isInModel": false}
- angularAxisLockController.enableLockZ = { "value": false, "isInModel": false}
- angularAxisLockController.evaluateLocks()
- }
- }
- }
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock X")
- backendValue: angularAxisLockController.enableLockX
- actionIndicatorVisible: false
- onCheckedChanged: angularAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock Y")
- backendValue: angularAxisLockController.enableLockY
- actionIndicatorVisible: false
- onCheckedChanged: angularAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- // spacer
- }
- SecondColumnLayout {
- Item {
- // spacer for the always hiden action indicator
- width: StudioTheme.Values.actionIndicatorWidth
- }
- CheckBox {
- text: qsTr("Lock Z")
- backendValue: angularAxisLockController.enableLockZ
- actionIndicatorVisible: false
- onCheckedChanged: angularAxisLockController.composeExpressionString()
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- text: "Is Kinematic"
- tooltip: "Kinematic objects are not influenced by external forces and can be seen as an object of infinite mass."
- }
- SecondColumnLayout {
- CheckBox {
- id: isKinematicCheckBox
- text: backendValues.isKinematic.valueToString
- backendValue: backendValues.isKinematic
- implicitWidth: StudioTheme.Values.twoControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- text: "Kinematic Position"
- tooltip: "The position of the kinematic object."
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPosition_x
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "X"
- color: StudioTheme.Values.theme3DAxisXColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPosition_y
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Y"
- color: StudioTheme.Values.theme3DAxisYColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPosition_z
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Z"
- color: StudioTheme.Values.theme3DAxisZColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- text: "Kinematic Rotation"
- tooltip: "The rotation of the kinematic object."
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicEulerRotation_x
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "X"
- color: StudioTheme.Values.theme3DAxisXColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicEulerRotation_y
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Y"
- color: StudioTheme.Values.theme3DAxisYColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicEulerRotation_z
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Z"
- color: StudioTheme.Values.theme3DAxisZColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- text: "Kinematic Pivot"
- tooltip: "The pivot point of the kinematic object."
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPivot_x
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "X"
- color: StudioTheme.Values.theme3DAxisXColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPivot_y
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Y"
- color: StudioTheme.Values.theme3DAxisYColor
- }
- ExpandingSpacer {}
- }
- PropertyLabel {
- visible: isKinematicCheckBox.checked
- }
- SecondColumnLayout {
- visible: isKinematicCheckBox.checked
- SpinBox {
- implicitWidth: StudioTheme.Values.singleControlColumnWidth
- + StudioTheme.Values.actionIndicatorWidth
- minimumValue: -9999999
- maximumValue: 9999999
- decimals: 2
- backendValue: backendValues.kinematicPivot_z
- }
- Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
- ControlLabel {
- text: "Z"
- color: StudioTheme.Values.theme3DAxisZColor
- }
- ExpandingSpacer {}
- }
- }
- }
- }
- // Other Properties Not covered by the UI
- // QVector3D inertiaTensor
- // QVector3D centerOfMassPosition
- // QQuaternion centerOfMassRotation
- // List<float> inertiaMatrix (9 floats for a Mat3x3)
|