Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. proc sc_pRigger_GUI()
  2.  
  3. {
  4.  
  5. if (`window -exists "sc_pRig_gui"`) deleteUI "sc_pRig_gui";
  6.  
  7. window -w 150 -h 300 -t "pRigger" -maximizeButton false -minimizeButton false sc_pRig_gui;
  8.  
  9. columnLayout;
  10.  
  11. rowColumnLayout -numberOfColumns 3
  12.  
  13. -columnWidth 1 5
  14.  
  15. -columnWidth 2 215
  16.  
  17. -columnWidth 3 5;
  18.  
  19. button -vis 0;
  20.  
  21. textFieldGrp -l "Number of Emitters: " -cw2 100 110 -tx 1 numOfEmits;
  22.  
  23. button -vis 0;
  24.  
  25. button -vis 0;
  26.  
  27. textFieldGrp -l "Rig Type: " -cw2 100 50 rigType;
  28.  
  29. button -vis 0;
  30.  
  31. setParent..;
  32.  
  33. rowColumnLayout -numberOfColumns 3
  34.  
  35. -columnWidth 1 45
  36.  
  37. -columnWidth 2 175
  38.  
  39. -columnWidth 3 5;
  40.  
  41. button -vis 0;
  42.  
  43. string $selectJointGroup = `optionMenu -label "JointGroups:" -changeCommand "#1"`;
  44.  
  45. menuItem -label "Select...";
  46.  
  47. menuItem -label "LeftHandFingers";
  48.  
  49. menuItem -label "RightHandFingers";
  50.  
  51. menuItem -label "LeftIndexFinger";
  52.  
  53. menuItem -label "RightIndexFinger";
  54.  
  55. setParent..;
  56.  
  57. rowColumnLayout -numberOfColumns 7
  58.  
  59. -columnWidth 1 5
  60.  
  61. -columnWidth 2 70
  62.  
  63. -columnWidth 3 5
  64.  
  65. -columnWidth 4 70
  66.  
  67. -columnWidth 5 5
  68.  
  69. -columnWidth 6 70
  70.  
  71. -columnWidth 7 5;
  72.  
  73. button -vis 0;
  74.  
  75. button -l "Refresh" -c sc_emitterPanal;
  76.  
  77. button -vis 0;
  78.  
  79. button -l "Create" -c sc_pRiggerCreate;
  80.  
  81. button -vis 0;
  82.  
  83. button -l "Set" -c sc_pRigNewPos;
  84.  
  85. button -vis 0;
  86.  
  87. setParent..;
  88.  
  89. showWindow sc_pRig_gui;
  90.  
  91. }
  92.  
  93. proc sc_pRiggerCreate()
  94.  
  95. //proc for the initial creation of the rig, taking the UI and implementing, shape is set at square.
  96.  
  97. {
  98.  
  99. //~~~~~~~~~~~~~~~~~~~~~~~
  100.  
  101. //TO DO:
  102.  
  103. //pSet sub-object renames, "pSet+obj"
  104.  
  105. //rename the pSetRoot cubes to "pSet+controlCube"
  106.  
  107. //review var. names
  108.  
  109. //create the curves for the locator controls and parent and group correctly
  110.  
  111. //~~~~~~~~~~~~~~~~~~~~~~~
  112.  
  113. //counter is based upon, the UI field "numOfEmits" where the user decideds how many to rig.
  114.  
  115. int $counter = (`textFieldGrp -q -tx numOfEmits`);
  116.  
  117. //not sure if this int is needed.
  118.  
  119. int $cubeSubCounter = $counter + 1;
  120.  
  121. //if the input contained in the $counter var. is greater than 0 then create the root,
  122.  
  123. //rename it, contain it and move it to the 0 0 0 coord's and perform the while loop.
  124.  
  125. if ($counter>0)
  126.  
  127. {
  128.  
  129. polyCube -n "pRigRoot";
  130.  
  131. move -r -os -wd 0 0 0 ;
  132.  
  133. string $pRigRoot[] = `ls -sl`;
  134.  
  135. int $vertCount = $counter;
  136.  
  137. spaceLocator -n "locGrouper";
  138.  
  139. group -n pSet "locGrouper";
  140.  
  141. string $pSet[] = `ls -sl`;
  142.  
  143. print $pSet;
  144.  
  145. select -cl;
  146.  
  147. select locGrouper;
  148.  
  149. delete "locGrouper";
  150.  
  151. int $pRigRootCheck = `objExists "root"`;
  152.  
  153. //if the root group exists then move the new root to the group.
  154.  
  155. if($pRigRootCheck == 0)
  156.  
  157. {
  158.  
  159. spaceLocator -n "locGrouper";
  160.  
  161. select -cl;
  162.  
  163. group -n "root" "locGrouper";
  164.  
  165. delete "locGrouper";
  166.  
  167. }
  168.  
  169. // while the counter is greater than 0, create a locator, emitter, and particals,
  170.  
  171. //linking the partical to the emitter, and containing each in a var.
  172.  
  173. //lastly subtracting 1 from the counter
  174.  
  175. while ($counter>0)
  176.  
  177. {
  178.  
  179. //locator creation
  180.  
  181. spaceLocator;
  182.  
  183. rename pRigLoc;
  184.  
  185. scale -r 1 1 1;
  186.  
  187. string $pRigLoc[] = (`ls -sl`);
  188.  
  189. //emitter creation
  190.  
  191. 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
  192.  
  193. -mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 ;
  194.  
  195. rename pRigEmit;
  196.  
  197. move -r -os -wd 0 0 0 ;
  198.  
  199. string $pRigEmit[] = (`ls -sl`);
  200.  
  201. //partical creation
  202.  
  203. particle;
  204.  
  205. rename pRigPart;
  206.  
  207. string $pRigPart[] = (`ls -sl`);
  208.  
  209. //dynamic connection for the emiter and partical
  210.  
  211. connectDynamic -em $pRigEmit $pRigPart;
  212.  
  213. //parent constraints for the loc, emit, part and all parented to the root.
  214.  
  215. select $pRigLoc;
  216.  
  217. select -add $pRigEmit;
  218.  
  219. parentConstraint -mo -weight 1;
  220.  
  221. select -r $pRigEmit;
  222.  
  223. select $pRigLoc;
  224.  
  225. select -add $pRigPart;
  226.  
  227. parentConstraint -mo -weight 1;
  228.  
  229. select $pRigRoot;
  230.  
  231. select -add $pRigLoc;
  232.  
  233. doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
  234.  
  235. parentConstraint -mo -weight 1;
  236.  
  237. parent $pRigEmit $pRigLoc;
  238.  
  239. parent $pRigPart $pRigLoc;
  240.  
  241. parent $pRigLoc $pSet;
  242.  
  243. //counter for the while loop
  244.  
  245. $counter = ($counter-1);
  246.  
  247. }
  248.  
  249. //parents the final pieces of the hierachy to the root.
  250.  
  251. parent $pRigRoot $pSet;
  252.  
  253. parent $pSet "root";
  254.  
  255. }
  256.  
  257. }
  258.  
  259. proc sc_emitterPanal()
  260.  
  261. {
  262.  
  263. if (`window -exists "sc_emitter"`) deleteUI "sc_emitter";
  264.  
  265. window -t "Emitter" -maximizeButton false -minimizeButton false sc_emitter;
  266.  
  267. columnLayout -adj 1;
  268.  
  269. select "pSet*";
  270.  
  271. string $sel[] = `ls -sl`;
  272.  
  273. int $pSetCount = size($sel);
  274.  
  275. int $pSetArray = $pSetCount - 1;
  276.  
  277. for ($each in $sel)
  278.  
  279. {
  280.  
  281. rowColumnLayout -numberOfColumns 1
  282.  
  283. -columnWidth 1 100;
  284.  
  285. checkBox $each;
  286.  
  287. }
  288.  
  289. select -cl;
  290.  
  291. showWindow sc_emitter;
  292.  
  293. }
  294.  
  295. proc sc_pRigNewPos()
  296.  
  297. {
  298.  
  299. //~~~~~~~~~~~~~~~~~~~~~~~
  300.  
  301. //TO DO:
  302.  
  303. //get connection info for each locator parent constraingt.
  304.  
  305. //isolate the pRigRoot for the set of each one.
  306.  
  307. //update the parentConstraint.
  308.  
  309. //select variable pSet [counter]
  310.  
  311. //select loc in a new var
  312.  
  313. //select pRig in a new var "ls -sl "pRigRoot""
  314.  
  315. //for each pSet
  316.  
  317. //select -hi
  318.  
  319. //array this number
  320.  
  321. //-1 [this is to counter the root]
  322.  
  323. //count the array numbers
  324.  
  325. //update array's
  326.  
  327. //~~~~~~~~~~~~~~~~~~~~~~~
  328.  
  329. select "pRigLoc_parentConstraint*";
  330.  
  331. string $selLoc[] = `ls -sl`;
  332.  
  333. select -cl;
  334.  
  335. select "pRigRoot*";
  336.  
  337. string $pRootSel[] = `ls -sl`;
  338.  
  339. int $locArrayCounter = size($selLoc);
  340.  
  341. int $rootCounter = size($pRootSel);
  342.  
  343. print $pRootSel;
  344.  
  345. //print $arrayCounter;
  346.  
  347. int $locCounter = 0;
  348.  
  349. int $pSetCount = 0;
  350.  
  351. while ($locCounter < $locArrayCounter)
  352.  
  353. {
  354.  
  355. //figure out the current array number
  356.  
  357. $locCounter = $locCounter + 1;
  358.  
  359. $pSetCount = $pSetCount + 1;
  360.  
  361. string $arrayNum = ("pRigLoc_parentConstraint" + $locCounter );
  362.  
  363. string $rootArray = ("pRigRoot" + $pSetCount);
  364.  
  365. print $pSetCount;
  366.  
  367. //print $counter;
  368.  
  369. //print $arrayNum;
  370.  
  371. //list the parent of each selected object (listRelative is an array evan though in -parent mode only a single result is given)
  372.  
  373. //a blank result means the item is a child of the scene root
  374.  
  375. string $myparents[] = (`listRelatives -p $arrayNum`);
  376.  
  377. print $myparents;
  378.  
  379. //if there are no parents
  380.  
  381. if ($myparents[0] == "")
  382.  
  383. {
  384.  
  385. //print $selLoc;
  386.  
  387. print "Error; Root is scene. \n";
  388.  
  389. }
  390.  
  391. else
  392.  
  393. {
  394.  
  395. select -cl;
  396.  
  397. select pSet|pRigRoot;
  398.  
  399. string $test[] = `ls -sl`;
  400.  
  401. print $test[0];
  402.  
  403. //if the parent of the selected loc is equal to the rootarray num
  404.  
  405. if ($myparents[0] == $rootArray)
  406.  
  407. {
  408.  
  409. print "Skipping conflicting constraint";
  410.  
  411. }
  412.  
  413. else
  414.  
  415. {
  416.  
  417. select -cl;
  418.  
  419. select $arrayNum;
  420.  
  421. //print $selLoc;
  422.  
  423. //print "yes \n";
  424.  
  425. parentConstraint -e -maintainOffset pRigRoot $arrayNum;
  426.  
  427. }
  428.  
  429. }
  430.  
  431. }
  432.  
  433. select -cl;
  434.  
  435. }
  436.  
  437. sc_pRigger_GUI()