PDA

View Full Version : A question for real-time Transforming Using Expressions.


Binxx
11-07-2012, 12:33 PM
Howdy guys, I haven't posted in a while, however I'm in a hitch and i was wondering if you guys could help me out or point me to the right direction to figure out this funky problem. The issue is that I'm working on a tutorial which is based in Maya 2010 however I want to transfer it to 2012-2013. The problem Is that there is a mirror symmetry functionality which works perfectly fine in 2010 however in 2012+ it blows up. What I assume is happening is that Maya is trying to calculate both actions at the same time. Not sure though But here is an example and since showing (for me) is way better then me trying to explain it all.

Tutorial :Developing Modular Rigging Systems with Python (http://www.3dbuzz.com/vbforum/showthread.php?182881-MM-Developing-Modular-Rigging-Systems-with-Python-Help)

Here is the problem. First 2010(working alright), then 2012(utter failure =( )

http://youtu.be/MZeuuD1aV1Y

Thanks for the look and as always Thank you for your time

djx
11-07-2012, 01:29 PM
I don't know for sure if this will help, but its easy to try, so I thought I'd mention it anyway, since it caused all sorts of problems in my rigging system.
Have a look at the Modify|Transformation Tools|Move Tool|Options and under Joint Orient Settings, uncheck Automatically Orient Joints.

David

Binxx
11-07-2012, 08:34 PM
Seems like it isn't working. I have a feeling its an issue with this expression


namespace -setNamespace ":"; $worldSpacePos = `xform -q -ws -translation SingleJointSegment__instance_2:module_transform`;

$worldSpaceOrient = `xform -q -ws -rotation SingleJointSegment__instance_2:module_transform`;

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateX = SingleJointSegment__instance_2:module_transform.translateX;

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateY = SingleJointSegment__instance_2:module_transform.translateY;

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateZ = SingleJointSegment__instance_2:module_transform.translateZ;

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateX = SingleJointSegment__instance_2:module_transform.rotateX;

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateY = SingleJointSegment__instance_2:module_transform.rotateY;

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateZ = SingleJointSegment__instance_2:module_transform.rotateZ;

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateX = $worldSpacePos[0];

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateX = $worldSpaceOrient[0];

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateY = $worldSpacePos[1];

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateY = $worldSpaceOrient[1];

SingleJointSegment__instance_2:module_transform_mirrorHelper.translateZ = $worldSpacePos[2];

SingleJointSegment__instance_2:module_transform_mirrorHelper.rotateZ = $worldSpaceOrient[2];

SingleJointSegment__instance_2:module_transform_mirrorHelper.globalScale = SingleJointSegment__instance_2:module_transform.globalScale;


simply run the script that makes this expression work its pretty simple.
The expression create is created via this python script.


def setupSymmetryMoveForObject(self, obj, mirrorObj, axis, translation = True, orientation = False, globalScale = False):
duplicateObject = cmds.duplicate(obj, parentOnly = True, inputConnections = True, name = obj+"_mirrorHelper")[0]
emptyGroup = cmds.group(empty = True, name = obj + "mirror_scale_grp")
cmds.parent(duplicateObject, emptyGroup, absolute = True)

scaleAttribute = ".scale" + axis
cmds.setAttr(emptyGroup+scaleAttribute, -1)

expressionString = "namespace -setNamespace \":\";\n"
if translation:
expressionString += "$worldSpacePos = `xform -q -ws -translation " + obj + "`;\n"
if orientation:
expressionString += "$worldSpaceOrient = `xform -q -ws -rotation " + obj + "`;\n"

attrs = []
if translation:
attrs.extend([".translateX", ".translateY", ".translateZ"])
if orientation:
attrs.extend([".rotateX", ".rotateY", ".rotateZ"])

for attr in attrs:
expressionString += duplicateObject+attr + " = " + obj + attr + ";\n"

i = 0

for axis in ["X", "Y", "Z"]:
if translation:
expressionString += duplicateObject+".translate" +axis + " = $worldSpacePos["+str(i)+"];\n"
if orientation:
expressionString += duplicateObject+".rotate" +axis + " = $worldSpaceOrient["+str(i)+"];\n"
i += 1
if globalScale:
expressionString += duplicateObject+".globalScale = " + obj+".globalScale;\n"

expression = cmds.expression(n=duplicateObject + "_symmetryMoveExpression", string=expressionString)

constraint = ""
if translation and orientation:
constraint = cmds.parentConstraint(duplicateObject, mirrorObj, maintainOffset = False, n = mirrorObj + "_symmetryMoveConstraint")[0]
elif translation:
constraint = cmds.pointConstraint(duplicateObject, mirrorObj, maintainOffset = False, n = mirrorObj + "_symmetryMoveConstraint")[0]
elif orientation:
constraint = cmds.orientConstraint(duplicateObject, mirrorObj, maintainOffset = False, n = mirrorObj + "_symmetryMoveConstraint")[0]
if globalScale:
cmds.connectAttr(duplicateObject+ ".globalScale", mirrorObj+ ".globalScale")

utils.addNodeToContainer("symmetryMove_container", [duplicateObject, emptyGroup, expression, constraint], ihb = True)

CGTalk Moderation
11-07-2012, 08:34 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.