Created
August 13, 2017 09:23
-
-
Save bitinn/6de928fbfb4f8fb8839412fbfdd126f6 to your computer and use it in GitHub Desktop.
AMT Normal Tools Lite for Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AMT Normal Tools Lite | |
// | |
// Copyright (c) 2017 Adnan Chaumette "fansub" | |
// http://polycount.com/discussion/183993/maya-free-face-weighted-vertex-normals-tool/ | |
// | |
// Re-indented and Tested on Mac with Maya LT 2017, by David Frank "bitinn" | |
// Install guide for mac users: | |
// | |
// Put "AMTNormalsLT" folder under this folder | |
// /Users/YOUR_USER_NAME/Library/Preferences/Autodesk/maya/YOUR_MAYA_VERSION/scripts | |
// Usage guide: | |
// | |
// 1. Source the AMTNormalsLT.mel (a main window should appear) | |
// 2. Select a mesh | |
// 3. Click "Weight Face Normals" button (FWN should be applied) | |
// 4. Hold middle mouse and move mouse to change bevel size; alternatively, hold cmd button and move the mouse; or just use the bevel attribute editor. | |
CallAMTNormalToolLT; | |
/* | |
display the main toolkit window | |
*/ | |
global proc CallAMTNormalToolLT() { | |
string $AMTNormalPath = (`internalVar -userScriptDir`) + "AMTNormalsLT/"; | |
string $AMTNormalsLT = "AMTNormalToolLT"; | |
if (`window -exists $AMTNormalsLT`) { | |
deleteUI $AMTNormalsLT; | |
windowPref -remove $AMTNormalsLT; | |
} | |
window | |
-title "AMT Normal Tools LT 1.0" | |
-s true | |
-wh 257 188 | |
-bgc (45/255.0) (50/255.0) (55/255.0) | |
-mxb false | |
-tlb true $AMTNormalsLT; | |
string $FaceWeightOps = | |
`frameLayout -cll 0 -label "FACE WEIGHTED WORKFLOW" -labelVisible false`; | |
rowColumnLayout -numberOfRows 1; | |
button | |
-l "Weight Face Normals" | |
-command ("FWVNLT") | |
-bgc (26/255.0) (30/255.0) (32/255.0) | |
-h 30 | |
-w 255; | |
setParent ..; | |
separator -h 1 -st "in" -hr 1; | |
rowColumnLayout -numberOfRows 1; | |
iconTextButton | |
-style "iconAndTextHorizontal" | |
-image ($AMTNormalPath + "Vertex_Display.png") | |
-font "boldLabelFont" | |
-ann "Enabled" | |
-label "Vertex Display" | |
-w 125 | |
-command ("setPolygonDisplaySettings(\"vNormal\")") | |
VertexDisplayBTN; | |
iconTextButton | |
-style "iconAndTextHorizontal" | |
-image ($AMTNormalPath + "Face_Display.png") | |
-font "boldLabelFont" | |
-ann "Enabled" | |
-label "Face Display" | |
-w 125 | |
-command ("setPolygonDisplaySettings(\"fNormal\")") | |
FaceDisplayBTN; | |
setParent..; | |
rowColumnLayout -numberOfRows 1; | |
iconTextButton | |
-style "iconAndTextHorizontal" | |
-image ($AMTNormalPath + "SelectHard.png") | |
-font "boldLabelFont" | |
-ann "" | |
-w 125 | |
-label "Sel. Hard Edges" | |
-command ("SelectHardEdges") | |
SelectHardBTN; | |
iconTextButton | |
-style "iconAndTextHorizontal" | |
-image ($AMTNormalPath + "SelectSoft.png") | |
-font "boldLabelFont" | |
-ann "" | |
-w 125 | |
-label "Sel. Soft Edges" | |
-command ("SelectSoftdges") | |
SelectSoftBTN; | |
setParent..; | |
separator -h 1 -st "in" -hr 1; | |
text -fn "boldLabelFont" -label "Normals Display Size"; | |
separator -h 1 -st "in" -hr 1; | |
float $NSizeValue[] = `polyOptions -q -sn`; | |
floatSliderGrp | |
-field true | |
-minValue 0 | |
-maxValue 250.0 | |
-fieldMinValue 0 | |
-fieldMaxValue 1000 | |
-value $NSizeValue[0] | |
-cw 1 50 | |
-dc ("ModifyNormalSize") | |
-cc ("ModifyNormalSize") | |
-cal 1 "center" | |
NormalSizeSLDR; | |
setParent $FaceWeightOps; | |
showWindow; | |
} | |
/* | |
Edit normal size | |
*/ | |
global proc ModifyNormalSize() { | |
float $GetSLDRVal = `floatSliderGrp -q -v NormalSizeSLDR`; | |
polyOptions -sn $GetSLDRVal; | |
} | |
/* | |
Select hard edges | |
*/ | |
global proc SelectHardEdges() { | |
resetPolySelectConstraint; | |
polySelectConstraint -m 3 -t 0x8000 -sm 1; | |
polySelectConstraint -m 0; | |
} | |
/* | |
Select soft edges | |
*/ | |
global proc SelectSoftdges() { | |
resetPolySelectConstraint; | |
polySelectConstraint -m 3 -t 0x8000 -sm 2; | |
polySelectConstraint -m 0; | |
} | |
/* | |
Calculate face weighted vertex normals | |
*/ | |
global proc FWVNLT() { | |
string $CurrentShape[] = `ls -sl -dag -o -fl -lf`; | |
string $OBJSel[] = stringArrayRemoveDuplicates( | |
`listRelatives -p -path $CurrentShape` | |
); | |
int $IsFace = size(`filterExpand -sm 34`); | |
int $IsPolygon = size(`filterExpand -sm 12`); | |
if (($IsPolygon >= 1) && ($IsFace == 0)) { | |
string $GetBevel[] = stringArrayRemoveDuplicates( | |
`listConnections -scn true -d true -t "polyBevel3" -et true $CurrentShape[0]` | |
); | |
if (size($GetBevel) == 0) { | |
resetPolySelectConstraint; | |
polySelectConstraint -m 3 -t 0x8000 -sm 1; | |
polySelectConstraint -m 0; | |
$GetBevel = | |
`polyBevel3 | |
-fraction 0.1 | |
-offsetAsFraction 0 | |
-segments 1 | |
-worldSpace true | |
-fillNgons true | |
-mergeVertices true | |
-offset 0.01 | |
-mergeVertexTolerance 0.0001 | |
-smoothingAngle 180 | |
-miteringAngle 180 | |
-angleTolerance 180 | |
-ch true`; | |
polySoftEdge -a 180 -ch 1 $OBJSel; | |
polyNormalPerVertex -fn true $OBJSel; | |
setAttr ($GetBevel[0] + ".offsetAsFraction") 1; | |
select $OBJSel; | |
EditBevelAttr; | |
} else { | |
setAttr ($GetBevel[0] + ".offsetAsFraction") 0; | |
setAttr ($GetBevel[0] + ".offset") 0.01; | |
polySoftEdge -a 180 -ch 1 $OBJSel; | |
polyNormalPerVertex -fn true $OBJSel; | |
setAttr ($GetBevel[0] + ".offsetAsFraction") 1; | |
select $OBJSel; | |
EditBevelAttr; | |
} | |
} else if (($IsPolygon == 0) && ($IsFace >= 1)) { | |
string $TargetFaces[] = `ls -sl -fl`; | |
for ($Face in $TargetFaces) { | |
string $faceNormal[] = `polyInfo -fn $Face`; | |
$array = stringToStringArray($faceNormal[0], " "); | |
float $X = $array[2]; | |
float $Y = $array[3]; | |
float $Z = $array[4]; | |
string $TargetVerts[] = `polyListComponentConversion -ff -tv $Face`; | |
polyNormalPerVertex -xyz $X $Y $Z $TargetVerts; | |
} | |
} else { | |
warning "Hmmm, you don't seem to have a mesh selected. Dafuk ?!"; | |
} | |
} | |
/* | |
Edit bevel attributes | |
*/ | |
global proc EditBevelAttr() { | |
string $Source_Mesh[] = `ls -sl -fl`; | |
string $CurrentShape[] = `ls -sl -dag -o -fl -lf`; | |
string $OBJSel[] = stringArrayRemoveDuplicates( | |
`listRelatives -p -path $CurrentShape` | |
); | |
string $GetBevel[] = stringArrayRemoveDuplicates( | |
`listConnections -scn true -d true -t "polyBevel3" -et true $CurrentShape[0]` | |
); | |
if (`dragAttrContext -exists "NormalsAttrCtx"`) { | |
dragAttrContext -reset; | |
} else { | |
dragAttrContext NormalsAttrCtx; | |
} | |
dragAttrContext | |
-edit | |
-connectTo ($GetBevel[0] + ".fraction" + "\n") | |
NormalsAttrCtx; | |
setToolTo NormalsAttrCtx; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment