AWB - Hair Pop Fix (MEL Script) by Tom

 avatar
unknown
plain_text
a year ago
5.2 kB
25
Indexable
string $mainStrand = "";
string $rightBang = "";
string $leftBang = "";
string $rightSideburn = "";
string $leftSideburn = "";

// Check if Alice_V2_01_COG_LOC exists
if (`objExists "Alice_V2_01_COG_LOC"`) {
    $mainStrand = "Alice_V2_01:ox_groom:GroundStrands24";
    $rightBang = "Alice_V2_01:ox_groom:GroundStrands19";
    $leftBang = "Alice_V2_01:ox_groom:GroundStrands7";
    $rightSideburn = "Alice_V2_01:ox_groom:GroundStrands21";
    $leftSideburn = "Alice_V2_01:ox_groom:GroundStrands20";
}
// Check if Alice_Muddy_01_COG_LOC exists
else if (`objExists "Alice_Muddy_01_COG_LOC"`) {
    $mainStrand = "Alice_Muddy_01:ox_groom:GroundStrands24";
    $rightBang = "Alice_Muddy_01:ox_groom:GroundStrands19";
    $leftBang = "Alice_Muddy_01:ox_groom:GroundStrands7";
    $rightSideburn = "Alice_Muddy_01:ox_groom:GroundStrands21";
    $leftSideburn = "Alice_Muddy_01:ox_groom:GroundStrands20";
}
// Check if Alice_Beach_Outfit_V2_01_COG_LOC exists
else if (`objExists "Alice_Beach_Outfit_V2_01_COG_LOC"`) {
    $mainStrand = "Alice_Beach_Outfit_V2_01:ox_groom:GroundStrands1";
    $rightBang = "Alice_Beach_Outfit_V2_01:ox_groom:GroundStrands19";
    $leftBang = "Alice_Beach_Outfit_V2_01:ox_groom:GroundStrands7";
    $rightSideburn = "Alice_Beach_Outfit_V2_01:ox_groom:GroundStrands21";
    $leftSideburn = "Alice_Beach_Outfit_V2_01:ox_groom:GroundStrands20";
}
// Check if Alice_Baking_School_01_COG_LOC exists
else if (`objExists "Alice_Baking_School_01_COG_LOC"`) {
    $mainStrand = "Alice_Baking_School_01:ox_groom:GroundStrands24";
    $rightBang = "Alice_Baking_School_01:ox_groom:GroundStrands19";
    $leftBang = "Alice_Baking_School_01:ox_groom:GroundStrands7";
    $rightSideburn = "Alice_Baking_School_01:ox_groom:GroundStrands21";
    $leftSideburn = "Alice_Baking_School_01:ox_groom:GroundStrands20";
}
// Check if Alice_Tea_Dress_V2_01_COG_LOC exists
else if (`objExists "Alice_Tea_Dress_V2_01_COG_LOC"`) {
    $mainStrand = "Alice_Tea_Dress_V2_01:ox_groom:GroundStrands1";
    $rightBang = "Alice_Tea_Dress_V2_01:ox_groom:GroundStrands19";
    $leftBang = "Alice_Tea_Dress_V2_01:ox_groom:GroundStrands7";
    $rightSideburn = "Alice_Tea_Dress_V2_01:ox_groom:GroundStrands21";
    $leftSideburn = "Alice_Tea_Dress_V2_01:ox_groom:GroundStrands20";
}
else {
    print("COG_LOC node not found.\n");
}


select -r $mainStrand;
OxAddStrandOperator "" AnimationCacheNode;
rename AnimationCache1 :mainStrandcache;
setAttr -type "string" mainStrandcache.strandGroupPattern "mainStrand";
OxEnableOperator mainStrandcache 1;

select -r $rightBang;
OxAddStrandOperator "" AnimationCacheNode;
rename AnimationCache1 :R_bangcache;
setAttr -type "string" R_bangcache.strandGroupPattern "R_bangStrand";
OxEnableOperator R_bangcache 1;

select -r $leftBang;
OxAddStrandOperator "" AnimationCacheNode;
rename AnimationCache1 :L_bangcache;
setAttr -type "string" L_bangcache.strandGroupPattern "L_bangStrand";
OxEnableOperator L_bangcache 1;

select -r $rightSideburn ;
OxAddStrandOperator "" AnimationCacheNode;
rename AnimationCache1 :R_sideburncache;
setAttr -type "string" R_sideburncache.strandGroupPattern "R_sideBurn";
OxEnableOperator R_sideburncache 1;

select -r $leftSideburn ;
OxAddStrandOperator "" AnimationCacheNode;
rename AnimationCache1 :L_sideburncache;
setAttr -type "string" L_sideburncache.strandGroupPattern "L_sideBurn";
OxEnableOperator L_sideburncache 1;


string $currentProject = `workspace -q -fn`;

string $cachePath = $currentProject + "/mainStrand.abc";
setAttr "mainStrandcache.filePath" -type "string" $cachePath;

string $cachePath = $currentProject + "/R_bang.abc";
setAttr "R_bangcache.filePath" -type "string" $cachePath;

string $cachePath = $currentProject + "/L_bang.abc";
setAttr "L_bangcache.filePath" -type "string" $cachePath;

string $cachePath = $currentProject + "/R_sideburn.abc";
setAttr "R_sideburncache.filePath" -type "string" $cachePath;

string $cachePath = $currentProject + "/L_sideburn.abc";
setAttr "L_sideburncache.filePath" -type "string" $cachePath;

string $allObjects[] = `ls -dag -type transform`;

for ($obj in $allObjects) {
    hide $obj;
}

// Create a progress bar UI
window -title "Progress" -widthHeight 300 100 progressWin;
columnLayout -adjustableColumn true;
text -label "Progress:";
progressBar -width 280 -minValue 0 -maxValue 100 -progress 0 progress;
showWindow;

// Simulate cache operations and update progress
string $caches[] = {
    "mainStrandcache",
    "R_bangcache",
    "L_bangcache",
    "R_sideburncache",
    "L_sideburncache"
};

int $completion[] = {20, 40, 60, 80, 100};

for ($i = 0; $i < size($caches); $i++) {
    OxRecordAnimation $caches[$i];
    progressBar -edit -progress $completion[$i] progress;
    refresh;
    pause -sec 1;
}

// Close the progress bar UI
deleteUI progressWin;

string $allObjects[] = `ls -dag -type transform`;

for ($obj in $allObjects) {
    showHidden $obj;
}


string $message = "if you close your eyes, you wont see any hair pops";
string $title = "Cache Complete";
confirmDialog -title $title -message $message -button "OK";
Editor is loading...