edwardE
06-24-2008, 06:23 PM
Hey there; I've got some basic experience with scripting languages and I've set up simple relationships between attributes and objects in Maya, but I need a little help with this one:
I want to control an attribute of multiple objects in closely the same way, but independently of each other, and with some variation.
For this certain instance, I have a tree which has groups of leaves on it, and I want these groups to sway back and fourth using a sine on their rotation. Up until now I've been writing the expressions for each object, coming up with increasingly lengthy lists that are all basically the same lines, but a little variated.
In generic scripting terms (bear with me, I'm no expert) I want it do do something like this:
First, I want to define an key array as object -> rate for each element, where object is the object name, and rate is a value I can assign to each object so that I can evaluate each object in a slightly different manner so things don't look so mechanical. Something like this (reminder: I'm writing this only to illustrate my concept, I might be combining languages/syntax here)
$leaves[] = {
leafName1 -> 5,
leafName2 -> 3,
leafName3 -> 6
};
Then, I want to evaluate them as:
foreach ( $leaves as $leaf -> $rate ) {
$leaf.rotateX = sin( time ) * $rate;
}
That way, the only listing I need to do is in my object array, and things aren't messy and repetitive lines for each object. I just don't know how to implement this as MEL.
Knowing this would help speed up writing expressions and keeping them clean a great deal. Many thanks in advance for reading this; I hope it all made sense!
I want to control an attribute of multiple objects in closely the same way, but independently of each other, and with some variation.
For this certain instance, I have a tree which has groups of leaves on it, and I want these groups to sway back and fourth using a sine on their rotation. Up until now I've been writing the expressions for each object, coming up with increasingly lengthy lists that are all basically the same lines, but a little variated.
In generic scripting terms (bear with me, I'm no expert) I want it do do something like this:
First, I want to define an key array as object -> rate for each element, where object is the object name, and rate is a value I can assign to each object so that I can evaluate each object in a slightly different manner so things don't look so mechanical. Something like this (reminder: I'm writing this only to illustrate my concept, I might be combining languages/syntax here)
$leaves[] = {
leafName1 -> 5,
leafName2 -> 3,
leafName3 -> 6
};
Then, I want to evaluate them as:
foreach ( $leaves as $leaf -> $rate ) {
$leaf.rotateX = sin( time ) * $rate;
}
That way, the only listing I need to do is in my object array, and things aren't messy and repetitive lines for each object. I just don't know how to implement this as MEL.
Knowing this would help speed up writing expressions and keeping them clean a great deal. Many thanks in advance for reading this; I hope it all made sense!
