Skip to content

Commit

Permalink
chain_FK_spline_02 and control_01: add support for leaf joints Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcampos committed Nov 15, 2023
1 parent d3daefe commit 24199ef
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,22 @@ def addObjects(self):

tagP = tweak_ctl
self.extratweak_ctl.append(tweak_ctl)
self.jnt_pos.append([tweak_ctl, i, None, False])
self.jnt_pos.append(
{
"obj": tweak_ctl,
"name": i,
"UniScale": False,
"leaf_joint": self.settings["leafJoints"],
}
)
else:
self.jnt_pos.append([div_cns, i])
self.jnt_pos.append(
{
"obj": div_cns,
"name": i,
"leaf_joint": self.settings["leafJoints"],
}
)

# =====================================================
# ATTRIBUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def addParameters(self):
self.pOverrideJointNb = self.addParam("overrideJntNb", "bool", False)
self.pJntNb = self.addParam("jntNb", "long", 3, 1)
self.pExtraTweak = self.addParam("extraTweak", "bool", False)
self.pleafJoints = self.addParam("leafJoints", "bool", False)

self.pUseIndex = self.addParam("useIndex", "bool", False)
self.pParentJointIndex = self.addParam(
Expand Down Expand Up @@ -133,6 +134,7 @@ def populate_componentControls(self):
self.populateCheck(self.settingsTab.extraTweak_checkBox,
"extraTweak")
self.settingsTab.jntNb_spinBox.setValue(self.root.attr("jntNb").get())
self.populateCheck(self.settingsTab.leafJoints_checkBox, "leafJoints")

def create_componentLayout(self):

Expand Down Expand Up @@ -173,6 +175,13 @@ def create_componentConnections(self):
partial(self.updateCheck,
self.settingsTab.extraTweak_checkBox,
"extraTweak"))
self.settingsTab.leafJoints_checkBox.stateChanged.connect(
partial(
self.updateCheck,
self.settingsTab.leafJoints_checkBox,
"leafJoints",
)
)

def dockCloseEventTriggered(self):
pyqt.deleteInstances(self, MayaQDockWidget)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(294, 211)
Form.resize(525, 438)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.groupBox = QtWidgets.QGroupBox(Form)
Expand All @@ -30,6 +30,9 @@ def setupUi(self, Form):
self.extraTweak_checkBox.setText("Extra Tweaks")
self.extraTweak_checkBox.setObjectName("extraTweak_checkBox")
self.verticalLayout.addWidget(self.extraTweak_checkBox)
self.leafJoints_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.leafJoints_checkBox.setObjectName("leafJoints_checkBox")
self.verticalLayout.addWidget(self.leafJoints_checkBox)
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
self.groupBox_2 = QtWidgets.QGroupBox(Form)
Expand Down Expand Up @@ -60,6 +63,7 @@ def setupUi(self, Form):

def retranslateUi(self, Form):
Form.setWindowTitle(gqt.fakeTranslate("Form", "Form", None, -1))
self.leafJoints_checkBox.setText(gqt.fakeTranslate("Form", "Leaf Joints", None, -1))
self.groupBox_2.setTitle(gqt.fakeTranslate("Form", "Joint Options", None, -1))
self.jntNb_label.setText(gqt.fakeTranslate("Form", "Joints Number", None, -1))

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>294</width>
<height>211</height>
<width>525</width>
<height>438</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -50,6 +50,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="leafJoints_checkBox">
<property name="text">
<string>Leaf Joints</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ def addObjects(self):
self.jnt_pos.append([t, 0, None, self.settings["uniScale"]])
else:
self.jnt_pos.append(
[self.ctl, 0, None, self.settings["uniScale"]])
{
"obj": self.ctl,
"name": 0,
"guide_relative": "root",
"UniScale": self.settings["uniScale"],
"leaf_joint": self.settings["addLeafJoint"],
}
)

def addAttributes(self):
# Ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def addParameters(self):

self.pJoint = self.addParam("joint", "bool", False)
self.pLeafJoint = self.addParam("leafJoint", "bool", False)
self.pAddLeafJoint = self.addParam("addLeafJoint", "bool", False)
self.pJoint = self.addParam("uniScale", "bool", False)

for s in ["tx", "ty", "tz", "ro", "rx", "ry", "rz", "sx", "sy", "sz"]:
Expand Down Expand Up @@ -171,6 +172,7 @@ def populate_componentControls(self):
self.populateCheck(self.settingsTab.joint_checkBox, "joint")
self.enable_leaf_joint()
self.populateCheck(self.settingsTab.leafJoint_checkBox, "leafJoint")
self.populateCheck(self.settingsTab.addLeafJoint_checkBox, "addLeafJoint")
self.populateCheck(self.settingsTab.uniScale_checkBox, "uniScale")
self.populateCheck(self.settingsTab.neutralRotation_checkBox,
"neutralRotation")
Expand Down Expand Up @@ -234,6 +236,10 @@ def create_componentConnections(self):
partial(self.updateCheck,
self.settingsTab.leafJoint_checkBox,
"leafJoint"))
self.settingsTab.addLeafJoint_checkBox.stateChanged.connect(
partial(self.updateCheck,
self.settingsTab.addLeafJoint_checkBox,
"addLeafJoint"))
self.settingsTab.uniScale_checkBox.stateChanged.connect(
partial(self.updateCheck,
self.settingsTab.uniScale_checkBox,
Expand Down Expand Up @@ -310,3 +316,4 @@ def dockCloseEventTriggered(self):
def enable_leaf_joint(self):
state = self.settingsTab.joint_checkBox.isChecked()
self.settingsTab.leafJoint_checkBox.setEnabled(state)
self.settingsTab.addLeafJoint_checkBox.setEnabled(state)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def setupUi(self, Form):
self.joint_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.joint_checkBox.setObjectName("joint_checkBox")
self.verticalLayout_4.addWidget(self.joint_checkBox)
self.addLeafJoint_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.addLeafJoint_checkBox.setEnabled(False)
self.addLeafJoint_checkBox.setObjectName("addLeafJoint_checkBox")
self.verticalLayout_4.addWidget(self.addLeafJoint_checkBox)
self.leafJoint_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.leafJoint_checkBox.setEnabled(False)
self.leafJoint_checkBox.setObjectName("leafJoint_checkBox")
Expand Down Expand Up @@ -200,8 +204,10 @@ def setupUi(self, Form):
def retranslateUi(self, Form):
Form.setWindowTitle(gqt.fakeTranslate("Form", "Form", None, -1))
self.joint_checkBox.setText(gqt.fakeTranslate("Form", "Joint", None, -1))
self.addLeafJoint_checkBox.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>When &quot;<span style=\" font-weight:600;\">Add Leaf Joint</span>&quot; is checked, the component will add an extra joint as a leaf joint. So we will have 2 joints. One to connect the joint structure the other to drive the skinning and allow non uniform scaling in Game Engine workflows</p><p>This is not the same as marking the control &quot;<span style=\" font-weight:600;\">is Leaf Joint</span>&quot; . </p></body></html>", None, -1))
self.addLeafJoint_checkBox.setText(gqt.fakeTranslate("Form", "Add Leaf Joint", None, -1))
self.leafJoint_checkBox.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>When &quot;<span style=\" font-weight:600;\">is Leaf Joint</span>&quot; is checked, the component will create only the joint without the controls</p><p>As the name indicates this option is meant to create leaf joints, but you can use it also to create &quot;branches&quot;</p><p>Leaf joint can be used as a deformation helpers or/and games pipelines</p></body></html>", None, -1))
self.leafJoint_checkBox.setText(gqt.fakeTranslate("Form", "is Leaf Joint (Beta)", None, -1))
self.leafJoint_checkBox.setText(gqt.fakeTranslate("Form", "is Leaf Joint", None, -1))
self.uniScale_checkBox.setText(gqt.fakeTranslate("Form", "Uniform Scale", None, -1))
self.neutralRotation_checkBox.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>If is active, it will align the control with world space</p></body></html>", None, -1))
self.neutralRotation_checkBox.setText(gqt.fakeTranslate("Form", "World Space Orientation Align", None, -1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>283</width>
<height>482</height>
<width>556</width>
<height>953</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -29,6 +29,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="addLeafJoint_checkBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When &amp;quot;&lt;span style=&quot; font-weight:600;&quot;&gt;Add Leaf Joint&lt;/span&gt;&amp;quot; is checked, the component will add an extra joint as a leaf joint. So we will have 2 joints. One to connect the joint structure the other to drive the skinning and allow non uniform scaling in Game Engine workflows&lt;/p&gt;&lt;p&gt;This is not the same as marking the control &amp;quot;&lt;span style=&quot; font-weight:600;&quot;&gt;is Leaf Joint&lt;/span&gt;&amp;quot; . &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Add Leaf Joint</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="leafJoint_checkBox">
<property name="enabled">
Expand All @@ -38,7 +51,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When &amp;quot;&lt;span style=&quot; font-weight:600;&quot;&gt;is Leaf Joint&lt;/span&gt;&amp;quot; is checked, the component will create only the joint without the controls&lt;/p&gt;&lt;p&gt;As the name indicates this option is meant to create leaf joints, but you can use it also to create &amp;quot;branches&amp;quot;&lt;/p&gt;&lt;p&gt;Leaf joint can be used as a deformation helpers or/and games pipelines&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>is Leaf Joint (Beta)</string>
<string>is Leaf Joint</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -473,12 +486,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>233</y>
<x>134</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>52</x>
<y>256</y>
<x>91</x>
<y>526</y>
</hint>
</hints>
</connection>
Expand All @@ -489,12 +502,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>233</y>
<x>134</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>89</x>
<y>279</y>
<x>128</x>
<y>567</y>
</hint>
</hints>
</connection>
Expand All @@ -505,12 +518,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>233</y>
<x>134</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>95</x>
<y>302</y>
<x>134</x>
<y>608</y>
</hint>
</hints>
</connection>
Expand All @@ -521,12 +534,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>228</y>
<x>352</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>178</x>
<y>251</y>
<x>352</x>
<y>526</y>
</hint>
</hints>
</connection>
Expand All @@ -537,12 +550,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>228</y>
<x>352</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>178</x>
<y>274</y>
<x>352</x>
<y>567</y>
</hint>
</hints>
</connection>
Expand All @@ -553,12 +566,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>228</y>
<x>352</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>178</x>
<y>297</y>
<x>352</x>
<y>608</y>
</hint>
</hints>
</connection>
Expand All @@ -569,12 +582,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>228</y>
<x>352</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>178</x>
<y>320</y>
<x>352</x>
<y>649</y>
</hint>
</hints>
</connection>
Expand All @@ -585,12 +598,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>261</x>
<y>233</y>
<x>516</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>261</x>
<y>256</y>
<x>516</x>
<y>526</y>
</hint>
</hints>
</connection>
Expand All @@ -601,12 +614,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>261</x>
<y>233</y>
<x>516</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>261</x>
<y>279</y>
<x>516</x>
<y>567</y>
</hint>
</hints>
</connection>
Expand All @@ -617,12 +630,12 @@
<slot>toggle()</slot>
<hints>
<hint type="sourcelabel">
<x>261</x>
<y>233</y>
<x>516</x>
<y>485</y>
</hint>
<hint type="destinationlabel">
<x>261</x>
<y>302</y>
<x>516</x>
<y>608</y>
</hint>
</hints>
</connection>
Expand Down

0 comments on commit 24199ef

Please sign in to comment.