Wednesday, December 15, 2010

IK Spring Solver

IK Spring Solver is useful when posing and animating limbs that have numerous joints such as insect legs. The most prominent function is the ability to adjust the spring angle bias to keep the joint angles to be evenly distributed. To use this IK solver, it has to be activated through an easy MEL script:


Through the Internet, there are many people who bumps into problems while using this IK Solver, especially when performing world rotation that seems not to affect the joints rigged with IK Spring Solver. This problem has been a plague since Maya 7.0 and no rectification is being done up till Maya 2009 (which I am using) to make it behave properly.

The only available fix to it, is to have the first joint of a series of joints bounded to an IK Spring Solver not to be parented to its whatever parent. That joint shall be parent constrained to whatever parent it supposed to be, instead of directly parented underneath them. 

Note that IK Spring Solver will also break if you choose to parent the joints under a transform node and choose that transform node to perform the required parent-constraining. It is okay if you parent constrain the joints to whatever parents it supposed to be as described above, and group the joints in an empty transform node for clarity purposes. 

I guess that is as much as I could explain. Please do drop a message if the problem persists, or my instructions being unclear.

Monday, February 22, 2010

Returning multiple values from a Python function

I was working on my Python scripts. Then I came to a point where I require more than 1 value to be returned from a function that I wrote. Usually, functions in Python can only return one thing, but the one thing can be a collection of items - tuple. The returned values can be broken down into a bunch of variables:

# Create a function as below, with three returns:
def addme(num):
v1 = num + 15
v2 = num - 10
v3 = num * 2
return v1,v2,v3;

# Running the function:

main = addme (15)
sA, sB, sC = addme (15)

#By printing main, main will be equal to (30,5,30):

print main

#By printing main[0], main[1] and main[2], you'll get individual values of 30, 5 and 30 respectively:
 print main[0]
print main[1]
print main[2]

#Or, another way would be printing sA, sB and sC; you'll get 30, 5 and 30 respectively as well:

print sA
print sB
print sC

Thursday, February 18, 2010

'It has non-zero rotations'

Awhile ago I haven't update this. So the previous method was outdated for some time.
A big thanks to Jakub Krompolc who has suggested a more effective solution which I should have rectify to this post earlier. 

cmds.makeIdentity( 'jointName', a=1, r=1 )

"This will convert all rotations to joint orients. Unless your joint hierarchy contains non-resettable objects, like some shapes etc. That`s the only limitation."

Friday, February 12, 2010

Modeling bumpy polygon plane

This simply Python script creates bumpy surface on a polygon plane by altering the Y position of each vertex points in a random manner. The User Presets area can be edited according to your needs.

import maya.cmds as cmds
import random

#User Presets Below This Line-----------------
numberOfVertex = 10200 # Number of vertexes
pName = 'pPlane1' # Name of polygon plane
loR = -5 # Lowest point of bumping
hiR = 5 # Highest point of bumping
mult = 0.1 # Magnitude of randomness
#User Presets Above This Line-----------------

for i in range(1,numberOfVertex):
    vtx = ('%s.vtx[%s]'%(pName,i))

Note that if your polygon plane is very high in resolution, it might take longer to complete depending on the processing power of your machine. I tried 10000+ vertexes and it took my computer's Maya about 30 seconds to complete.

Don't panic if Maya froze during the process!

Wednesday, February 10, 2010

'File contains unknown nodes or data'

Some people happens to run into a problem when trying to save a Maya Binary (.MB) file to Maya ASCII (.MA) file. An error message would pop up mentioning, 'File contains unknown nodes or data. To preserve this information, the current file type cannot be changed.'

In this case, you can write this MEL script to look for the 'unknown' node(s):

ls -type unknown;

A list of unknown node(s) will be generated.
You can delete them by typing:

delete `ls -type unknown`;

By deleting the unknown nodes, the problem should be solved. =]

 UPDATED 12.01.2010 :
Thank you to Ariel for adding extra info.
If it says "Cannot delete locked node", make sure you get the name of that node and select it, and then type:

lockNode -l 0;
Then type again:

ls -type unknown;
delete `ls -type unknown`;

That should do it.

Monday, February 1, 2010

Juss Rig It

Officially online!