Wednesday, 18 May 2011

soFar;

For the most part this works, the "set" button which sets a new position for emitters only works if one pSet is present in a scene, thats an issue im trying to sort out, the emitter panal needs some formating and tidying up, but it works and will hopefully help me correct the set button issue.

Friday, 13 May 2011

pRigger - procedure pRiggerCreate

Finished my first alpha procedure for the partical rigger, in short what it does when placed in the master script, is create locators, emitters and particals along with a root control for the rig, which it then parents them all up every creation cycle (cc).

emitters & particals >>>> locators >>>> rootControl >>>> pSet(group)>>>>root(group)

only one "pSet" and "rootControl" is created per cc and only one "root" is created per scene but the number of emitters attached to to a rootControl is currently unlimited.
Some minor tweaks need to the code itself, mostly renaming variables and such, formating and ive probably missed a couple of random variables that need deleting, its only an alpha code at the moment so it shouldnt matter too much, enjoy;
 

Thursday, 5 May 2011

here brian

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;
string $layout = `formLayout`;
string $layoutTabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit
-attachForm $layoutTabs "top" 0
-attachForm $layoutTabs"left" 0
-attachForm $layoutTabs "bottom" 0
-attachForm $layoutTabs "right" 0
$layout;
string $base = `rowColumnLayout -numberOfColumns 3
-columnWidth 1 5
-columnWidth 2 200
-columnWidth 3 5`;
button -vis 0;
textFieldGrp -l "Number of Emitters: " -cw2 100 100 -tx 1 numOfEmits;
button -vis 0;
button -vis 0;
textFieldGrp -l "Rig Type: " -cw2 100 100 rigType;
button -vis 0;
button -vis 0;
button -l "Create" -c sc_pRigger_cube;
button -vis 0;
setParent..;
string $geo = `rowColumnLayout -numberOfColumns 5`;
setParent..;
string $forces = `rowColumnLayout -numberOfColumns 5`;
setParent..;
tabLayout -edit
-tabLabel $base "Emitters" -tabLabel $geo "Geometry" -tabLabel $forces "Forces" $layoutTabs;
showWindow sc_pRig_gui;
}
proc sc_pRigger_cube()
{
int $counter = (`textFieldGrp -q -tx numOfEmits`);
print ("numberOfEmitters:" + " " + $counter + "\n");
int $cubeSubCounter = $counter + 1;
print ("subDivisions:" + " " + $cubeSubCounter + "\n");
if ($counter>0)
{
polyCube -sy $cubeSubCounter -sx 2;
rename pRigCube;
move -r -os -wd 0 0.5 0 ;
int $vertCount = $counter;
while ($counter>0)
{
$vertCount = (($counter - 1)*3+13);
//this now equals the assumption that there is atleast one emitter being rigged.
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.5 ;
string $pRigEmit[] = (`ls -sl`);
//creates renames moves and contains the emitter in a variable.
particle;
rename pRigPart;
string $pRigPart[] = (`ls -sl`);
connectDynamic -em $pRigEmit $pRigPart;
//creates renames moves and contains and links the emitter to the emitter whilst containing the partical in a variable.
$counter = ($counter-1);
//deducts the values for the while loop, prevents infinite loops.
print ("startingVert:" + " " + $vertCount + "\n");
}
}
}
sc_pRigger_GUI()

Wednesday, 4 May 2011

script dump

proc sc_pRigger_GUI()
{
if (`window -exists "sc_pRig_gui"`) deleteUI "sc_pRig_gui";
window -w 150 -h 300 -t "Locator Randomiser" -maximizeButton false -minimizeButton false sc_pRig_gui;
string $layout = `formLayout`;
string $layoutTabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit
    -attachForm $layoutTabs "top"    0
     -attachForm $layoutTabs"left"   0
     -attachForm $layoutTabs "bottom" 0
     -attachForm $layoutTabs "right"  0
     $layout;


string $base = `rowColumnLayout -numberOfColumns 3
                -columnWidth 1 5
                -columnWidth 2 200
                -columnWidth 3 5`;
button -vis 0;
textFieldGrp -l "Number of Emitters: " -cw2 100 100 -tx 1 numOfEmits;
button -vis 0;

button -vis 0;
textFieldGrp -l "Rig Type: " -cw2 100 100 rigType;
button -vis 0;

button -vis 0;
button -l "Create" -c sc_pRigger_cube;
button -vis 0;

setParent..;

string $geo = `rowColumnLayout -numberOfColumns 5`;

setParent..;

string $forces = `rowColumnLayout -numberOfColumns 5`;

setParent..;

tabLayout -edit
          -tabLabel $base "Emitters" -tabLabel $geo "Geometry" -tabLabel $forces "Forces" $layoutTabs;


showWindow sc_pRig_gui;
}


proc sc_pRigger_cube()

{
int $counter = (`textFieldGrp -q -tx numOfEmits`);

    if ($counter>0)
    {
    polyCube -sx $counter;
    rename pRigCube;

    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;
        particle;
        rename pRigPart;


    }
}
sc_pRigger_GUI()

Sunday, 3 April 2011

why so FK?

quick shot of what an fkik joint should look like in the hyper shader once everything is hooked up, this is only one joint, for each corosponding joint the same thing should be applied, all the connections should be labeled in the picture. fairly simple concept combined with some shared attr's it becomes a simple yet effective feature of any rig.

Wednesday, 16 March 2011

Partical Rig

So for the post production brief, our groups project is a space invaders theme, and the way we are generating our space invaders is through geometry instancing in the partical systems, this is one of my jobs, and so as a rigger I set about setting up a partical rig and an easier way of manipulating them, its fairly simple, you manipulate the gridReference box to effect the way the particals behave in space, scale it up to make them spread out, or scale it down to condense them, for the most part it works a charm, the only issue so far is the translate aspect, as its done in world space it produces weird results when moving the main box, but this has given me an idea, sometime in the future I'll be designing a partical rigging system, a way to manage multiple partical systems in different ways. heres a video;

Monday, 28 February 2011

Winrar just finished the min max UI its all now based around variables the user has input and has fully broken away from hard coded values, those values are still coded but now they are defaults for the UI as apposed to the only value usable, the break away from hard code to a fully UI orientated script probably means this is now in beta, but I wont class it as such, until I've created an origin lock on each axis, which in theory will be pretty straight forward but may require more than a few sleepless nights, by and large all the functions currently doable are finalised including the GUI theres a few minor graphical outputs i wish to implement and rearrange the GUI slightly, which i shall change before i continue on with the things i wish to include so it feels complete and easy to use. Also with code formating and the few notes included it hit over 500 lines! 


CODE;

proc sc_gui()
{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Locator Randomiser" -
maximizeButton false -minimizeButton false sc_gui;
columnLayout;
string $sel[] = (`ls -sl`);
separator;
separator;
textFieldButtonGrp -label "Object:"
-text $sel
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
separator;
separator;
separator -style "double" -w 265;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
button -vis 0;
button -vis 0;
text "Frame Settings";
button -vis 0;
button -vis 0;
button -vis 0;
button -vis 0;
setParent..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 5
-columnWidth 3 5
-columnWidth 4 100
-columnWidth 5 5
-columnWidth 6 5
-columnWidth 7 5
-columnWidth 8 100
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
textFieldGrp -l "Start:" -cw2 50 165 -text 1 start;
button -vis 0;
button -vis 0;
button -vis 0;
textFieldGrp -l "Min:" -cw2 50 165 -text 1 minFrame;
button -vis 0;
button -vis 0;
setParent..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 5
-columnWidth 3 5
-columnWidth 4 100
-columnWidth 5 5
-columnWidth 6 5
-columnWidth 7 5
-columnWidth 8 100
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
textFieldGrp -l "Finish:" -cw2 50 165 -text 100 finish;
button -vis 0;
button -vis 0;
button -vis 0;
textFieldGrp -l "Max:" -cw2 50 165 -text 10 maxFrame;
button -vis 0;
button -vis 0;
setParent..;
separator;
separator;
separator;
separator;separator;
separator;
separator -style "double" -w 265;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
text "Min";
button -vis 0;
text "Movement Parameters";
button -vis 0;
text "Max";
button -vis 0;
button -vis 0;
setParent ..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "X:"; //2
button -vis 0; //3
textField -text -10 -aie true -ec sc_minMaxUpdateX minFltSldX;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranX;//6
button -vis 0;//7
textField -text 10 -aie true -ec sc_minMaxUpdateX maxFltSldX;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;//1
button -vis 0;//2
button -vis 0;//3
text "Random:";//4
button -vis 0;//5
checkBox -l " " randChkX;//6
button -vis 0;//7
button -vis 0;//8
button -vis 0;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
separator;
separator;
separator -style "single" -w 265;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Y:"; //2
button -vis 0; //3
textField -text -10 -aie true -ec sc_minMaxUpdateY minFltSldY;//8//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranY;//6
button -vis 0;//7
textField -text 10 -aie true -ec sc_minMaxUpdateY maxFltSldY;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Y" randChkY;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -vis 0;//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 265;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Z:"; //2
button -vis 0; //3
textField -text -10 -aie true -ec sc_minMaxUpdateZ minFltSldZ;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranZ;//6
button -vis 0;//7
textField -text 10 -aie true -ec sc_minMaxUpdateZ maxFltSldZ;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Z" randChkZ;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -vis 0;//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 265;
separator;
separator;
rowColumnLayout -numberOfColumns 3;
button -vis 0 -w 160;
button -l "Key" -c sc_frameCount;
button -vis 0;
setParent ..;
separator;
separator;
showWindow "sc_gui";
}
proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}
proc sc_applyMinMax()
{
int $minX = (`textField -query -text minFltSldX`);
int $maxX = (`textField -query -text maxFltSldX`);
print ($minX + "\n");
print ($maxX + "\n\n");
}
proc sc_minMaxUpdateX()
{
float $minX;
float $maxX;
$minX = (`textField -q -text minFltSldX`);
$maxX = (`textField -q -text maxFltSldX`);
floatSlider -edit -min $minX -max $maxX tranX;
}
proc sc_minMaxUpdateY()
{
float $minY;
float $maxY;
$minY = (`textField -q -text minFltSldY`);
$maxY = (`textField -q -text maxFltSldY`);
floatSlider -edit -min $minY -max $maxY tranY;
}
proc sc_minMaxUpdateZ()
{
float $minZ;
float $maxZ;
$minZ = (`textField -q -text minFltSldZ`);
$maxZ = (`textField -q -text maxFltSldZ`);
floatSlider -edit -min $minZ -max $maxZ tranZ;
}
proc sc_frameCount()
{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = (`textFieldGrp -query -text minFrame`);
int $max = (`textFieldGrp -query -text maxFrame`);
int $randMoveX;
int $randMoveY;
int $randMoveZ;
string $objAttrX;
string $objAttrY;
string $objAttrZ;
int $finalMoveX;
int $finalMoveY;
int $finalMoveZ;
int $objAttrGetX;
int $objAttrGetY;
int $objAttrGetZ;
string $sel[] = (`select`);
string $Ty = "ty";
int $currentFrame = $start;
for ($currentFrame > $start; $currentFrame < $end;)
{
int $randGen = rand($min,$max);
string $selObj = (`textFieldButtonGrp -query -text selObj`);
int $minFltSldX = (`textField -q -text minFltSldX`);
int $minFltSldY = (`textField -q -text minFltSldY`);
int $minFltSldZ = (`textField -q -text minFltSldZ`);
int $maxFltSldX = (`textField -q -text maxFltSldX`);
int $maxFltSldY = (`textField -q -text maxFltSldY`);
int $maxFltSldZ = (`textField -q -text maxFltSldZ`);
currentTime -edit $currentFrame;
$currentFrame = ($currentFrame + $randGen);
//~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~X~
//~~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkX`)
{
$randMoveX = rand($minFltSldX,$maxFltSldX);
}
else
{
$randMoveX = (`floatSlider -query -value tranX`);
}
$objAttrX = $selObj + ".translateX";
$objAttrGetX = `getAttr $objAttrX`;
$finalMoveX = ($objAttrGetX + $randMoveX);
setAttr $objAttrX $finalMoveX;
//~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~Y~
//~~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkY`)
{
$randMoveY = rand($minFltSldY,$maxFltSldY);
}
else
{
$randMoveY = (`floatSlider -query -value tranY`);
}
$objAttrY = $selObj + ".translateY";
$objAttrGetY = `getAttr $objAttrY`;
$finalMoveY = ($objAttrGetY + $randMoveY);
setAttr $objAttrY $finalMoveY;
//~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~Z~
//~~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkZ`)
{
$randMoveZ = rand($minFltSldZ,$maxFltSldZ);
}
else
{
$randMoveZ = (`floatSlider -query -value tranZ`);
}
$objAttrZ = $selObj + ".translateZ";
$objAttrGetZ = `getAttr $objAttrZ`;
$finalMoveZ = ($objAttrGetZ + $randMoveZ);
setAttr $objAttrZ $finalMoveZ;
//~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~End~
//~~~~~~~~~~~~~~~~~~~~~~
setKeyframe `textFieldButtonGrp -query -text selObj`;
}
}
sc_gui()

Saturday, 26 February 2011

Today I gave myself a headache, but fix'd an issue that came about when I added in a couple IF statements, in short;

currentTime -edit $currentFrame;
$currentFrame = ($currentFrame + $randGen);
setKeyframe `textFieldButtonGrp -query -text selObj`;

is wrong, it should be;

currentTime -edit $currentFrame;
$currentFrame = ($currentFrame + $randGen);
IF()
SETATTR
setKeyframe `textFieldButtonGrp -query -text selObj`;

what it was doing was cycling through the FOR loop and not applying anything but keyframing it none the less,  took me ages to notice what it was doing =/

Next I'll need to go in and change the INT's to FLOAT's as I switched them around during debugging.
but it now has a properly random function, inwhich it will randomly keyframe random movements along the different axis, or randomly keyframe a set movement along the different axis. Next piece of functionality will be to make the min max for the axis affect the sliders, then i'll work on origin lock.

GUI;




CODE;

proc sc_gui()
{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Locator Randomiser" -
maximizeButton false -minimizeButton false sc_gui;
columnLayout;
string $sel[] = (`ls -sl`);
separator;
separator;
textFieldButtonGrp -label "Object:"
-text $sel
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 1
-columnWidth 1 260;
text -al "left" " Frame Settings:";
setParent ..;
separator;
separator;
textFieldGrp -l "Start:"
-cw2 50 165 -text 1 start;
textFieldGrp -l "Finish:"
-cw2 50 165 -text 100 finish;
separator;
separator;
textFieldGrp -l "Min:"
-cw2 50 165 -text 1 minFrame;
textFieldGrp -l "Max:"
-cw2 50 165 -text 10 maxFrame;
separator;
separator;separator;
separator;
separator -style "double" -w 260;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
text "Min";
button -vis 0;
text "Movement Parameters";
button -vis 0;
text "Max";
button -vis 0;
button -vis 0;
setParent ..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "X:"; //2
button -vis 0; //3
textField -text -10 minFltSldX;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranX;//6
button -vis 0;//7
textField -text 10 maxFltSldX;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " x" randChkX;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Y:"; //2
button -vis 0; //3
textField -text -10 minFltSldY;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranY;//6
button -vis 0;//7
textField -text 10 maxFltSldY;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Y" randChkY;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Z:"; //2
button -vis 0; //3
textField -text -10 minFltSldZ;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranZ;//6
button -vis 0;//7
textField -text 10 maxFltSldZ;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Z" randChkZ;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 3;
button -vis 0 -w 160;
button -l "Key" -c sc_frameCount;
button -vis 0;
setParent ..;
separator;
separator;
showWindow "sc_gui";
}
proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}
proc sc_frameCount()
{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = (`textFieldGrp -query -text minFrame`);
int $max = (`textFieldGrp -query -text maxFrame`);
int $randMoveX;
int $randMoveY;
int $randMoveZ;
string $objAttrX;
string $objAttrY;
string $objAttrZ;
int $finalMoveX;
int $finalMoveY;
int $finalMoveZ;
int $objAttrGetX;
int $objAttrGetY;
int $objAttrGetZ;
string $sel[] = (`select`);
string $Ty = "ty";
int $currentFrame = $start;
for ($currentFrame > $start; $currentFrame < $end;)
{
int $randGen = rand($min,$max);
string $selObj = (`textFieldButtonGrp -query -text selObj`);
int $minFltSldX = (`textField -q -text minFltSldX`);
int $minFltSldY = (`textField -q -text minFltSldY`);
int $minFltSldZ = (`textField -q -text minFltSldZ`);
int $maxFltSldX = (`textField -q -text maxFltSldX`);
int $maxFltSldY = (`textField -q -text maxFltSldY`);
int $maxFltSldZ = (`textField -q -text maxFltSldZ`);
currentTime -edit $currentFrame;
$currentFrame = ($currentFrame + $randGen);
//~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~X
//~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkX`)
{
$randMoveX = rand($minFltSldX,$maxFltSldX);
}
else
{
$randMoveX = (`floatSlider -query -value tranX`);
}
$objAttrX = $selObj + ".translateX";
$objAttrGetX = `getAttr $objAttrX`;
$finalMoveX = ($objAttrGetX + $randMoveX);
setAttr $objAttrX $finalMoveX;
//~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~Y
//~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkY`)
{
$randMoveY = rand($minFltSldY,$maxFltSldY);
}
else
{
$randMoveY = (`floatSlider -query -value tranY`);
}
$objAttrY = $selObj + ".translateY";
$objAttrGetY = `getAttr $objAttrY`;
$finalMoveY = ($objAttrGetY + $randMoveY);
setAttr $objAttrY $finalMoveY;
//~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~Z
//~~~~~~~~~~~~~~~~~~~~~
if (`checkBox -q -v randChkZ`)
{
$randMoveZ = rand($minFltSldZ,$maxFltSldZ);
}
else
{
$randMoveZ = (`floatSlider -query -value tranZ`);
}
$objAttrZ = $selObj + ".translateZ";
$objAttrGetZ = `getAttr $objAttrZ`;
$finalMoveZ = ($objAttrGetZ + $randMoveZ);
setAttr $objAttrZ $finalMoveZ;
//~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~End
//~~~~~~~~~~~~~~~~~~~~~
setKeyframe `textFieldButtonGrp -query -text selObj`;
}
}
sc_gui()

Thursday, 24 February 2011

Today we dine in MEL Cont.

So today I set about adding some extra functionality, mainly a way to choose wheather or not to have the amount an object moves random or not, i've got as far as the GUI and a rough IF statement, that basicly reads, IF the box is checked then print "test"; else do what your sposed to, im undecided if the code for this should check all the boxes at once, or one by one, it would probably better to break the main FOR loop down into the the three main sections (x,y and z), that way it can differinciate between the 3 different values, were as if I make the check outside the FOR loop in the form of a IF statement, i'll still have to break them appart later. probably better logic to do it seperatly.


Heres the GUI;


 And the code (most of this is GUI orientated);
sc_gui();
proc sc_gui()
{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Locator Randomiser" -

maximizeButton false -minimizeButton false sc_gui;
columnLayout;
string $sel[] = (`ls -sl`);
separator;
separator;
textFieldButtonGrp -label  "Object:"
-text $sel
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
    rowColumnLayout -numberOfColumns 1
            -columnWidth 1 260;
        text -al "left" "      Frame Settings:";

    setParent ..;
separator;
separator;
textFieldGrp -l "Start:"
-cw2 50 165 -text 1 start;
textFieldGrp -l "Finish:"
-cw2 50 165 -text 100 finish;
separator;
separator;
textFieldGrp -l "Min:"
-cw2 50 165 -text 1 minFrame;
textFieldGrp -l "Max:"
-cw2 50 165 -text 10 maxFrame;
separator;
separator;separator;
separator;
separator -style "double" -w 260;

    rowColumnLayout -numberOfColumns 11
        -columnWidth 1 5
        -columnWidth 2 10
        -columnWidth 3 5
        -columnWidth 4 45      
        -columnWidth 5 5
        -columnWidth 6 130
        -columnWidth 7 5
        -columnWidth 8 45
        -columnWidth 9 5
        -columnWidth 10 5
        -columnWidth 11 5
        ;
            button -vis 0;
            button -vis 0;
            button -vis 0;
            text "Min";
            button -vis 0;
            text "Movement Parameters";
            button -vis 0;
            text "Max";
            button -vis 0;
            button -vis 0;
           
           
           
                       
            setParent ..;
    rowColumnLayout -numberOfColumns 11
        -columnWidth 1 5
        -columnWidth 2 10
        -columnWidth 3 5
        -columnWidth 4 45      
        -columnWidth 5 5
        -columnWidth 6 130
        -columnWidth 7 5
        -columnWidth 8 45
        -columnWidth 9 5
        -columnWidth 10 5
        -columnWidth 11 5
        ;
            button -vis 0; //1
            text "X:"; //2
            button -vis 0;    //3
            textField;//4
            button -vis 0;//5
        floatSlider   -min -10 -max 10 tranX;//6
            button -vis 0;//7
            textField;//8
            button -vis 0 ;//9
            button -vis 0;//10
            button -vis 0;//11
        setParent..;



            rowColumnLayout -numberOfColumns 9
                -columnWidth 1 5
                -columnWidth 2 50
                -columnWidth 3 5
                -columnWidth 4 20      
                -columnWidth 5 45
                -columnWidth 6 75
                -columnWidth 7 5
                -columnWidth 8 45
                -columnWidth 9 5
                ;
               
            button -vis 0;//1
            text "Random:";//2
            button -vis 0;//3
            checkBox  -l " x" randChkX;//4
            button -vis 0;//5
            button -vis 0;//6
            button -vis 0;//7
            button -l "Apply";//8
            button -vis 0;//9
           
        setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;



    rowColumnLayout -numberOfColumns 11
        -columnWidth 1 5
        -columnWidth 2 10
        -columnWidth 3 5
        -columnWidth 4 45      
        -columnWidth 5 5
        -columnWidth 6 130
        -columnWidth 7 5
        -columnWidth 8 45
        -columnWidth 9 5
        -columnWidth 10 5
        -columnWidth 11 5
        ;
            button -vis 0; //1
            text "Y:"; //2
            button -vis 0;    //3
            textField;//4
            button -vis 0;//5
        floatSlider   -min -10 -max 10 tranY;//6
            button -vis 0;//7
            textField;//8
            button -vis 0 ;//9
            button -vis 0;//10
            button -vis 0;//11
        setParent..;


            rowColumnLayout -numberOfColumns 9
                -columnWidth 1 5
                -columnWidth 2 50
                -columnWidth 3 5
                -columnWidth 4 20      
                -columnWidth 5 45
                -columnWidth 6 75
                -columnWidth 7 5
                -columnWidth 8 45
                -columnWidth 9 5
                ;
               
            button -vis 0;//1
            text "Random:";//2
            button -vis 0;//3
            checkBox  -l " Y" randChkY;//4
            button -vis 0;//5
            button -vis 0;//6
            button -vis 0;//7
            button -l "Apply";//8
            button -vis 0;//9
           
        setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
          
           
    rowColumnLayout -numberOfColumns 11
        -columnWidth 1 5
        -columnWidth 2 10
        -columnWidth 3 5
        -columnWidth 4 45      
        -columnWidth 5 5
        -columnWidth 6 130
        -columnWidth 7 5
        -columnWidth 8 45
        -columnWidth 9 5
        -columnWidth 10 5
        -columnWidth 11 5
        ;
            button -vis 0; //1
            text "Z:"; //2
            button -vis 0;    //3
            textField;//4
            button -vis 0;//5
        floatSlider   -min -10 -max 10 tranZ;//6
            button -vis 0;//7
            textField;//8
            button -vis 0 ;//9
            button -vis 0;//10
            button -vis 0;//11
        setParent..;


            rowColumnLayout -numberOfColumns 9
                -columnWidth 1 5
                -columnWidth 2 50
                -columnWidth 3 5
                -columnWidth 4 20      
                -columnWidth 5 45
                -columnWidth 6 75
                -columnWidth 7 5
                -columnWidth 8 45
                -columnWidth 9 5
                ;
               
            button -vis 0;//1
            text "Random:";//2
            button -vis 0;//3
            checkBox  -l " Z" randChkZ;//4
            button -vis 0;//5
            button -vis 0;//6
            button -vis 0;//7
            button -l "Apply";//8
            button -vis 0;//9
           
        setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;



 rowColumnLayout -numberOfColumns 3;
        button -vis 0 -w 160;
        button -l "Key" -c sc_frameCount;
        button -vis 0;

    setParent ..;
   
separator;
separator;
showWindow "sc_gui";

}

proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}

proc sc_frameCount()

{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = (`textFieldGrp -query -text minFrame`);
int $max = (`textFieldGrp -query -text maxFrame`);
string $sel[] = (`select`);
string $Ty = "ty";
int $randX = (`checkBox -query -v randChkX`);
int $randY = (`checkBox -query -v randChkY`);
int $randZ = (`checkBox -query -v randChkZ`);
$currentFrame = $start;

if($randX == 1 || $randY == 1 || $randZ == 1)
    {
    print "test";
    }
else{
    for ($currentFrame > $start; $currentFrame <

$end;)
    {   
    int $randGen = rand($min,$max);
    string $selObj = (`textFieldButtonGrp -query -text

selObj`);
    float $randMoveX = (`floatSlider -query -value

tranX`);
    float $randMoveY = (`floatSlider -query -value

tranY`);
    float $randMoveZ = (`floatSlider -query -value

tranZ`);
   
    string $objAttrX = $selObj + ".translateX";
    string $objAttrY = $selObj + ".translateY";
    string $objAttrZ = $selObj + ".translateZ";
   
    int $objAttrGetX = `getAttr $objAttrX`;
    int $objAttrGetY = `getAttr $objAttrY`;
    int $objAttrGetZ = `getAttr $objAttrZ`;
   
    int $finalMoveX = ($objAttrGetX + $randMoveX);
    int $finalMoveY = ($objAttrGetY + $randMoveY);
    int $finalMoveZ = ($objAttrGetZ + $randMoveZ);
   
   
   
    $currentFrame = ($currentFrame + $randGen);
        currentTime -edit $currentFrame;
        setAttr $objAttrX $finalMoveX;
        setAttr $objAttrY $finalMoveY;
        setAttr $objAttrZ $finalMoveZ;
        print ($currentFrame + "\n");       
        print ($randMoveX + "\n");
        print ($randMoveY + "\n");
        print ($randMoveZ + "\n");
        setKeyframe `textFieldButtonGrp -query

-text selObj`;
    }       
    }


sc_gui();

Wednesday, 23 February 2011

Today we dine in MEL

So today I hit a checkpoint with my script, and HAVE A VIDEO!

VIDEO;
video
Awesome, so what does it do, why is it a checkpoint etc. at the moment, all it does is move things along different axis, at random points between a user input time range. it mimics speed by changing the space between the keyframes. i'll figure out how to alter the distance automaticaly later on. It's a checkpoint because the sliders now work, the object select button works and the range is input by the user, plus the GUI looks perty, it will be rearranged to look better and the sections more logical. but other than that not a bad start.

GUI;






CODE;

proc sc_gui()

{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Randomizer" -maximizeButton false -minimizeButton false sc_gui;
columnLayout;
separator;
separator;
textFieldButtonGrp -label "Object:"
-text ""
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
textFieldGrp -l "Start:"
-cw2 50 165 start;
textFieldGrp -l "Finish:"
-cw2 50 165 finish;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
checkBoxGrp -l "Random: "
-cw2 50 165;
separator;
separator;
floatSliderGrp -l "x "
-cw2 40 165 -min -10 -max 10 tranX;
floatSliderGrp -l "y "
-cw2 40 165 -min -10 -max 10 tranY;
floatSliderGrp -l "z "
-cw2 40 165 -min -10 -max 10 tranZ;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
button -l "Frame" -c sc_frameCount;
showWindow "sc_gui";
separator;
separator;
}
proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}
proc sc_frameCount()
{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = 1;
int $max = 10;
string $sel[] = (`select`);
string $Ty = "ty";
$currentFrame = $start;
for ($currentFrame > $start; $currentFrame < $end;)
{
int $randGen = rand($min,$max);
string $selObj = (`textFieldButtonGrp -query -text selObj`);
float $randMoveX = (`floatSliderGrp -query -value tranX`);
float $randMoveY = (`floatSliderGrp -query -value tranY`);
float $randMoveZ = (`floatSliderGrp -query -value tranZ`);
string $objAttrX = $selObj + ".translateX";
string $objAttrY = $selObj + ".translateY";
string $objAttrZ = $selObj + ".translateZ";
int $objAttrGetX = `getAttr $objAttrX`;
int $objAttrGetY = `getAttr $objAttrY`;
int $objAttrGetZ = `getAttr $objAttrZ`;
int $finalMoveX = ($objAttrGetX + $randMoveX);
int $finalMoveY = ($objAttrGetY + $randMoveY);
int $finalMoveZ = ($objAttrGetZ + $randMoveZ);
$currentFrame = ($currentFrame + $randGen);
currentTime -edit $currentFrame;
setAttr $objAttrX $finalMoveX;
setAttr $objAttrY $finalMoveY;
setAttr $objAttrZ $finalMoveZ;
print ($currentFrame + "\n");
print ($randMoveX + "\n");
print ($randMoveY + "\n");
print ($randMoveZ + "\n");
setKeyframe `textFieldButtonGrp -query -text selObj`;
}
}
sc_gui()