Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MEL script for generating plants in Maya
- // The first part is for the UI, and will be saved as a button in the shelf
- // Then the part that will be saved in a .mel file in the script folder
- // UI for basicBranchingCoral
- if (`window -exists bbcWindowZW`)
- deleteUI -window bbcWindowZW;
- window -rtf true -title "Branching Coral" bbcWindowZW;
- columnLayout;
- text " Create a Branching Coral";
- text " ";
- intSliderGrp -minValue 5 -maxValue 2000 -value 50 -label "Number of loops" -field true loopRoundsSlider;
- intSliderGrp -minValue 5 -maxValue 40 -value 15 -label "Angle" -field true angleSlider;
- text " ";
- gridLayout -numberOfRowsColumns 1 3 -cellWidthHeight 130 40;
- button -c "Call_basicBranchingCoralAndClose" -label "Create And Close";
- button -c "Call_basicBranchingCoral" -label "Apply";
- button -c "Call_Close" -label "Close";
- ////
- proc Call_basicBranchingCoral()
- {
- source basicBranchingCoral;
- int $loopRounds = `intSliderGrp -q -value "loopRoundsSlider"`;
- int $rotationAng = `intSliderGrp -q -value "angleSlider"`;
- basicBranchingCoral($loopRounds, $rotationAng);
- }
- proc Call_basicBranchingCoralAndClose()
- {
- source basicBranchingCoral;
- int $loopRounds = `intSliderGrp -q -value "loopRoundsSlider"`;
- int $rotationAng = `intSliderGrp -q -value "angleSlider"`;
- basicBranchingCoral($loopRounds, $rotationAng);
- deleteUI -window bbcWindowZW;
- }
- proc Call_Close()
- {
- deleteUI -window bbcWindowZW;
- }
- //// Window shows:
- showWindow bbcWindowZW;
- /////////////////////////////////////////////////////////////// UI stored in button
- ///////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////// Main proc stored in .mel file
- global proc basicBranchingCoral (int $loopRounds,int $rotationAng)
- {
- int $namesNum = 0;
- int $loopCounter = 0;
- // ------------------------------------------------------------------------------------------------------------------------------------| Make first fucking shape:
- polySphere -r .3 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;
- string $currentObj[] = `ls -sl`;
- select -r ($currentObj[0] + ".f[140:219]") ;
- scale -r -p -2.98023e-008cm 0cm -4.47035e-008cm 1 2.999999 1 ;
- select -r ($currentObj[0] + ".f[240:359]") ($currentObj[0] + ".f[380:399]") ;
- move -r -os -wd 0 1.86 0 ;
- select -r ($currentObj[0] + ".f[0:119]") ($currentObj[0] + ".f[360:379]") ;
- move -r -os -wd 0 -1.863831 0 ;
- select -r $currentObj[0] ;
- move -r 0 -2 0 ($currentObj[0] + ".scalePivot") ($currentObj[0] + ".rotatePivot") ;
- // ------------------------------------------------------------------------------------------------------------------------------------|
- //////////////////////////////////////////////////////////////////////////////////////////////////
- $createShader = 1;
- // check for shader
- string $shads[] = `ls -mat`;
- for ($myNode in $shads)
- {
- if($myNode == "coralColor")
- $createShader = 0;
- }
- switch ($createShader)
- {
- case 0:
- //apply shade
- break;
- case 1:
- //make shader
- shadingNode -asShader aiStandard -n "coralColor";
- sets -renderable true -noSurfaceShader true
- -empty -n coralColorSG;
- connectAttr -f coralColor.outColor coralColorSG.surfaceShader;
- setAttr "coralColor.color" -type double3 0 0 0 ;
- setAttr "coralColor.color" -type double3 1 0.1069 0 ;
- break;
- }
- ///////// --- connect to shader
- // connects to the shader network
- select $currentObj[0];
- sets -edit -forceElement coralColorSG $currentObj[0];
- //////////////////////////////////////////////////////////////////////////////////////////////////
- string $allBranches[] = `ls -sl`;
- int $branchSaveIndex = 1;
- // the first shape is duplicated and changed, then the duplicates are duplicated...:
- for ($loopCounter; $loopCounter < $loopRounds; $loopCounter++)
- {
- select $allBranches[$loopCounter];
- duplicate;
- string $currentObj1[] = `ls -sl`;
- move -r -os -wd 0 4 0;
- rotate -r -os -fo (rand(-$rotationAng, $rotationAng)) 0 (rand(-$rotationAng, $rotationAng));
- $allBranches[$branchSaveIndex] = $currentObj1[0];
- $branchSaveIndex++;
- select $allBranches[$loopCounter];
- duplicate;
- string $currentObj2[] = `ls -sl`;
- move -r -os -wd 0 4 0;
- rotate -r -os -fo (rand(-$rotationAng, $rotationAng)) 0 (rand(-$rotationAng, $rotationAng));
- $allBranches[$branchSaveIndex] = $currentObj2[0];
- $branchSaveIndex++;
- }
- // Now all elements are selected:
- select -cl;
- int $i = ($loopRounds*2);
- for ($i; $i >= 0; $i--)
- {
- select -tgl $allBranches[$i];
- }
- // and put in a group:
- group -n "coral";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement