proc sc_pRigger_GUI()
{
if (`window -exists "sc_pRig_gui"`) deleteUI "sc_pRig_gui";
window -w 150 -h 300 -t "pRigger" -maximizeButton false -minimizeButton false sc_pRig_gui;
columnLayout;
rowColumnLayout -numberOfColumns 3
-columnWidth 1 5
-columnWidth 2 215
-columnWidth 3 5;
button -vis 0;
textFieldGrp -l "Number of Emitters: " -cw2 100 110 -tx 1 numOfEmits;
button -vis 0;
button -vis 0;
textFieldGrp -l "Rig Type: " -cw2 100 50 rigType;
button -vis 0;
setParent..;
rowColumnLayout -numberOfColumns 3
-columnWidth 1 45
-columnWidth 2 175
-columnWidth 3 5;
button -vis 0;
string $selectJointGroup = `optionMenu -label "JointGroups:" -changeCommand "#1"`;
menuItem -label "Select...";
menuItem -label "LeftHandFingers";
menuItem -label "RightHandFingers";
menuItem -label "LeftIndexFinger";
menuItem -label "RightIndexFinger";
setParent..;
rowColumnLayout -numberOfColumns 7
-columnWidth 1 5
-columnWidth 2 70
-columnWidth 3 5
-columnWidth 4 70
-columnWidth 5 5
-columnWidth 6 70
-columnWidth 7 5;
button -vis 0;
button -l "Refresh" -c sc_emitterPanal;
button -vis 0;
button -l "Create" -c sc_pRiggerCreate;
button -vis 0;
button -l "Set" -c sc_pRigNewPos;
button -vis 0;
setParent..;
showWindow sc_pRig_gui;
}
proc sc_pRiggerCreate()
//proc for the initial creation of the rig, taking the UI and implementing, shape is set at square.
{
//~~~~~~~~~~~~~~~~~~~~~~~
//TO DO:
//pSet sub-object renames, "pSet+obj"
//rename the pSetRoot cubes to "pSet+controlCube"
//review var. names
//create the curves for the locator controls and parent and group correctly
//~~~~~~~~~~~~~~~~~~~~~~~
//counter is based upon, the UI field "numOfEmits" where the user decideds how many to rig.
int $counter = (`textFieldGrp -q -tx numOfEmits`);
//not sure if this int is needed.
int $cubeSubCounter = $counter + 1;
//if the input contained in the $counter var. is greater than 0 then create the root,
//rename it, contain it and move it to the 0 0 0 coord's and perform the while loop.
if ($counter>0)
{
polyCube -n "pRigRoot";
move -r -os -wd 0 0 0 ;
string $pRigRoot[] = `ls -sl`;
int $vertCount = $counter;
spaceLocator -n "locGrouper";
group -n pSet "locGrouper";
string $pSet[] = `ls -sl`;
print $pSet;
select -cl;
select locGrouper;
delete "locGrouper";
int $pRigRootCheck = `objExists "root"`;
//if the root group exists then move the new root to the group.
if($pRigRootCheck == 0)
{
spaceLocator -n "locGrouper";
select -cl;
group -n "root" "locGrouper";
delete "locGrouper";
}
// while the counter is greater than 0, create a locator, emitter, and particals,
//linking the partical to the emitter, and containing each in a var.
//lastly subtracting 1 from the counter
while ($counter>0)
{
//locator creation
spaceLocator;
rename pRigLoc;
scale -r 1 1 1;
string $pRigLoc[] = (`ls -sl`);
//emitter creation
emitter -pos 0 0 0 -type omni -r 100 -sro 0 -nuv 0 -cye none -cyi 1 -spd 1 -srn 0 -nsp 1 -tsp 0
-mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 ;
rename pRigEmit;
move -r -os -wd 0 0 0 ;
string $pRigEmit[] = (`ls -sl`);
//partical creation
particle;
rename pRigPart;
string $pRigPart[] = (`ls -sl`);
//dynamic connection for the emiter and partical
connectDynamic -em $pRigEmit $pRigPart;
//parent constraints for the loc, emit, part and all parented to the root.
select $pRigLoc;
select -add $pRigEmit;
parentConstraint -mo -weight 1;
select -r $pRigEmit;
select $pRigLoc;
select -add $pRigPart;
parentConstraint -mo -weight 1;
select $pRigRoot;
select -add $pRigLoc;
doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
parentConstraint -mo -weight 1;
parent $pRigEmit $pRigLoc;
parent $pRigPart $pRigLoc;
parent $pRigLoc $pSet;
//counter for the while loop
$counter = ($counter-1);
}
//parents the final pieces of the hierachy to the root.
parent $pRigRoot $pSet;
parent $pSet "root";
}
}
proc sc_emitterPanal()
{
if (`window -exists "sc_emitter"`) deleteUI "sc_emitter";
window -t "Emitter" -maximizeButton false -minimizeButton false sc_emitter;
columnLayout -adj 1;
select "pSet*";
string $sel[] = `ls -sl`;
int $pSetCount = size($sel);
int $pSetArray = $pSetCount - 1;
for ($each in $sel)
{
rowColumnLayout -numberOfColumns 1
-columnWidth 1 100;
checkBox $each;
}
select -cl;
showWindow sc_emitter;
}
proc sc_pRigNewPos()
{
//~~~~~~~~~~~~~~~~~~~~~~~
//TO DO:
//get connection info for each locator parent constraingt.
//isolate the pRigRoot for the set of each one.
//update the parentConstraint.
//select variable pSet [counter]
//select loc in a new var
//select pRig in a new var "ls -sl "pRigRoot""
//for each pSet
//select -hi
//array this number
//-1 [this is to counter the root]
//count the array numbers
//update array's
//~~~~~~~~~~~~~~~~~~~~~~~
select "pRigLoc_parentConstraint*";
string $selLoc[] = `ls -sl`;
select -cl;
select "pRigRoot*";
string $pRootSel[] = `ls -sl`;
int $locArrayCounter = size($selLoc);
int $rootCounter = size($pRootSel);
print $pRootSel;
//print $arrayCounter;
int $locCounter = 0;
int $pSetCount = 0;
while ($locCounter < $locArrayCounter)
{
//figure out the current array number
$locCounter = $locCounter + 1;
$pSetCount = $pSetCount + 1;
string $arrayNum = ("pRigLoc_parentConstraint" + $locCounter );
string $rootArray = ("pRigRoot" + $pSetCount);
print $pSetCount;
//print $counter;
//print $arrayNum;
//list the parent of each selected object (listRelative is an array evan though in -parent mode only a single result is given)
//a blank result means the item is a child of the scene root
string $myparents[] = (`listRelatives -p $arrayNum`);
print $myparents;
//if there are no parents
if ($myparents[0] == "")
{
//print $selLoc;
print "Error; Root is scene. \n";
}
else
{
select -cl;
select pSet|pRigRoot;
string $test[] = `ls -sl`;
print $test[0];
//if the parent of the selected loc is equal to the rootarray num
if ($myparents[0] == $rootArray)
{
print "Skipping conflicting constraint";
}
else
{
select -cl;
select $arrayNum;
//print $selLoc;
//print "yes \n";
parentConstraint -e -maintainOffset pRigRoot $arrayNum;
}
}
}
select -cl;
}
sc_pRigger_GUI()