// Heartstring (HS) v1.7 Noah Heilveil // U4 Grid v1.6 Ben Esler // U3 Grid v1.5 Josh Buck // Allows easy scene setup for the creation of HS Assets // v1.7 changes // Changed reference objects scale // renamed 'UE4 Grid' to 'HS Grid' // Updated snapping functions // fixed reference layer bug // Changed spacing display // fixed "stack last" losing selection bug // v1.6 changes // Updated All grid units from U3 to U4 (base 8 to base 10) // Changed reference objects (character height 188.28) // Changed from Divisions to Spacing for Grid Settings // Updated GUI spacing/sizing // Renamed from jbu3grid to UE4 Grid // v1.4 changes // added labels to help new users // added align functions // added new layer option to references // added axmesh button // v1.5 changes // updated UI colors for better look in Maya 2011 // fixed some UI bugs // added 5th level of grid division // changed the grid nudge method // Create main procedure global proc HSGrid() { if (`window -exists HSGridWindow`) deleteUI HSGridWindow; if (`windowPref -exists HSGridWindow`) windowPref -remove HSGridWindow; // Create main window window -title "HSGrid" -sizeable no //-rtf on HSGridWindow; // The main UI column columnLayout -columnWidth 170 -columnAttach both 0 -rowSpacing 2 mainColumnUI; // Grid UI Columns rowColumnLayout -numberOfColumns 2 -cw 1 84 -cw 2 84 -parent mainColumnUI gridSettingsUI; // Grid choice buttons button -backgroundColor 0.8 0.8 0.8 -height 30 -label "HS Grid" -command HSGridSettings; button -backgroundColor 0.8 0.8 0.8 -height 30 -label "Default Grid" -command jbDefaultGridSettings; rowColumnLayout -numberOfColumns 1 -columnWidth 1 180 -parent mainColumnUI; separator -height 10; text -label "Grid Settings" -al "center"; // Grid settings radio buttons rowColumnLayout -numberOfColumns 5 -cw 1 32 -cw 2 32 -cw 3 34 -cw 4 34 -cw 5 36 -parent mainColumnUI; $gridRadioCollection = `radioCollection gridCollection`; $gridQuery = `grid -query -spacing`; string $gridRadioButton1 , $gridRadioButton2 , $gridRadioButton4 , $gridRadioButton8 , $gridRadioButton16; $gridRadioButton1 = `radioButton -label "1" -onCommand ("grid -spacing 1") rbtnGrid1`; $gridRadioButton2 = `radioButton -label "5" -onCommand "grid -spacing 5" rbtnGrid2`; $gridRadioButton4 = `radioButton -label "10" -onCommand "grid -spacing 10" rbtnGrid4`; $gridRadioButton8 = `radioButton -label "50" -onCommand "grid -spacing 50" rbtnGrid8`; $gridRadioButton16 = `radioButton -label "100" -onCommand "grid -spacing 100" rbtnGrid16`; if ( $gridQuery == "1" ) radioCollection -edit -select $gridRadioButton1 $gridRadioCollection; if ( $gridQuery == "2" ) radioCollection -edit -select $gridRadioButton2 $gridRadioCollection; if ( $gridQuery == "4" ) radioCollection -edit -select $gridRadioButton4 $gridRadioCollection; if ( $gridQuery == "8" ) radioCollection -edit -select $gridRadioButton8 $gridRadioCollection; if ( $gridQuery == "16" ) radioCollection -edit -select $gridRadioButton16 $gridRadioCollection; // Radio buttons for snapping on/off rowColumnLayout -numberOfColumns 2 -cw 1 84 -cw 2 84 -parent mainColumnUI; $snapRadioCollection = `radioCollection snapCollection`; $snapQuery = `snapMode -query -grid`; string $snapOnRadioButton , $snapOffRadioButton; $snapOnRadioButton = `radioButton -label "Snap ON" -onCommand "snapMode -grid true" rbtnSnapOn`; $snapOffRadioButton = `radioButton -label "Snap OFF" -onCommand "snapMode -grid false" rbtnSnapOff`; if ( $snapQuery == "1" ) radioCollection -edit -select $snapOnRadioButton $snapRadioCollection; if ( $snapQuery == "0" ) radioCollection -edit -select $snapOffRadioButton $snapRadioCollection; // Larger/Smaller grid buttons rowColumnLayout -numberOfColumns 2 -cw 1 84 -cw 2 84 -parent mainColumnUI; button -backgroundColor 0.65 0.65 0.65 -label "Larger" -command MakeGridLarger; button -backgroundColor 0.65 0.65 0.65 -label "Smaller" -command MakeGridSmaller; // 3D Grid Nudge Label rowColumnLayout -numberOfColumns 1 -columnWidth 1 168 -parent mainColumnUI; separator -height 10; text -label "3D Grid Nudge" -al "center"; //Grid Nudge Buttons rowColumnLayout -numberOfColumns 3 -cw 1 52 -cw 2 52 -cw 3 52 -cs 1 5 -parent mainColumnUI; button -height 30 -bgc 0.65 0.50 0.50 -label "+ X" -command jbNudgeGridXPlus; button -height 30 -bgc 0.50 0.65 0.50 -label "+ Y" -command jbNudgeGridYPlus; button -height 30 -bgc 0.50 0.50 0.65 -label "+ Z" -command jbNudgeGridZPlus; button -height 30 -bgc 0.65 0.50 0.50 -label "- X" -command jbNudgeGridXMinus; button -height 30 -bgc 0.50 0.65 0.50 -label "- Y" -command jbNudgeGridYMinus; button -height 30 -bgc 0.50 0.50 0.65 -label "- Z" -command jbNudgeGridZMinus; // Align UI/Settings rowColumnLayout -numberOfColumns 1 -columnWidth 1 168 -parent mainColumnUI; separator -height 10; text -align center -label "Align"; rowColumnLayout -numberOfColumns 3 -cw 1 52 -cw 2 52 -cw 3 52 -cs 1 5 -parent mainColumnUI; button -height 30 -bgc 0.65 0.50 0.50 -label "X" -command AlignXPlus; button -height 30 -bgc 0.50 0.65 0.50 -label "Y" -command AlignYPlus; button -height 30 -bgc 0.50 0.50 0.65 -label "Z" -command AlignZPlus ; rowColumnLayout -numberOfColumns 2 -columnWidth 1 84 -columnWidth 2 84 -parent mainColumnUI; checkBox -align left -v false -label "Stack" alignStack; checkBox -align left -v false -label "Align to last" alignToLead; //Make References UI column rowColumnLayout -numberOfColumns 1 -columnWidth 1 168 -parent mainColumnUI; separator -height 10; text -label "References" -al "center"; button -height 30 -width 60 -al center -bgc 0.65 0.65 0.55 -label "Wall 20x400x400 Ref" -command MakeW20_H400_D400ref; button -height 30 -width 60 -al center -bgc 0.65 0.55 0.65 -label "Door 18x200x90 Ref" -command MakeD18_H200_D90ref; button -height 30 -width 60 -al center -bgc 0.55 0.65 0.65 -label "Char 50x188.28x50 Ref" -command MakeDefaultCharacter; checkBox -align left -v false -label "Add to new Layer" addToNewLayer; //Inches to Centimeter // Isolate/Show UI columns rowColumnLayout -numberOfColumns 1 -columnWidth 1 168 -parent mainColumnUI; separator -height 10; text -label "Isolate Mesh" -al "center"; rowColumnLayout -numberOfColumns 2 -columnWidth 1 84 -columnWidth 2 84 -parent mainColumnUI otherUI; $isolateRadioCollection = `radioCollection isolateCollection`; string $isolateRadioButton , $showRadioButton; $showRadioButton = `radioButton -label "Show All" -select -onCommand jbUnisolate rbtnShow`; $isolateRadioButton = `radioButton -label "Isolate" -onCommand jbIsolateSelected rbtnIsolate`; rowColumnLayout -numberOfColumns 1 -columnWidth 1 168 -parent mainColumnUI additionalFunctionsUI; showWindow HSGridWindow; } HSGrid; //Maya default grid and camera global proc jbDefaultGridSettings() { grid -size 12 -spacing 5 -divisions 5; displayColor -c -dormant gridAxis 1; displayColor -c -dormant gridHighlight 3; displayColor -c -dormant grid 3; setAttr "perspShape.farClipPlane" 10000; setAttr "perspShape.nearClipPlane" 0.1; setAttr "top.translateY" 100.1; setAttr "front.translateZ" 100.1; setAttr "side.translateX" 100.1; viewSet -animate `optionVar -query animateRollViewCompass` -home; print ("Default Grid and Camera Settings Restored \n"); } //Heartstrings grid and camera global proc HSGridSettings() { // sets grid color displayColor -c -dormant gridAxis 1; displayColor -c -dormant gridHighlight 3; displayColor -c -dormant grid 2; // sets camera to prevent clipping and eliminate display artifacts setAttr "perspShape.farClipPlane" 100000; setAttr "perspShape.nearClipPlane" 1.5; setAttr "top.translateY" 1000; setAttr "front.translateZ" 1000; setAttr "side.translateX" 1000; // sets grid grid -size 15 -spacing 5 -divisions 5; snapMode -grid true; // sets radio buttons in UI radioCollection -edit -select rbtnGrid2 gridCollection; radioCollection -edit -select rbtnSnapOn snapCollection; // sets view to home viewSet -animate `optionVar -query animateRollViewCompass` -home; print ("Unreal Grid and Camera Settings Activated \n"); } //Increase overall grid size by a value global proc MakeGridLarger () { int $makeThisMuchLarger = 5; int $currentGridSize = `grid -query -size`; grid -size ($currentGridSize + $makeThisMuchLarger); } //Decrese overall grid size by a value global proc MakeGridSmaller () { int $makeThisMuchSmaller = 5; int $currentGridSize = `grid -query -size`; grid -size ($currentGridSize - $makeThisMuchSmaller); } //Makes a reference object D1.8 h20 d9 global proc MakeD18_H200_D90ref() { polyCube -ch on -o on -w 9 -h 20 -d 1.8 -sw 9 -sh 20 -sd 2 -cuv 4 -name ref_D20object ; move 0 10 0; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; if ( `checkBox -q -value addToNewLayer`) { createDisplayLayer -name "r_2_20_9_1" ; } } //Makes a reference object w2 h40 d40 global proc MakeW20_H400_D400ref() { polyCube -ch on -o on -w 40 -h 40 -d 2 -sw 40 -sh 40 -sd 2 -cuv 4 -name ref_w40object ; move 0 20 0; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; if ( `checkBox -q -value addToNewLayer`) { createDisplayLayer -name "r_10_10_2_1" ; } } //Makes a maximum size human reference object global proc MakeDefaultCharacter() { polyCube -ch on -o on -w 5 -h 18.828 -d 5 -sw 5 -sh 4 -sd 5 -cuv 4 -name ref_defaultCharacter ; move 0 9.414 0; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; if ( `checkBox -q -value addToNewLayer`) { createDisplayLayer -name "r_MaxHuman_1" ; } } //Isolates the selected mesh based on viewPanel global proc jbIsolateSelected() { $activePanel = `getPanel -withFocus`; string $panelType = `getPanel -to $activePanel`; if ($panelType == "modelPanel") { print "ISOLATED \n"; enableIsolateSelect $activePanel 1; } else { error "Panel must contain an active Mesh"; } } //Unisolates the selected mesh based on viewPanel global proc jbUnisolate() { $activePanel = `getPanel -withFocus`; string $panelType = `getPanel -to $activePanel`; if ($panelType == "modelPanel") { enableIsolateSelect $activePanel 0; } else { error "Panel must contain an active Mesh"; } } // Grid Snap Movements global proc jbNudgeGridXPlus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInX = (10 / $currentGridDivs); move -relative -rpr -x $moveThisMuchInX; } global proc jbNudgeGridXMinus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInX = (10 / $currentGridDivs); move -relative -rpr -x ($moveThisMuchInX * -1); } global proc jbNudgeGridYPlus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInY = (10 / $currentGridDivs); move -relative -rpr -y $moveThisMuchInY; } global proc jbNudgeGridYMinus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInY = (10 / $currentGridDivs); move -relative -rpr -y ($moveThisMuchInY * -1); } global proc jbNudgeGridZPlus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInZ = (10 / $currentGridDivs); move -relative -rpr -z $moveThisMuchInZ; } global proc jbNudgeGridZMinus () { int $currentGridDivs = `grid -query -divisions`; int $moveThisMuchInZ = (10 / $currentGridDivs); move -relative -rpr -z ($moveThisMuchInZ * -1); } global proc AlignXPlus () { if ( `checkBox -q -value alignStack` ) { align -x stack; } else if ( `checkBox -q -value alignToLead` ) { align -x mid -atl; } else { align -x mid; } } global proc AlignYPlus () { if ( `checkBox -q -value alignStack` ) { align -y stack; } else if ( `checkBox -q -value alignToLead` ) { align -y mid -atl; } else { align -y mid; } } global proc AlignZPlus () { if ( `checkBox -q -value alignStack` ) { align -z stack; } else if ( `checkBox -q -value alignToLead` ) { align -z mid -atl; } else { align -z mid; } }