Showing posts with label Scripting. Show all posts
Showing posts with label Scripting. Show all posts

Wednesday, January 25, 2012

School and such

Been a while since I last posted an update and I just wanted to keep my blog alive. This spring is my last semester as a graduate student at the University of Texas at Dallas. As part of my graduate project, I am working on an animated short, that you can find here http://cabinfevershort.blogspot.com/ and I'm having to teach myself animation, as we lack animators for the project.

It's coming along very well! In fact I'm looking forward to posting some of the shots I personally worked on. I'm very proud of the work I've been doing for this short and I want to share it on my portfolio, but I want it to be perfect. So I'm still around, just working incredibly hard to finish my degree. I'm hoping to have something posted within the next week!

Thursday, January 27, 2011

Cluster handle creation script

As I create more rigs, I continue to look for more things to automate. I've come up with a new script that creates cluster handles for selected control vertices. I use cluster handles to control the deformations in a spline IK curve for spines or what have you. It was irritating having to select the curve, convert to CV selection, select the CV, create the deformer, and repeat. With this script, you can simply select all of the CV's, and run the script. It will create a cluster handle for each CV and set them to relative, so the curve does not receive double translations when parented in the rig hierarchy. It is a relatively short script so I will post it here in the blog:

//Catches CV's in a selection and creates a cluster deformer for each CV

ls -sl;
string $cjCVArray [] = `filterExpand -sm 28`;

for ($each in $cjCVArray) {

select $each;
newCluster " -relative -envelope 1";
select -cl;

}

I would also like to note that I have finished my FK control creation tool, and will post it as soon as I can find a way to host files for the blog.

Edit: So it was brought to my attention that Maya already has this function built into its menus... The good thing about this script, however, is that it taught me how Maya can use filters to get an array of selected components. Without the filter, your receive an array inside your array, which is pretty useless for what this script does. Basically, if you select CV's and run the script without a filter you get curve1.cv[0:4] instead of a list of each CV. Good practice.


Wednesday, January 19, 2011

FK Control Creation

I have refined my earlier script to accept a selection of multiple joints. Basically, I have added a loop that runs through the selection, and creates, sets, constrains each joint to their respective control, and constrains the control group to the joint up in the hierarchy using a parent constraint. It looks something like this:

while ($positionInSelectionArray < $selectionArraySize) {

Create Control with part of joint name and orient it;
Freeze Transforms; Create Group for control;

Select Joint then Group;
Find the position of the joint in world space using xform;

Use xform to position the group to the joint's position;
Obtain the name of the NURBS control inside the group and select;
Add joint to selection;

Assign NURBS circle to $cjDriver;
Assign Joint to $cjDriven;
Find the group name and parent of the joint and assign them to variables;

Select $cjDriver;
Select $cjDriven;

Orient constrain joint to NURBS circle;
Select parent of joint; Select control group;
Parent Constrain control group to joint parent;
select -cl;

$positionInSelectionArray = $positionInSelectionArray + 1;

}

I am currently working on options in the GUI to allow the user to change the shape of their control NURBS to either a circle or star. There will be another option to either parent the control group to the joint's parent, or parent constrain the control group to the joint's parent. I am also working on an option so the user will be allowed to pick the axis to which the control NURBS will be oriented to. For example:

Currently the code is good for joints that point down the X axis of the joint chain. A user may be more comfortable with a different axis that points down their joint chain, say for example the Y axis. This extra option will rotate the circle to align with a user specified axis. Basically:

if (check box Y axis = true) {

Rotate circle to align with the y axis;
Freeze Transforms;

}

else if (check box Z axis = true) {

Rotate circle to align with the Z axis;
Freeze Transforms;


}

This will allow the tool to be more robust and user friendly. Still working on hosting my scripts some where.

Tuesday, January 11, 2011

Starting to Script

I have been reading a book, "MEL Scripting a Character Rig in Maya," by Chris Maraffi. I'm still learning MEL syntax, but I have managed to create a couple tools from things I picked up from the book.

FK Control Creation

Using part of the author's script, I created an FK control creation tool. I took what Chris Maraffi wrote for his xform tool, and changed particular parts of it. His code queried the translations of an object using the xform command. Well, that works great with objects, but joints inside a hierarchy have transforms based on their parent joint. So, in order to find the transforms of a joint in the hierarchy, I used a world space flag (-ws) to find the transforms of any joint in the world space. From there I created a simple GUI that requests the user to input a part of the joint name they wish to remove.


For example: I select my joint "left_shoulder_bindJT". From here, I activate my arm control tool from the shelf. In the text field I input "_bindJT" which tells my tool to substitute "_bindJT" with blank space. I then select the "Create" button and my FK control NURBs Circle is created. The selected joint is then oriented to the control circle, and the group of the control circle is parent constrained to the joint's parent. For this example, the control is named "cc_left_shoulder" and the control group is named "grp_cc_left_shoulder" which is automatically done by the script.



I am currently working on a way to host the script, and when I do I will post it with instructions on how to use them.