// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== global proc AEMASH_OrientTemplate( string $nodeName ) { editorTemplate -beginScrollLayout; python("import MASH.nodeHeaders; MASH.nodeHeaders.addHeader('" + $nodeName + "', 'Orient')") editorTemplate -endLayout; editorTemplate -label (getPluginResource("MASH", "kOrientMode")) -addControl "orientMode"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kSoloX")) -addControl "rotationXStrength"; editorTemplate -label (getPluginResource("MASH", "kSoloY")) -addControl "rotationYStrength"; editorTemplate -label (getPluginResource("MASH", "kSoloZ")) -addControl "rotationZStrength"; editorTemplate -label (getPluginResource("MASH", "kUpVector")) -addControl "upVectorMenu"; editorTemplate -label (getPluginResource("MASH", "kFlipAxis")) -addControl "flipAxis"; editorTemplate -label (getPluginResource("MASH", "kSmoothRot")) -addControl "smoothing"; editorTemplate -label (getPluginResource("MASH", "kMuteRot")) -addControl "muteIncoming"; editorTemplate -beginLayout (getPluginResource("MASH", "kTargertAimOpt")) -collapse 1; editorTemplate -callCustom "MASHorientTargetSingleInputBuildQt" "MASHorientTargetSingleInputUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kMeshOrientOpt")) -collapse 1; editorTemplate -callCustom "MASHorientMeshSingleInputBuildQt" "MASHorientMeshInputUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kStrength")) -collapse 0; editorTemplate -label (getPluginResource("MASH", "kStrength")) -addControl "Envelope"; editorTemplate -label (getPluginResource("MASH", "kRandStrength")) -addControl "randEnvelope"; editorTemplate -label (getPluginResource("MASH", "kStepStrength")) -addControl "StepEnvelope"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kStrengthMap")) -addControl "mColour"; editorTemplate -label (getPluginResource("MASH", "kMapProjAxis")) -addControl "mapDirection"; editorTemplate -callCustom "MASHmapHelperButton" "MASHmapHelperButtonEdit" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kFalloffObject")) -collapse 1; editorTemplate -callCustom "MASHfalloffButtons" "MASHfalloffButtonsEdit" ""; editorTemplate -endLayout; editorTemplate -suppress "targetMode"; editorTemplate -suppress "inIterations"; editorTemplate -suppress "Envelope"; editorTemplate -suppress "randEnvelope"; editorTemplate -suppress "StepEnvelope"; editorTemplate -suppress "time"; editorTemplate -suppress "upVector"; AEdependNodeTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; } global proc AEaddSpringButton ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -label (getPluginResource("MASH", "kAddSpring")) -c ("orientButtonCMDS " + $nodeName[0] + " 1") addRotSpringMASHButton; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEaddSpringButtonEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("orientButtonCMDS " + $nodeName[0] + " 1") addRotSpringMASHButton; } global proc orientButtonCMDS (string $nodeName, int $whichCMD) { if ($whichCMD == 1) { string $outgoing[] = `listConnections -d 1 -s 0 ($nodeName+".outRotationPP")`; //create new node and hook up time string $nodeType = "MASH_Spring"; $newNode = `createNode MASH_Spring -n $nodeType`; connectAttr -f time1.outTime ($newNode +".time"); //connect message string $conns[] = `listConnections -d 1 ($outgoing[0] +".setMessage")`; int $numConns = `size($conns)`; int $nextCon = $numConns+1; connectAttr -force ($newNode +".message") ($outgoing[0] +".setMessage[" + $nextCon + "]"); // connect new node to waiter connectAttr -force ($newNode +".outArray") ($outgoing[0] +".inRotationPP"); //connect new node to current node connectAttr -force ($nodeName +".outRotationPP") ($newNode +".inputArray"); //set good rotation defaults setAttr ($newNode +".damping") 0.85; setAttr ($newNode +".stiffness") 0.05; } } global proc AEorientButton ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -bgc (181.0/255.0) (157.0/255.0) (136.0/255.0) -label (getPluginResource("MASH", "kSetTarget")) -c ("orientButtonCMDS " + $nodeName[0] + " 1") setOrientMASHButton; button -bgc (140.0/255.0) (167.0/255.0) (173.0/255.0) -label (getPluginResource("MASH", "kCreateTarget")) -c ("orientButtonCMDS " + $nodeName[0] + " 2") createTargetMASHButton; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEorientButtonEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("orientButtonCMDS " + $nodeName[0] + " 1") setOrientMASHButton; button -e -c ("orientButtonCMDS " + $nodeName[0] + " 2") createTargetMASHButton; } global proc orientButtonCMDS (string $nodeName, int $whichCMD) { if ($whichCMD == 1) { string $target[] = `ls -sl -type "transform"`; if (size($target) > 0) { connectAttr -force ($target[0]+".translate") ($nodeName+".targetInput"); setAttr ($nodeName+".orientMode") 2; print "Target connected."; } else { warning "Please select a translate."; } } if ($whichCMD == 2) { string $obj[] = `spaceLocator`; connectAttr -force ($obj[0]+".translate") ($nodeName+".targetInput"); setAttr ($obj[0]+".overrideColor") 9; setAttr ($obj[0]+".overrideEnabled") 1; setAttr ($nodeName+".targetMode") 1; setAttr ($nodeName+".orientMode") 2; } else if ($whichCMD == 3) { string $filter[] = `filterExpand -sm 12`; if (size($filter) > 0) { string $shape[] = `listRelatives -s $filter[0]`; connectAttr -force ($shape[0]+".worldMesh") ($nodeName+".inputMesh"); setAttr ($nodeName+".orientMode") 3; MASHinViewMessage("Mesh connected.", "Info"); } else { MASHinViewMessage("Please select a mesh.", "Warning"); } } evalDeferred("updateAE " + $nodeName); } global proc AEaddMeshOrientButtons ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -label (getPluginResource("MASH", "kConnectMesh")) -c ("orientButtonCMDS " + $nodeName[0] + " 3") orientMeshMASHButton; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEaddMeshButtonsOrientEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("orientButtonCMDS " + $nodeName[0] + " 3") orientMeshMASHButton; } global proc MASHorientTargetSingleInputBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 orientTarget; text -w 105 -h 20 -vis 1 -label (getPluginResource("MASH", "kTarget")) -align "right" -font "plainLabelFont" ; //get python to create the widget, include the desired nodeType as an arguement python("MASHsingleInputQtWidget.build_qt_widget('orientTarget', '" + $nodeName + "', 'transform', 'targetInput', 'translate', 'OrientSwitchToAimMode')"); setParent..; } global proc MASHorientTargetSingleInputUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("MASHsingleInputQtWidget.update_qt_widget('orientTarget', '" + $nodeName + "', 'transform', 'targetInput', 'translate', 'OrientSwitchToAimMode')"); } global proc MASHorientMeshSingleInputBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 orientMesh; text -w 105 -h 20 -vis 1 -label (getPluginResource("MASH", "kInputMesh")) -align "right" -font "plainLabelFont" ; //get python to create the widget, include the desired nodeType as an arguement python("MASHsingleInputQtWidget.build_qt_widget('orientMesh', '" + $nodeName + "', 'mesh', 'inputMesh', 'worldMesh', 'OrientSwitchToMeshMode')"); setParent..; } global proc MASHorientMeshInputUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); python("MASHsingleInputQtWidget.update_qt_widget('orientMesh', '" + $nodeName + "', 'mesh', 'inputMesh', 'worldMesh', 'OrientSwitchToMeshMode')"); }