// =========================================================================== // 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 MASHcheckFlightMode ( string $nodeName ) { if ( `objExists $nodeName` == 0 ) return; string $nodeAttr = $nodeName + ".legacy2017"; int $value = `getAttr $nodeAttr`; if ($value) { editorTemplate -dimControl $nodeName "startFrame" true; } else { editorTemplate -dimControl $nodeName "startFrame" false; } } global proc AEMASH_FlightTemplate( string $nodeName ) { editorTemplate -beginScrollLayout; python("import MASH.nodeHeaders; MASH.nodeHeaders.addHeader('" + $nodeName + "', 'Flight')") editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kMainControls")) -collapse 0; editorTemplate -label (getPluginResource("MASH", "kSeperateStrength")) -addControl "seperationStrength"; editorTemplate -label (getPluginResource("MASH", "kAlignStrength")) -addControl "alignmentStrength"; editorTemplate -label (getPluginResource("MASH", "kCohesionStrength")) -addControl "cohesionStrength"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kSearchDist")) -addControl "searchDistance"; editorTemplate -label (getPluginResource("MASH", "kCompanionNum")) -addControl "numberOfNeighbours"; editorTemplate -label (getPluginResource("MASH", "kVisionField")) -addControl "FoV"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kAlignZone")) -addControl "alignThreshold"; editorTemplate -label (getPluginResource("MASH", "kSeperateZone")) -addControl "seperationThreshold"; editorTemplate -beginLayout (getPluginResource("MASH", "kSpeedMass")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kMinSpeed")) -addControl "minSpeed"; editorTemplate -label (getPluginResource("MASH", "kMaxSpeed")) -addControl "maxSpeed"; editorTemplate -label (getPluginResource("MASH", "kSteerForce")) -addControl "steeringForce"; editorTemplate -label (getPluginResource("MASH", "kRotationSteering")) -addControl "rotationalSteering"; editorTemplate -label (getPluginResource("MASH", "kRotationThreshold")) -addControl "rotationalThreshold"; editorTemplate -callCustom "AEFlightLegacyCheck" "AEFlightLegacyCheckEdit" ""; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kMass")) -addControl "mass"; editorTemplate -label (getPluginResource("MASH", "kMassVar")) -addControl "massVariance"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kStrength")) -addControl "Envelope"; editorTemplate -label (getPluginResource("MASH", "kRandStrength")) -addControl "randEnvelope"; editorTemplate -label (getPluginResource("MASH", "kStepStrength")) -addControl "StepEnvelope"; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kGravInertia")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kGravStrength")) -addControl "gravitateStrength"; editorTemplate -label (getPluginResource("MASH", "kGravDist")) -addControl "gravitateDistance"; editorTemplate -label (getPluginResource("MASH", "kGravType")) -addControl "gravitateType"; editorTemplate -label (getPluginResource("MASH", "kGivenLoc")) -addControl "gravitateLocation"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kInertia")) -addControl "inertia"; editorTemplate -addSeparator; editorTemplate -callCustom "MASHflightGravitationBuildQt" "MASHflightGravitationUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kRamps")) -collapse 1; AEaddRampControl ($nodeName+".separateRamp"); AEaddRampControl ($nodeName+".alignRamp"); AEaddRampControl ($nodeName+".cohereRamp"); AEaddRampControl ($nodeName+".obstacleRamp"); AEaddRampControl ($nodeName+".attractorRamp"); AEaddRampControl ($nodeName+".predatorAndPreyRamp"); AEaddRampControl ($nodeName+".gravityRamp"); editorTemplate -endLayout; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kControlView")) -collapse 0; editorTemplate -label (getPluginResource("MASH", "kDispType")) -addControl "displayType"; editorTemplate -label (getPluginResource("MASH", "kPointID")) -addControl "displayCount"; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kAttractControl")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kAttractStrength")) -addControl "targetStrength"; editorTemplate -label (getPluginResource("MASH", "kAttractSearchDist")) -addControl "targetDistance"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kArrivalMode")) -addControl "arrivalMode"; editorTemplate -label (getPluginResource("MASH", "kArrivalThresh")) -addControl "arriveThreshold"; editorTemplate -label (getPluginResource("MASH", "kArrivalVar")) -addControl "arriveVariance"; editorTemplate -label (getPluginResource("MASH", "kArrivalDamp")) -addControl "arrivalDamp"; editorTemplate -callCustom "MASHflightAttractorWidgetBuildQt" "MASHflightAttractorWidgetUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kObstacleCont")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kAvoidType")) -addControl "avoidanceType"; editorTemplate -label (getPluginResource("MASH", "kObstacleStr")) -addControl "obstacleStrength"; editorTemplate -label (getPluginResource("MASH", "kObstacleSearchDist")) -addControl "obstacleDistance"; editorTemplate -addSeparator; editorTemplate -callCustom "AEaddObstacleButtons" "AEaddObstacleButtonsEdit" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kPredatorPrey")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kPredatorStr")) -addControl "predatorStrength"; editorTemplate -label (getPluginResource("MASH", "kPredatorSearchDist")) -addControl "predatorDistance"; editorTemplate -label (getPluginResource("MASH", "kPreyStrength")) -addControl "preyStrength"; editorTemplate -label (getPluginResource("MASH", "kPreySearchDist")) -addControl "preyDistance"; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kMeshFollow")) -collapse 1; editorTemplate -callCustom "MASHflightMeshFollowingBuildQt" "MASHflightMeshFollowingUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kFields")) -collapse 1; editorTemplate -callCustom "MASHFlightMayaForcesListWidgetBuildQt" "MASHFlightMayaForcesWidgetUpdateQt" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kDistInitialState")) -collapse 1; editorTemplate -callCustom "MASHflightInitialStateBuildQt" "MASHflightInitialStateUpdateQt" ""; editorTemplate -endLayout; editorTemplate -label (getPluginResource("MASH", "kSimStart")) -addControl "startFrame"; AEdependNodeTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; } // // Check for legacy controls and disable the new controls accordingly // global proc AEFlightLegacyCheck ( string $attr ) { AEFlightLegacyCheckEdit($attr); } global proc AEFlightLegacyCheckEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); string $conns[] = `listConnections -d 1 -s 0 -p 1 ($nodeName[0]+".outputPoints")`; if (size($conns) == 0) { editorTemplate -dimControl $nodeName "rotationalSteering" true; editorTemplate -dimControl $nodeName "rotationalThreshold" true; } else { editorTemplate -dimControl $nodeName "rotationalSteering" false; editorTemplate -dimControl $nodeName "rotationalThreshold" false; } } global proc AEaddGravButtons ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -bgc (181.0/255.0) (157.0/255.0) (136.0/255.0) -label (getPluginResource("MASH", "kConnectLoc")) -c ("flightGravButtonCMDS " + $nodeName[0] + " 1") connGravMASHButton; button -bgc (140.0/255.0) (167.0/255.0) (173.0/255.0) -label (getPluginResource("MASH", "kCreateLoc")) -c ("flightGravButtonCMDS " + $nodeName[0] + " 2") createGravMASHButton; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEaddGravButtonsEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("flightGravButtonCMDS " + $nodeName[0] + " 1") connGravMASHButton; button -e -c ("flightGravButtonCMDS " + $nodeName[0] + " 2") createGravMASHButton; } global proc flightGravButtonCMDS (string $nodeName, int $whichCMD) { if ($whichCMD == 1) { string $obj[] = `ls -sl -tr`; if (size($obj) > 0) { connectAttr -force ($obj[0]+".translate") ($nodeName+".gravitateLocation"); MASHinViewMessage((getPluginResource("MASH", "kTranslateConnected")), "Info"); } else { MASHinViewMessage((getPluginResource("MASH", "kPleaseSelectTranslate")), "Warning"); } } if ($whichCMD == 2) { //create a transform that will the the central attraction point for the flock string $obj[] = `spaceLocator -n (getPluginResource("MASH", "kGravitationCentre"))`; connectAttr -force ($obj[0]+".translate") ($nodeName+".gravitateLocation"); MASHinViewMessage((getPluginResource("MASH", "kTranslateConnected")), "Info"); } evalDeferred("updateAE " + $nodeName); } global proc AEaddFollowButtons ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -bgc (181.0/255.0) (157.0/255.0) (136.0/255.0) -label (getPluginResource("MASH", "kConnectAttrObj")) -c ("flightButtonCMDS " + $nodeName[0] + " 1") connFollowMASHButton; button -bgc (140.0/255.0) (167.0/255.0) (173.0/255.0) -label (getPluginResource("MASH", "kCreateAttrObj")) -c ("flightButtonCMDS " + $nodeName[0] + " 2") createFollowMASHButton; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEaddFollowButtonsEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("flightButtonCMDS " + $nodeName[0] + " 1") connFollowMASHButton; button -e -c ("flightButtonCMDS " + $nodeName[0] + " 2") createFollowMASHButton; } global proc AEaddObstacleButtons ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); rowLayout -numberOfColumns 3 -columnWidth3 125 140 125 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center"; button -bgc (181.0/255.0) (157.0/255.0) (136.0/255.0) -label (getPluginResource("MASH", "kConnectObstacle")) -c ("flightButtonCMDS " + $nodeName[0] + " 3") connObstMASHButton; button -bgc (140.0/255.0) (167.0/255.0) (173.0/255.0) -label (getPluginResource("MASH", "kCreateObstacleLoc")) -c ("flightButtonCMDS " + $nodeName[0] + " 4") createObstMASHButton; button -bgc (173.0/255.0) (140.0/255.0) (163.0/255.0) -label (getPluginResource("MASH", "kConnectObstacleMesh")) -c ("flightButtonCMDS " + $nodeName[0] + " 5") connObMeshMASHButton; setParent..; separator -w 100 -h 5 -hr 1 -st "none"; } global proc AEaddObstacleButtonsEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); button -e -c ("flightButtonCMDS " + $nodeName[0] + " 3") connObstMASHButton; button -e -c ("flightButtonCMDS " + $nodeName[0] + " 4") createObstMASHButton; button -e -c ("flightButtonCMDS " + $nodeName[0] + " 5") connObMeshMASHButton; } global proc flightButtonCMDS (string $nodeName, int $whichCMD) { if ($whichCMD == 1) { string $connections[] = `listConnections -d on -s on ($nodeName + ".targets")`; int $currentFollows = size($connections); int $element = $currentFollows; string $toAttr = ($nodeName + ".targets[" + $element +"]"); string $obj[] = `ls -sl -tr`; if (size($obj) > 0) { connectAttr -force ($obj[0]+".translate") $toAttr; MASHinViewMessage((getPluginResource("MASH", "kTranslateConnected")), "Info"); } else { MASHinViewMessage((getPluginResource("MASH", "kPleaseSelectTranslate")), "Warning"); } } if ($whichCMD == 2) { string $connections[] = `listConnections -d on -s on ($nodeName + ".targets")`; int $currentFollows = size($connections); int $element = $currentFollows; string $toAttr = ($nodeName + ".targets[" + $element +"]"); string $obj[] = `spaceLocator -n (getPluginResource("MASH", "kFollowLocator"))`; connectAttr ($obj[0]+".translate") $toAttr; } if ($whichCMD == 3) { string $connections[] = `listConnections -d on -s on ($nodeName + ".obstacles")`; int $currentFollows = size($connections); int $element = $currentFollows; string $toAttr = ($nodeName + ".obstacles[" + $element +"]"); string $obj[] = `ls -sl -tr`; if (size($obj) > 0) { connectAttr -force ($obj[0]+".translate") $toAttr; MASHinViewMessage((getPluginResource("MASH", "kTranslateConnected")), "Info"); } else { MASHinViewMessage((getPluginResource("MASH", "kPleaseSelectTranslate")), "Warning"); } } if ($whichCMD == 4) { string $connections[] = `listConnections -d on -s on ($nodeName + ".obstacles")`; int $currentFollows = size($connections); int $element = $currentFollows; string $toAttr = ($nodeName + ".obstacles[" + $element +"]"); string $obj[] = `spaceLocator -n (getPluginResource("MASH", "kObstacleLocator"))`; connectAttr ($obj[0]+".translate") $toAttr; } if ($whichCMD == 5) { string $connections[] = `listConnections -d on -s on ($nodeName + ".obstacleMeshes")`; int $currentFollows = size($connections); int $element = $currentFollows; string $toAttr = ($nodeName + ".obstacleMeshes[" + $element +"]"); string $filter[] = `filterExpand -sm 12`; if (size($filter) > 0) { string $shape[] = `listRelatives -s $filter[0]`; connectAttr -force ($shape[0]+".worldMesh") $toAttr; MASHinViewMessage((getPluginResource("MASH", "kTranslateConnected")), "Info"); } else { MASHinViewMessage((getPluginResource("MASH", "kPleaseSelectMesh")), "Warning"); } } evalDeferred("updateAE " + $nodeName); } global proc MASHflightGravitationBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 flightGravitationLayout; text -w 105 -h 20 -vis 1 -label (getPluginResource("MASH", "kGravityLocation")) -align "right" -font "plainLabelFont" ; //get python to create the widget, include the desired nodeType as an arguement python("MASHsingleInputQtWidget.build_qt_widget('flightGravitationLayout', '" + $nodeName + "', 'transform', 'gravitateLocation', 'translate', '')"); setParent..; } global proc MASHflightGravitationUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); python("MASHsingleInputQtWidget.update_qt_widget('flightGravitationLayout', '" + $nodeName + "', 'transform', 'gravitateLocation', 'translate', '')"); } global proc MASHflightAttractorWidgetBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHlistQtWidget"); string $parent = `setParent -q`; //get python to create the widget, include the desired nodeType as an arguement python("MASHlistQtWidget.build_qt_widget('" + $parent + "', '" + $nodeName + "', 'transform', 'targets', 'translate', '', 'kAttractorObjects')"); setParent..; } global proc MASHflightAttractorWidgetUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; string $parent = `setParent -q`; python("import MASHsingleInputQtWidget"); python("MASHlistQtWidget.update_qt_widget('" + $parent + "', '" + $nodeName + "', 'transform', 'targets', 'translate', '', 'kAttractorObjects')"); } global proc MASHflightMeshFollowingBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 flightFollowMeshLayout; 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('flightFollowMeshLayout', '" + $nodeName + "', 'mesh', 'inputMesh', 'worldMesh', '')"); setParent..; } global proc MASHflightMeshFollowingUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); python("MASHsingleInputQtWidget.update_qt_widget('flightFollowMeshLayout', '" + $nodeName + "', 'mesh', 'inputMesh', 'worldMesh', '')"); } global proc MASHFlightMayaForcesListWidgetBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHlistQtWidget"); string $parent = `setParent -q`; //get python to create the widget, include the desired nodeType as an arguement python("MASHlistQtWidget.build_qt_widget('" + $parent + "','" + $nodeName + "', 'vortexField,uniformField,turbulenceField,dragField,gravityField,newtonField,radialField,airField,volumeAxisField', 'fields', 'message', '', 'kFields')"); setParent..; } global proc MASHFlightMayaForcesWidgetUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; string $parent = `setParent -q`; python("import MASHlistQtWidget"); python("MASHlistQtWidget.update_qt_widget('" + $parent + "', '" + $nodeName + "', 'vortexField,uniformField,turbulenceField,dragField,gravityField,newtonField,radialField,airField,volumeAxisField', 'fields', 'message', '', 'kFields')"); } global proc MASHflightInitialStateBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 flightInitialStateLayout; text -w 105 -h 20 -vis 1 -label (getPluginResource("MASH", "kDistInitialState")) -align "right" -font "plainLabelFont" ; //get python to create the widget, include the desired nodeType as an arguement python("MASHsingleInputQtWidget.build_qt_widget('flightInitialStateLayout', '" + $nodeName + "', 'MASH_Waiter', 'initialState', 'outputPoints', '')"); setParent..; } global proc MASHflightInitialStateUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; python("import MASHsingleInputQtWidget"); python("MASHsingleInputQtWidget.update_qt_widget('flightInitialStateLayout', '" + $nodeName + "', 'MASH_Waiter', 'initialState', 'outputPoints', '')"); }