Skip to content

Commit

Permalink
Align ankle to world orientation if the checkbox is turned on.
Browse files Browse the repository at this point in the history
  • Loading branch information
joji2468ng committed Jan 22, 2024
1 parent 04392ab commit 4294af6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,33 +155,35 @@ def addObjects(self):

# IK Controlers -----------------------------------

self.ik_cns = primitive.addTransformFromPos(
self.root_ctl, self.getName("ik_cns"), self.guide.pos["ankle"]
# Define the wrist transform (wt)
if not self.settings["ikOri"]:
m = transform.getTransformLookingAt(self.guide.pos["ankle"],
self.guide.pos["eff"],
self.normal,
"z-x",
False)
else:
m = transform.getTransformFromPos(self.guide.pos["ankle"])

self.ik_cns = primitive.addTransform(
self.root_ctl, self.getName("ik_cns"), m
)

self.ikcns_ctl = self.addCtl(
self.ik_cns,
"ikcns_ctl",
transform.getTransformFromPos(self.guide.pos["ankle"]),
m,
self.color_ik,
"null",
w=self.size * 0.12,
tp=self.root_ctl,
)
attribute.setInvertMirror(self.ikcns_ctl, ["tx"])

m = transform.getTransformLookingAt(
self.guide.pos["ankle"],
self.guide.pos["eff"],
self.x_axis,
"zx",
False,
)

self.ik_ctl = self.addCtl(
self.ikcns_ctl,
"ik_ctl",
transform.getTransformFromPos(self.guide.pos["ankle"]),
m,
self.color_ik,
"cube",
w=self.size * 0.12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def addParameters(self):
self.pUpvRefArray = self.addParam("pinrefarray", "string", "")
self.pMaxStretch = self.addParam("maxstretch", "double", 1.5, 1, None)
self.pMirrorMid = self.addParam("mirrorMid", "bool", False)
self.pGuideOrientWrist = self.addParam("guideOrientWrist", "bool", False)
self.pIKOrient = self.addParam("ikOri", "bool", True)

# Divisions
self.pDiv0 = self.addParam("div0", "long", 2, 1, None)
Expand Down Expand Up @@ -162,6 +162,8 @@ def populate_componentControls(self):
)

self.populateCheck(self.settingsTab.mirrorMid_checkBox, "mirrorMid")
self.populateCheck(self.settingsTab.ikOri_checkBox, "ikOri")

self.settingsTab.div0_spinBox.setValue(self.root.attr("div0").get())
self.settingsTab.div1_spinBox.setValue(self.root.attr("div1").get())
ikRefArrayItems = self.root.attr("ikrefarray").get().split(",")
Expand Down Expand Up @@ -212,10 +214,10 @@ def create_componentConnections(self):
self.setProfile
)

self.settingsTab.guideOrientWrist_checkBox.stateChanged.connect(
self.settingsTab.ikOri_checkBox.stateChanged.connect(
partial(self.updateCheck,
self.settingsTab.guideOrientWrist_checkBox,
"guideOrientWrist"))
self.settingsTab.ikOri_checkBox,
"ikOri"))

self.settingsTab.mirrorMid_checkBox.stateChanged.connect(
partial(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def setupUi(self, Form):
self.div1_spinBox.setObjectName("div1_spinBox")
self.horizontalLayout.addWidget(self.div1_spinBox)
self.verticalLayout.addLayout(self.horizontalLayout)
self.guideOrientWrist_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.guideOrientWrist_checkBox.setObjectName("guideOrientWrist_checkBox")
self.verticalLayout.addWidget(self.guideOrientWrist_checkBox)
self.ikOri_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.ikOri_checkBox.setObjectName("ikOri_checkBox")
self.verticalLayout.addWidget(self.ikOri_checkBox)
self.mirrorMid_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.mirrorMid_checkBox.setObjectName("mirrorMid_checkBox")
self.verticalLayout.addWidget(self.mirrorMid_checkBox)
Expand Down Expand Up @@ -221,9 +221,9 @@ def retranslateUi(self, Form):
self.ikfk_label.setText(gqt.fakeTranslate("Form", "IK/FK Blend", None, -1))
self.maxStretch_label.setText(gqt.fakeTranslate("Form", "Max Stretch", None, -1))
self.divisions_label.setText(gqt.fakeTranslate("Form", "Divisions", None, -1))
self.guideOrientWrist_checkBox.setText(gqt.fakeTranslate("Form", "Align ankle to world orientation", None, -1))
self.guideOrientWrist_checkBox.setToolTip(gqt.fakeTranslate("Form", "This option aligns the ankle with either world oriantation or guide. NOTE: This option override Mirror IK ctl behaviour", None, -1))
self.guideOrientWrist_checkBox.setStatusTip(gqt.fakeTranslate("Form", "This option aligns the ankle with either world oriantation or guide", None, -1))
self.ikOri_checkBox.setText(gqt.fakeTranslate("Form", "Align ankle to world orientation", None, -1))
self.ikOri_checkBox.setToolTip(gqt.fakeTranslate("Form", "This option aligns the ankle with either world oriantation or guide. NOTE: This option override Mirror IK ctl behaviour", None, -1))
self.ikOri_checkBox.setStatusTip(gqt.fakeTranslate("Form", "This option aligns the ankle with either world oriantation or guide", None, -1))
self.mirrorMid_checkBox.setToolTip(gqt.fakeTranslate("Form", "This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour ", None, -1))
self.mirrorMid_checkBox.setStatusTip(gqt.fakeTranslate("Form", "This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour ", None, -1))
self.mirrorMid_checkBox.setWhatsThis(gqt.fakeTranslate("Form", "This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour ", None, -1))
Expand Down

0 comments on commit 4294af6

Please sign in to comment.