Tuesday, March 25, 2014

Overriding Maya's duplicate defaults for better stability

Everything in Maya is basically name based. Move the sphere named "ball" over by 24 units etc.

Amazingly you can break a lot of simplicity of Maya by simply having 2 objects named the same thing.
In the following, if you were to type "select ball" Maya will return an error: or "setAttr ball.ty 100;" or basically any command that doesn't use the full path of the object. which is very common.( in Maya default and in many online scripts)

// Error: line 1: More than one object matches name: ball
 "group1| ball"  & "group2|ball"



Obviously this is not ideal.
In my experience I've found it is just easier to give every node in Maya a unique name and avoid name clashing as much as possible.

 However. The duplicate and duplicate with transform in Maya no longer has any options that you can customize, and by default is not set to rename children.

so if you duplicate "group2|ball" you will get "group3|ball"   as it only cares about objects in the same parent space.

I'm not exactly why it was decided to remove the options for duplicate and duplicate with transform , but I'm not a fan.

So I hijack the scripts and put them in my prefs/scripts/ directory and let it ignore the embedded Maya commands.

for Duplicate do a "whatIs performDuplicate.mel" and copy paste that script into your prefs dir.
then edit that script with the info below

//___________performDuplicate.mel____________________________

find the line that says :
int $renameChild = 0;
and replace the 0 with a 1
int $renameChild = 1;



for Duplicate with Transforms its a little easier, as it just uses the duplicate command , so you can add the following as a script in your prefs/scripts/ dir.


//___________DuplicateWithTransforms.mel____________________________
global proc DuplicateWithTransform ()
{
evalEcho("duplicate -rc -smartTransform")
}


the nice thing is, Duplicate Special still has an option box (for now) so if you want to duplicate a bunch of objects and retain non-unique child names, you can.





hope this helps
-=s

Friday, March 14, 2014

Smann's Toolbox Shelf for Maya


Okay, I hate the toolbox, I think it's a waste of space. So I started tinkering around with adding a shelf to it to make it more useful. 

 I've got everything working, now I'm just gonna try it out in production and see how it all holds up.

Right Now I'm over writing Maya's internal toobox,mel by putting mine in the prefs/scripts folder, but I think eventually I'd like to do it like addSideShelf.mel and have it just add to the toolbox rather than override.. but first I have to see how well this idea even works.

also, right now I only made 1 possible shelf available.. maybe down the line I'll add tabs.  but at some point the internal maya commend "shelfLayout" lost its ability to be vertical. 



Wednesday, February 19, 2014

quickControl.mel

again with the facebook requests!

in any case, super quick script for creating control curves based on selected objects and parenting the objects under them





// stephenkmann@gmail.com
// creates a nurbs curve with a parent, and parents the selected objects under it alla  a quick control //curve for animation.
global proc quickControl ()
{
string $sel[] = `ls -sl`;
for ($each in $sel)
    {
    float $pos[] = `xform -q -ws -rp $each` ;
    float $rot[] = `xform -q -ws -ro $each`;
    select -cl;
    string $grp = `group -em -n ($each + "CONGR")`;

    string $control =` curve -n ($each + "CONTROL") -d 1 -p -4 0 -4 -p 4 0 -4 -p 4 0 4 -p -4 0 4 -p -4 0 -4 -p 0 0 -4 -p 3.134446 0 -3.134446 -p 4 0 0 -p 3.134446 0 3.134446 -p 0 0 4 -p -3.134446 0 3.134446 -p -4 0 0 -p -3.134446 0 -3.134446 -p 0 0 -4 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 `;
    parent $control $grp;

move -rpr -xyz $pos[0] $pos[1] $pos[2]  $grp;
xform -ws -ro $rot[0] $rot[1] $rot[2]  $grp;

parent $each $control;

    }
}

Friday, February 7, 2014

Quick Script for making an ikSpline rig along selected curves

So  a friend of mine posted a question/request about needing a script to make joint chains on hair curves and then applying some sort of joint ikSpline rig to those curves, and then binding that to the respective geo.

 I was bored. Saw his post and said, sure,  why not.  I write this kind of stuff all the time, so why not expand a little and share.



So here is what I wrote, with over commenting.  

 maybe it will help someone, or they can get a laugh out of it as it is written in mel.

The use of this is based on a selection of curves, and those curves have matching geo with the suffix "GEO"
  It creates a joint chain of 10 joints and scales them to match the length of the selected curves, and then uses that curve as an ikSpline handle, and then does a simple bind of the joints to the geo.

The idea being that your geo is just named the same as the curve, plus GEO.
ie: "curve178' has  a corresponding geo named "curve178GEO"  To be fair, its not often we have this scenario where curves and geo match each other, but that's what cometRename is for.. and I do this a lot,  I know I don't want that geo named anything like that, but I'll temporarily name it that way to make the script slightly easier, and then after the fact I'll just name them back to something better. ( if it matters)

also, I didn't do any nice naming of anything in this script, its all whatever Maya wants to name it.. Generally I don't do that either. I give everything matching names that make sense and make it easy to find relationships later. ( visually / mentally ) . Naming nodes is really just to help us humans.    Cause really , it doesn't matter what anything is named , you can always follow the connections.( but clashing names are always bad, for humans and computers) .

//--------------------------------------------------
global proc curveJointRig ()
{
string $crvs[] = `ls -sl`;
select -cl;
// create GOD group
string $grp = `group -em -n "GOD"`;
select -cl;
for ($crv in $crvs)
    {
    // arclen creates a node called curveInfo and connects it to the given curve.   
    // the main use here is to get the length of the curve to figure out how long the joints 
    // should be, and to then use that to drive their stretch  
    //  for more info   `help -doc arclen`;
    string $cInfo = `arclen -ch -1 $crv`;
    float $dis = `getAttr ($cInfo + ".arcLength")`;
 
    float $jlen = ($dis / 10);
    string $jnts[];
    clear $jnts;
    int $i = 0;
    while ($i <= 10)
        {
        // the joint command makes joint.. in this case I'm just putting them at 0 1 2 3 
        // as I don't know yet what length i want them to be.   for more info `help -doc joint`;
        string $jnt = `joint -p $i 0 0 `;
        $jnts[`size$jnts`] = $jnt;
        int $n = `size$jnts`;
        print ($jnt + "  " + $jnts[$n -1] + " /n");
        // I used catch here as I don't really care if it works or not, 
        //when making joints if the joint stays  selected while you create the next joint, 
       // it will automatically parent correctly also, I'm not doing any rotation axis settings here,, 
        // for more info `help -doc catch`;
        catch (`parent $jnt $jnts[$n -2]`);
        $i++;
        setAttr ($jnt + ".tx") $jlen;
        }
    // make ikSpline handle    for more info `help -doc ikHandle`;
    ikHandle -sol ikSplineSolver -sj $jnts[0] -ee $jnts[(`size $jnts` -1)] -ccv false -pcv false -curve $crv;  
 
    // do some stretch rigging   yadda yadda yadda  joints on chain, scale with curve as it gets
    // longer and shorter based on the arclength dividing the original length of the curve and the     //current length, which is then plugged into the scaleX of the joints
    //( did not do any twist rigging here) this is a pretty standard practice. 
    // operation sets how the mult div works, 1 =mult, 2 = divide, 3= pow
    string $multA = `createNode multiplyDivide`;
    setAttr ($multA + ".operation") 2;
    connectAttr ($cInfo +".arcLength") ($multA + ".input1X");
    setAttr ($multA + ".input2X") $dis;
    string $multB = `createNode multiplyDivide`;
    setAttr ($multB + ".operation") 2;
    connectAttr ($multA + ".outputX") ($multB + ".input1X");
        for ($jnt in $jnts)
        {
        connectAttr ($multB + ".outputX") ($jnt + ".sx");
        }
     
     // some clean up  This is just grouping, and plugging the scaleX of the main group
     //  into the secondary mult that will keep things from exploding.
     // that only works if you parent the joints under the group as well.
    // this curve has no rig on it, so I put that in there as well, but normally I want put joints
    // on it, or clusters and those would go in the group, and not the curve
     parent $jnts[0] $grp;
     parent $crv  $grp ;
     connectAttr ($grp + ".sx") ($multB + ".input2X" );
      select -cl;


     // bind?  ( I really did the least amount of scripting possible here.. but it should give 
    // a base to start with     for more info use `help -doc skinCluster`;
     skinCluster -dr 7.5 -tsb $jnts ($crv + "GEO");


     select -cl;
     print ("finished " + $crv + " \n");
    }
     
}

//-----------------------------------------------------


here is just the node graph of the curveInfo to the multDiv to the joints .




well, anyway, I hope that helps someone.. or gives them a laugh. .

 -=s





Wednesday, November 13, 2013

node editor Knife !

Just found this accidentally while using alt + ctrl + left mouse button drag to zoom in and out of the node editor.

if you use shif + ctrl + LMB drag you get a little knife pointer and you can draw straight lines to cut connections between nodes.   As I was trying to figure out what it was I accidentally sliced through  a bunch of connections by mistake.

its kinda cool though now that I know what it is.

-=s




Wednesday, October 30, 2013

Using extra geo to aid in Weight Painting quick tip

I keep telling myself to put stuff on this blog and I never do..   So I figure just do quick bursts. 

 I'm sure most people do this already , but I thought I'd throw it out there. 

 The image below shows 3 pieces of geo, that upper flap thing there was giving me trouble weighting quickly as the weights on the bottom and top didn't line up, so in many positions that geo would penetrate.    
  a fast quick way to do this is to duplicate your geo and cut off the offending part, and make it a single surface..  In this case I had multiple issues with this geo, so I ended up making 2 extra pieces.  

In this case mirroring and copy skin weights tolerances were too high, or just didn't want to work like I wanted them to, so I knew I couldn't do a regular copy skin weights.  

so the blue geo is a copy of the orange geo ( the hero geo) , that I did a base smooth bind to and smoothed the hell out of it using smoothFlood.mel  ( which I love) .

after getting a semi decent but still penetrating weight map on this flap, I then duplicated it again, and cut off the flap and then cut it in half. 

 I then copied weights from the blue to the cut off flap.. 

 I did minimal weight fixes to the flap. but it was fast as I didn't need to deal with a volume surface. 

I then reversed the process and copied the weights from the cut off flap to the blue geo. but I did the copy ONLY to the verts I wanted.   

To do this select your first piece of geo, and then rt click on the second geo and choose vertex to enable vertex selections , Do not hit F8 as you want your first geo to remain selected as it was. 

you can then shift select the verts you want to copy to , and then run Copy Skin Weights. 

which I did for other parts on the blue geo, and then eventually did the same to go from the blue to the hero orange geo. 

( you can also make a set of the verts you want to copy to , and just shift select that ) 

okay, hope that helps someone..

-=s


Thursday, September 26, 2013

Ziploc Fresh Forward with Rachel Ray

All CG,
built some fun rigs and scripts for this one to control the slicing of the fruit vegetables and the zipping and unzipping of the ziploc bags