Joint Mover Utilities

artv2.utilities.joint_mover_utilities

author:Jeremy Ernst
description:This module contains helper functions for dealing with joint movers and creating joint movers. The class JointMoverUtils, is a UI with methods to aid in joint mover creation, such as marking up joints with parameters that get used when auto-generating the mover controls.
class JointMoverUtils(parent=None)[source]

This class provides a user interface with methods to aid in joint mover file creation.

../../../_images/JointMoverUtils.png

Functions:

Markup Joints()

Marks joints up with attributes that will be used when the JointMover class builds the controls on top of the joints. These attributes tell the JointMover class which control shape to use, how big the control is, what the offset is, if the joint should aim at the child, and if the joint is a twist joint.

Create Preview Movers()

Creates joint mover controls for the selected joints using the markup data on the joints (such as control size, control shape, and control offset).

Delete Preview Movers()

Deletes the preview movers.

Note

Don’t leave preview movers in your scene!

Remove All Markups()

Removes two attributes which populate their enums at the time of markup: aimJoint and controlType. By removing these, you can then re-markup the joints, and only those two attributes will be added, with updated enums. For example, if a new control shape is added, that shape will not appear in the enum attribute until you remove and re-markup.
static remove_markups()[source]

Removes the aimJoint and controlType attributes from the joints so they can be re-added with updated information.

create_mover(shape_data, jnt, key='mover')[source]

Creates the joint mover control for the given joint, using the given file path for which shape to use.

Parameters:
  • shape_data (str list/dict) – The shape data that makes up the control shape (knots, points, etc)
  • jnt (PyNode) – The joint to create the mover for.
  • key (str) – Whether to create a global mover (key=”mover”) or an offset mover (key=”mover_offset”)
Returns:

Returns the created mover group and mover control nodes.

Return type:

[], PyNode

create_mover_containers(name)[source]

Creates containers for the various nodes that get created when building the joint mover. This includes an overall container for the entire asset, an overall container for this component, and then containers for the mover controls themselves and the utility nodes that get created when hooking up the joints to the offset movers.

Parameters:name (str) – The unique name of the component.
Returns:Returns the created PyNode containers.
create_movers_from_joints(name, joint_hierarchy_root)[source]

Given a joint hierarchy that has had the joints marked up, create joint mover controls for each joint based on those mark-up parameters.

Parameters:
  • name (str) – Unique name of the component.
  • joint_hierarchy_root – The top of the skeletal hierarchy that we want to create joint movers from.
Returns:

Returns a dictionary of PyNodes where the keys are the joint PyNodes, and the values of each are the mover nodes created for that joint.

drive_joints_with_movers(mover_data, name)[source]

Hook up the joints so that they are driven by the offset mover that was created from said joint.

Parameters:
  • mover_data – The dictionary of PyNodes that has the joint as the key, and the created movers as the value.
  • name – The unique name of the component.
drive_joints_with_offsets(mover, jnt, main_asset)[source]

Takes the given joint mover control and the given joint, and hooks them up so the mover drives the joint’s translation and rotation.

Parameters:
  • mover (PyNode) – Joint mover offset control transform.
  • jnt (PyNode) – The joint to drive translation and rotations on.
  • main_asset (PyNode) – The container to add the created utility nodes to.
get_enum_joints(current_joint, root)[source]

Create an enum string with all the joints in the component hierarchy excluding the given current joint.

Parameters:
  • current_joint – The current joint which is getting the enum attribute.
  • root – The root joint of the component hierarchy
Returns:

an enum string for Maya’s addAttr (“red:green:blue”)

mark_joint_movers(mover_data, name, prefix, suffix)[source]

Marks the joint mover controls with metadata attributes. For example, is the given node a mover control, or just a buffer group? What is the mover type? Which component does this mover belong to?

Parameters:
  • mover_data – The joint mover nodes (PyNodes) that have been created.
  • name (str) – The component’s unique name.
  • prefix (str) – The component’s prefix.
  • suffix (str) – The component’s suffix.
markup_joints(joints=None, root_joint=None)[source]

Finds joints in the file, and marks them up with attributes that will be used when building the joint mover controls. These attributes are things like: the control shape to build, the size of the control, the offset to apply to the control, whether the joint is a twist joint, etc.

Below, you will find a glossary of the attributes and what their intended use is.

Can Aim

Whether this joint should aim at another joint when aim mode is turned on.

Aim Joint

Which joint this joint should aim at when aim mode is turned on. (This is ignored if Can Aim is False)

Aim Axis

Which axis represents the aim axis. (This is ignored if Can Aim is False)

Invert Aim Axis

If the aim axis should be inverted. (If your aim axis is set to X, but needs to be -X, this would be True) (This is ignored if Can Aim is False)

Up Axis

The axis of the joint that is closes to the world up axis. (This is ignored if Can Aim is False)

Maintain Offset

This will probably not ever need to be used, but in the case of some special circumstance, this will create the aim constraint while maintaining offsets. (This is ignored if Can Aim is False)

Twist Joint

Whether the joint is to be setup as a twist joint. A twist joint gets no global mover control. Instead it gets an offset mover that is only unlocked along the length axis, and is automatically driven to keep equal spacing between the start joint and end joint (calf and foot for example).

Control Type

The shape that the joint mover control should have. This list is populated by the files located in /resources/control_shapes.

Control Size

The scale factor to create the control at. If you use the “Create Preview Movers” button in the markup tool, you can then set this value in order to see how the control will be built and at what size.

Control Offset X, Y, Z

When creating the control, the rotational offset to apply on creation.

../../../_images/joint_mover_markup_offset.gif
setup_cv_scaling(node)[source]

Creates a setup where the current CV positions of the given node are multiplied by a value, which results in changing its total size.

Parameters:node (PyNode) – The transform node of the control
Returns:A list of PyNodes that are the created multiplyDivide nodes.
Return type:[], PyNodes
setup_mover(jnt, shape_data, scale_factor, container)[source]

Creates a normal joint mover control setup for the given joint. Normal means that the joint receives a global mover and an offset mover with buffer groups above each.

Parameters:
  • jnt (PyNode) – The PyNode of the joint to create the setup.
  • shape_data (str list/dict) – The data that makes up the control shape (knots, points, etc)
  • scale_factor (float) – The amount to scale the control by.
  • container (PyNode) – The container (PyNode) to add the created nodes to.
Returns:

Returns a list of PyNodes where the first element is the joint PyNode, and the second element is a list of the created mover nodes.

Return type:

[], PyNode

setup_twist_mover(jnt, control_path, scale_factor, container)[source]

Creates a twist joint mover control setup for the given joint. A twist joint setup is no global mover, and instead, a group that is driven by constraints to keep the twist joint along the X axis of the parent. Every channel on the offset control except for TranslateX is locked as well, to keep the twist joint aligned properly.

Parameters:
  • jnt (PyNode) – The PyNode of the joint to create the setup.
  • control_path (str) – The path to the control shape file.
  • scale_factor (float) – The amount to scale the control by.
  • container (PyNode) – The container (PyNode) to add the created nodes to.
Returns:

Returns a list of PyNodes where the first element is the joint PyNode, and the second element is a list of the created mover nodes.

Return type:

[], PyNode

show_window()[source]

Show the JointMoverUtils tool.