Skip to content

Commit

Permalink
Shifter components: expose joint name description in settings. close #…
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcampos committed Mar 23, 2022
1 parent 0f8d004 commit 28ed5d6
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,22 +551,22 @@ def addObjects(self):
jd_names = ast.literal_eval(
self.settings["jointNamesDescription_custom"]
)
upperarm = jd_names[0]
lowerarm = jd_names[1]
upperarm_twist_ = jd_names[2]
lowerarm_twist_ = jd_names[3]
hand = jd_names[4]
jdn_upperarm = jd_names[0]
jdn_lowerarm = jd_names[1]
jdn_upperarm_twist = jd_names[2]
jdn_lowerarm_twist = jd_names[3]
jdn_hand = jd_names[4]

# setting the joints
if i == 0:
self.jnt_pos.append([driver, upperarm])
self.jnt_pos.append([driver, jdn_upperarm])
current_parent = "root"
twist_name = upperarm_twist_
twist_name = jdn_upperarm_twist
twist_idx = 1
increment = 1
elif i == self.settings["div0"] + 1:
self.jnt_pos.append([driver, lowerarm, current_parent])
twist_name = lowerarm_twist_
self.jnt_pos.append([driver, jdn_lowerarm, current_parent])
twist_name = jdn_lowerarm_twist
current_parent = "elbow"
twist_idx = self.settings["div1"]
increment = -1
Expand All @@ -584,7 +584,7 @@ def addObjects(self):
eff_loc = self.eff_jnt_off
else:
eff_loc = self.eff_loc
self.jnt_pos.append([eff_loc, hand, current_parent])
self.jnt_pos.append([eff_loc, jdn_hand, current_parent])

# match IK FK references
self.match_fk0_off = self.add_match_ref(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pymel.core as pm
import ast
from pymel.core import datatypes

from mgear.shifter import component
Expand All @@ -16,6 +17,12 @@ class Component(component.Main):
def addObjects(self):
"""Add all the objects needed to create the component."""

# joint Description Names
jd_names = ast.literal_eval(
self.settings["jointNamesDescription_custom"]
)
jdn_ball = jd_names[0]

self.up_axis = pm.upAxis(q=True, axis=True)

self.div_count = len(self.guide.apos) - 5
Expand Down Expand Up @@ -215,9 +222,9 @@ def addObjects(self):
self.previousTag = fk_ctl
attribute.setKeyableAttributes(fk_ctl)
if i:
name = "ball" + str(i)
name = jdn_ball + str(i)
else:
name = "ball"
name = jdn_ball
self.jnt_pos.append([fk_ctl, name])

parent = fk_ctl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Guide(guide.ComponentGuide):
"leg_3jnt_01",
]

joint_names_description = ["ball"]

def postInit(self):
"""Initialize the position for the guide"""
self.save_transform = ["root", "#_loc", "heel", "outpivot", "inpivot"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Component Hydraulic 01 module"""

import ast
from mgear.shifter import component
from mgear.core import attribute, transform, primitive, applyop
from mgear.core import attribute, transform, primitive, applyop, string


##########################################################
Expand All @@ -18,6 +18,12 @@ class Component(component.Main):
def addObjects(self):
"""Add all the objects needed to create the component."""

# joint Description Names
jd_names = ast.literal_eval(
self.settings["jointNamesDescription_custom"]
)
jdn_section = jd_names[0]

self.normal = self.guide.blades["blade"].z * -1
self.binormal = self.guide.blades["blade"].x

Expand Down Expand Up @@ -68,7 +74,9 @@ def addObjects(self):
self.getName("div%s_loc" % i))

self.div_cns.append(div_cns)
self.jnt_pos.append([div_cns, i])
self.jnt_pos.append(
[div_cns, string.replaceSharpWithPadding(jdn_section, i + 1)]
)

# =====================================================
# ATTRIBUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Guide(guide.ComponentGuide):
email = EMAIL
version = VERSION

joint_names_description = ["section_##"]

def postInit(self):
"""Initialize the position for the guide"""
self.save_transform = ["root", "tip"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pymel.core as pm
import ast
from pymel.core import datatypes

from mgear.shifter import component

from mgear.core import node, fcurve, applyop, vector, icon
from mgear.core import attribute, transform, primitive
from mgear.core import attribute, transform, primitive, string

#############################################
# COMPONENT
Expand Down Expand Up @@ -205,18 +206,6 @@ def addObjects(self):
)
attribute.setInvertMirror(self.ikcns_ctl, ["tx"])

# m = transform.getTransformLookingAt(self.guide.pos["ankle"],
# self.guide.pos["eff"],
# self.x_axis,
# "zx",
# False)
# if self.settings["FK_rest_T_Pose"]:
# t_ik = transform.getTransformLookingAt(self.guide.pos["ankle"],
# self.guide.pos["eff"],
# self.normal * -1,
# "zx",
# False)
# else:
t_ik = transform.getTransformFromPos(self.guide.pos["ankle"])

self.ik_ctl = self.addCtl(
Expand Down Expand Up @@ -446,24 +435,34 @@ def addObjects(self):
else:
driver = div_cns

# joint Description Name
jd_names = ast.literal_eval(
self.settings["jointNamesDescription_custom"]
)
jdn_thigh = jd_names[0]
jdn_calf = jd_names[1]
jdn_thigh_twist = jd_names[2]
jdn_calf_twist = jd_names[3]
jdn_foot = jd_names[4]

# setting the joints
if i == 0:
self.jnt_pos.append([driver, "thigh"])
self.jnt_pos.append([driver, jdn_thigh])
current_parent = "root"
twist_name = "thigh_twist_"
twist_name = jdn_thigh_twist
twist_idx = 1
increment = 1
elif i == self.settings["div0"] + 1:
self.jnt_pos.append([driver, "calf", current_parent])
twist_name = "calf_twist_"
self.jnt_pos.append([driver, jdn_calf, current_parent])
twist_name = jdn_calf_twist
current_parent = "knee"
twist_idx = self.settings["div1"]
increment = -1
else:
self.jnt_pos.append(
[
driver,
twist_name + str(twist_idx).zfill(2),
string.replaceSharpWithPadding(twist_name, twist_idx),
current_parent,
]
)
Expand All @@ -480,7 +479,7 @@ def addObjects(self):
)
if self.up_axis == "z":
self.end_jnt_off.rz.set(-90)
self.jnt_pos.append([self.end_jnt_off, "foot", current_parent])
self.jnt_pos.append([self.end_jnt_off, jdn_foot, current_parent])

# match IK FK references
self.match_fk0_off = self.add_match_ref(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class Guide(guide.ComponentGuide):
email = EMAIL
version = VERSION

joint_names_description = [
"thigh",
"calf",
"thigh_twist_##",
"calf_twist_##",
"foot",
]

def postInit(self):
"""Initialize the position for the guide"""
self.save_transform = ["root", "knee", "ankle", "eff"]
Expand Down

0 comments on commit 28ed5d6

Please sign in to comment.