Skip to content

Commit

Permalink
EPIC Arm and leg 02 enhancements: T reset pose for FK and IK controls C…
Browse files Browse the repository at this point in the history
…loses #359
  • Loading branch information
miquelcampos committed Jan 12, 2024
1 parent 378f447 commit 8714be8
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def addObjects(self):
"""Add all the objects needed to create the component."""

self.WIP = self.options["mode"]
self.up_axis = pm.upAxis(q=True, axis=True)

self.blade_normal = self.guide.blades["blade"].z * -1
self.blade_binormal = self.guide.blades["blade"].x
Expand Down Expand Up @@ -66,8 +67,26 @@ def addObjects(self):
"xz",
self.negate,
)

if self.settings["rest_T_Pose"]:
x = datatypes.Vector(1, 0, 0)
if self.negate:
z_dir = -1
else:
z_dir = 1

if self.up_axis == "y":
z = datatypes.Vector(0, z_dir, 0)
else:
z = datatypes.Vector(0, 0, z_dir)

t_npo = transform.getRotationFromAxis(x, z, "xz", False)
t_npo = transform.setMatrixPosition(t_npo, self.guide.apos[0])
else:
t_npo = t

self.fk0_npo = primitive.addTransform(
self.root, self.getName("fk0_npo"), t
self.root, self.getName("fk0_npo"), t_npo
)

self.fk0_ctl = self.addCtl(
Expand All @@ -89,8 +108,16 @@ def addObjects(self):
"xz",
self.negate,
)

if self.settings["rest_T_Pose"]:
t_npo = transform.setMatrixPosition(
transform.getTransform(self.fk0_ctl), self.guide.apos[1]
)
else:
t_npo = t

self.fk1_npo = primitive.addTransform(
self.fk0_ctl, self.getName("fk1_npo"), t
self.fk0_ctl, self.getName("fk1_npo"), t_npo
)

self.fk1_ctl = self.addCtl(
Expand Down Expand Up @@ -120,8 +147,17 @@ def addObjects(self):
"xz",
self.negate,
)

if self.settings["rest_T_Pose"]:
t_npo = transform.setMatrixPosition(
transform.getTransform(self.fk1_ctl), self.guide.apos[2]
)

else:
t_npo = t

self.fk2_npo = primitive.addTransform(
self.fk1_ctl, self.getName("fk2_npo"), t
self.fk1_ctl, self.getName("fk2_npo"), t_npo
)

self.fk2_ctl = self.addCtl(
Expand Down Expand Up @@ -211,11 +247,25 @@ def addObjects(self):

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

if self.settings["rest_T_Pose"]:
arm_length = vector.getDistance(
self.guide.pos["root"], self.guide.pos["elbow"]
) + vector.getDistance(
self.guide.pos["elbow"], self.guide.pos["wrist"]
)
if self.negate:
wrist_pos = self.guide.pos["root"] - datatypes.Vector(arm_length, 0, 0)
else:
wrist_pos = self.guide.pos["root"] + datatypes.Vector(arm_length, 0, 0)

else:
wrist_pos = self.guide.pos["wrist"]

self.ik_cns = primitive.addTransformFromPos(
self.root, self.getName("ik_cns"), self.guide.pos["wrist"]
self.root, self.getName("ik_cns"), wrist_pos
)

t = transform.getTransformFromPos(self.guide.pos["wrist"])
t = transform.getTransformFromPos(wrist_pos)
self.ikcns_ctl = self.addCtl(
self.ik_cns,
"ikcns_ctl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def addParameters(self):
self.pMirrorIK = self.addParam("mirrorIK", "bool", True)
self.pleafJoints = self.addParam("leafJoints", "bool", False)
self.pUseBlade = self.addParam("use_blade", "bool", True)
self.pTPoseRest = self.addParam("rest_T_Pose", "bool", False)

# Divisions
self.pDiv0 = self.addParam("div0", "long", 2, 0, None)
Expand Down Expand Up @@ -136,6 +137,7 @@ def postDraw(self):
for shp in self.blade.getShapes():
pm.connectAttr(self.root.use_blade, shp.attr("visibility"))


##########################################################
# Setting Page
##########################################################
Expand Down Expand Up @@ -188,6 +190,11 @@ def populate_componentControls(self):
self.tabs.insertTab(1, self.settingsTab, "Component Settings")

# populate component settings

self.populateCheck(
self.settingsTab.TPoseRest_checkBox, "rest_T_Pose"
)

self.settingsTab.ikfk_slider.setValue(
int(self.root.attr("blend").get() * 100)
)
Expand Down Expand Up @@ -382,7 +389,6 @@ def create_componentConnections(self):
"pinrefarray",
)
)
self.settingsTab.pinRefArray_listWidget.installEventFilter(self)
self.mainSettingsTab.connector_comboBox.currentIndexChanged.connect(
partial(
self.updateConnector,
Expand All @@ -391,6 +397,16 @@ def create_componentConnections(self):
)
)

self.settingsTab.TPoseRest_checkBox.stateChanged.connect(
partial(
self.updateCheck,
self.settingsTab.TPoseRest_checkBox,
"rest_T_Pose",
)
)

self.settingsTab.pinRefArray_listWidget.installEventFilter(self)

def eventFilter(self, sender, event):
if event.type() == QtCore.QEvent.ChildRemoved:
if sender == self.settingsTab.ikRefArray_listWidget:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from mgear.core import pyqt
QtGui, QtCore, QtWidgets, wrapInstance = pyqt.qt_import()
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'C:/datawork/repo/mgear4/release/scripts/mgear/shifter_epic_components/EPIC_arm_02/settingsUI.ui'
#
# Created: Fri Jan 12 15:22:01 2024
# by: pyside2-uic running on PySide2 2.0.0~alpha0
#
# WARNING! All changes made in this file will be lost!

from PySide2 import QtCore, QtGui, QtWidgets

class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(268, 687)
Form.resize(364, 1028)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.groupBox = QtWidgets.QGroupBox(Form)
Expand Down Expand Up @@ -84,6 +92,9 @@ def setupUi(self, Form):
self.useBlade_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.useBlade_checkBox.setObjectName("useBlade_checkBox")
self.verticalLayout.addWidget(self.useBlade_checkBox)
self.TPoseRest_checkBox = QtWidgets.QCheckBox(self.groupBox)
self.TPoseRest_checkBox.setObjectName("TPoseRest_checkBox")
self.verticalLayout.addWidget(self.TPoseRest_checkBox)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.squashStretchProfile_pushButton = QtWidgets.QPushButton(self.groupBox)
Expand Down Expand Up @@ -201,35 +212,39 @@ def setupUi(self, Form):
QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):
Form.setWindowTitle(pyqt.fakeTranslate("Form", "Form", None, -1))
self.ikfk_label.setText(pyqt.fakeTranslate("Form", "FK/IK Blend", None, -1))
self.maxStretch_label.setText(pyqt.fakeTranslate("Form", "Max Stretch", None, -1))
self.divisions_label.setText(pyqt.fakeTranslate("Form", "Divisions", None, -1))
self.leafJoints_checkBox.setText(pyqt.fakeTranslate("Form", "Leaf Joints", None, -1))
self.ikTR_checkBox.setText(pyqt.fakeTranslate("Form", "IK separated Trans and Rot ctl", None, -1))
self.mirrorIK_checkBox.setToolTip(pyqt.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.mirrorIK_checkBox.setStatusTip(pyqt.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.mirrorIK_checkBox.setWhatsThis(pyqt.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.mirrorIK_checkBox.setText(pyqt.fakeTranslate("Form", "Mirror IK Ctl axis behaviour", None, -1))
self.mirrorMid_checkBox.setToolTip(pyqt.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(pyqt.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(pyqt.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.setText(pyqt.fakeTranslate("Form", "Mirror Mid Ctl and UPV axis behaviour", None, -1))
self.useBlade_checkBox.setToolTip(pyqt.fakeTranslate("Form", "<html><head/><body><p>If checked, the Rest pose for FK controls will be in T Pose</p></body></html>", None, -1))
self.useBlade_checkBox.setStatusTip(pyqt.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.useBlade_checkBox.setWhatsThis(pyqt.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.useBlade_checkBox.setText(pyqt.fakeTranslate("Form", "Use Wrist Blade", None, -1))
self.squashStretchProfile_pushButton.setText(pyqt.fakeTranslate("Form", "Squash and Stretch Profile", None, -1))
self.ikRefArray_groupBox.setTitle(pyqt.fakeTranslate("Form", "IK Reference Array", None, -1))
self.ikRefArray_copyRef_pushButton.setText(pyqt.fakeTranslate("Form", "Copy from UpV Ref", None, -1))
self.ikRefArrayAdd_pushButton.setText(pyqt.fakeTranslate("Form", "<<", None, -1))
self.ikRefArrayRemove_pushButton.setText(pyqt.fakeTranslate("Form", ">>", None, -1))
self.upvRefArray_groupBox.setTitle(pyqt.fakeTranslate("Form", "UpV Reference Array", None, -1))
self.upvRefArray_copyRef_pushButton.setText(pyqt.fakeTranslate("Form", "Copy from IK Ref", None, -1))
self.upvRefArrayAdd_pushButton.setText(pyqt.fakeTranslate("Form", "<<", None, -1))
self.upvRefArrayRemove_pushButton.setText(pyqt.fakeTranslate("Form", ">>", None, -1))
self.pinRefArray_groupBox.setTitle(pyqt.fakeTranslate("Form", "Pin Elbow Reference Array", None, -1))
self.pinRefArray_copyRef_pushButton.setText(pyqt.fakeTranslate("Form", "Copy from IK Ref", None, -1))
self.pinRefArrayAdd_pushButton.setText(pyqt.fakeTranslate("Form", "<<", None, -1))
self.pinRefArrayRemove_pushButton.setText(pyqt.fakeTranslate("Form", ">>", None, -1))
Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "Form", None, -1))
self.ikfk_label.setText(QtWidgets.QApplication.translate("Form", "FK/IK Blend", None, -1))
self.maxStretch_label.setText(QtWidgets.QApplication.translate("Form", "Max Stretch", None, -1))
self.divisions_label.setText(QtWidgets.QApplication.translate("Form", "Divisions", None, -1))
self.leafJoints_checkBox.setText(QtWidgets.QApplication.translate("Form", "Leaf Joints", None, -1))
self.ikTR_checkBox.setText(QtWidgets.QApplication.translate("Form", "IK separated Trans and Rot ctl", None, -1))
self.mirrorIK_checkBox.setToolTip(QtWidgets.QApplication.translate("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.mirrorIK_checkBox.setStatusTip(QtWidgets.QApplication.translate("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.mirrorIK_checkBox.setWhatsThis(QtWidgets.QApplication.translate("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.mirrorIK_checkBox.setText(QtWidgets.QApplication.translate("Form", "Mirror IK Ctl axis behaviour", None, -1))
self.mirrorMid_checkBox.setToolTip(QtWidgets.QApplication.translate("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(QtWidgets.QApplication.translate("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(QtWidgets.QApplication.translate("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.setText(QtWidgets.QApplication.translate("Form", "Mirror Mid Ctl and UPV axis behaviour", None, -1))
self.useBlade_checkBox.setToolTip(QtWidgets.QApplication.translate("Form", "<html><head/><body><p>If checked, the Rest pose for FK controls will be in T Pose</p></body></html>", None, -1))
self.useBlade_checkBox.setStatusTip(QtWidgets.QApplication.translate("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.useBlade_checkBox.setWhatsThis(QtWidgets.QApplication.translate("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.useBlade_checkBox.setText(QtWidgets.QApplication.translate("Form", "Use Wrist Blade", None, -1))
self.TPoseRest_checkBox.setToolTip(QtWidgets.QApplication.translate("Form", "<html><head/><body><p>If checked, the Rest pose for controls will be in T Pose</p></body></html>", None, -1))
self.TPoseRest_checkBox.setStatusTip(QtWidgets.QApplication.translate("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.TPoseRest_checkBox.setWhatsThis(QtWidgets.QApplication.translate("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.TPoseRest_checkBox.setText(QtWidgets.QApplication.translate("Form", "Rest T Pose", None, -1))
self.squashStretchProfile_pushButton.setText(QtWidgets.QApplication.translate("Form", "Squash and Stretch Profile", None, -1))
self.ikRefArray_groupBox.setTitle(QtWidgets.QApplication.translate("Form", "IK Reference Array", None, -1))
self.ikRefArray_copyRef_pushButton.setText(QtWidgets.QApplication.translate("Form", "Copy from UpV Ref", None, -1))
self.ikRefArrayAdd_pushButton.setText(QtWidgets.QApplication.translate("Form", "<<", None, -1))
self.ikRefArrayRemove_pushButton.setText(QtWidgets.QApplication.translate("Form", ">>", None, -1))
self.upvRefArray_groupBox.setTitle(QtWidgets.QApplication.translate("Form", "UpV Reference Array", None, -1))
self.upvRefArray_copyRef_pushButton.setText(QtWidgets.QApplication.translate("Form", "Copy from IK Ref", None, -1))
self.upvRefArrayAdd_pushButton.setText(QtWidgets.QApplication.translate("Form", "<<", None, -1))
self.upvRefArrayRemove_pushButton.setText(QtWidgets.QApplication.translate("Form", ">>", None, -1))
self.pinRefArray_groupBox.setTitle(QtWidgets.QApplication.translate("Form", "Pin Elbow Reference Array", None, -1))
self.pinRefArray_copyRef_pushButton.setText(QtWidgets.QApplication.translate("Form", "Copy from IK Ref", None, -1))
self.pinRefArrayAdd_pushButton.setText(QtWidgets.QApplication.translate("Form", "<<", None, -1))
self.pinRefArrayRemove_pushButton.setText(QtWidgets.QApplication.translate("Form", ">>", 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>268</width>
<height>687</height>
<width>364</width>
<height>1028</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -188,6 +188,22 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="TPoseRest_checkBox">
<property name="toolTip">
<string extracomment="This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour ">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, the Rest pose for controls will be in T Pose&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string extracomment="This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour ">This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour </string>
</property>
<property name="whatsThis">
<string>This option set the axis of the mid CTL (elbow) and the up vector control to move in a mirror behaviour </string>
</property>
<property name="text">
<string>Rest T Pose</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down
Loading

0 comments on commit 8714be8

Please sign in to comment.