Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
MAYA:MAYA ForumMAYA TutorialsMAYA

MEL: assign a unique multiplier

COW Forums : MAYA

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Geoff BaileyMEL: assign a unique multiplier
by on Apr 13, 2005 at 6:03:32 pm

Let's say I have a few hundred layers and I want to animate the first and have all the rest follow at regular intervals.

In After Effects I could write an expression that told each layer to find the position of the lead layer at "time-(offset*index)", where "offset" is a variable and index is the index number of that layer (so layer 2 would multiply the offest by 2, layer 3 by 3, etc.). It's a convention I use all the time in AE for expressions.

Is there any equivelant in Maya expressions where I can assign a number of layers a unique multiplier at increases with each layer?

Hope that's clear.


Return to posts index
Reply   Like  

Steve SayerRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 6:21:03 pm

This is certainly possible, but there may be more economical ways to do it.

The 'getAttr' command can be used with a '-time' flag which reads the value of an attribute at a particular time rather than the current time.

However, it can be computationally expensive to look up a lot of data at other time values. If you really have hundreds of layers, you might want to look into an alternate solution.

I'm not sure what the best solution might be; I'm thinking about feeding the info from the first layer's animation curve(s) directly into the other layers, or perhaps having the first layer write the appropriate info into an array variable which the other layers can then read. Anyone else have any advice or suggestions?

-Steve


Return to posts index
Reply   Like  

Geoff BaileyRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 6:39:43 pm

Thanks Steve.

Economical is what I'm going for. I've been using the 'getAttr' command with a time flag. Since I'm only referencing position and rotation data it hasn't been too bad (even with 1200 layers).

BUT it has meant that I have to paste the expression into 1200 layers and manually adjust the modifier by hand. It's not been too bad, but my brain is slowly turning to mush. The problem is that each layer needs to be offset a little more than the previous layer. I can't figure out how to run a single script to do this.


Return to posts index
Reply   Like  


Sean FennellRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 6:47:10 pm

there are known issues with getAttr -time. Try the frameCache node. You can plug the animation into this node, and then look ahead and behind as many frames or iterations as you wish. And its much more stable than getAttr -time

createNode frameCache (also in the node documentation)


Return to posts index
Reply   Like  

Geoff BaileyRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 6:55:24 pm

Thanks Sean. I know there are problems with the getAttr -time. But I've also had a problem with frameCache. The node caches animation, but it you change the original animation, I've had problems with the frameCache not responding to the updated animation. Any workarounds?

getAttr -time seems to be working okay for now.

Lastly, none of this solves my original problem (thanks for the other comments, though): how to avoid 1200 expressions.


Return to posts index
Reply   Like  

Joaquin (Kino) GilRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 7:45:48 pm

[Geoff Bailey] "how to avoid 1200 expressions."

That's AE-mind-set. You don't have to. Not everything in life is a "layer".

Treat it like an object and simply have the mel script create the "layers" by copying the "master object" with a + or - frame offset 1200 times.

You can add a complementary number of hold frames to each in order to have all start from the same moment in time. It will work somewhat like the "duplicate" panel with a repetition or instance of 1200 and a (constant, variable or random) transformation in the TIME "channel". Grok?

"Instances" are lighter in ram (being the SAME as the master object with a 3d+time transform) and WILL have the same animation and characteristics. For diversity of objects use "copies" instead.

If original placement of the copies is crucial, you can feed the initial positions to all copies from a simple coordinate list in ascii text stored in disk and read at runtime. If different shapes are desired, a similar list can replace the filename reference in a runtime variable from any number of shapes you can read directly from disk.

If you want to have the "above/below" effect when having the objects move, offset their position per copy in the same 3D axis that the camera looks at the objects, say -Z.

You can group them in a container group so in the event of a correction being needed, delete the container group, re-animate the "master" object and run the script again to create your clones.

take care

.k.





Return to posts index
Reply   Like  


Steve SayerRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 8:22:12 pm

[Geoff Bailey] "Lastly, none of this solves my original problem (thanks for the other comments, though): how to avoid 1200 expressions."

EEEK.

Sorry, I mistook the focus of your original post.

Good heavens, Geoff, only one expression should be needed.

What you want to do is create an iterative loop that will step through all your layers automatically, incrementing the offset for each. Try something like the following. This example uses four NURBS spheres, the first one keyframed manually:
int $i;
vector $position = <<0,0,0>>;
for ($i = 2; $i < 5; $i++)
{
string $object = ("nurbsSphere" + $i);

float $offset = $i * 3;

float $valueX = `getAttr -time (frame - $offset) nurbsSphere1.translateX`;
float $valueY = `getAttr -time (frame - $offset) nurbsSphere1.translateY`;
float $valueZ = `getAttr -time (frame - $offset) nurbsSphere1.translateZ`;

vector $position = <<$valueX, $valueY, $valueZ>>;

eval("setAttr " + $object + ".translate " + $position);
}
The key here is using commands nested in a 'for' loop.

The incremenent integer $i counts up as the 'for' loop iterates, and the 'getAttr' and 'eval' commands incorporate the resulting offset into each iteration of the read-and-set attribute operations.

Hmmm, I see Joaquin has posted a reply. I don't know exactly what you're doing with layers and instances; hopefully something that I've posted here will turn out to be useful. Post again if I haven't explained anything well enough.

-Steve


Return to posts index
Reply   Like  

Joaquin (Kino) GilRe: MEL: assign a unique multiplier
by on Apr 13, 2005 at 8:49:03 pm

basically the same solution Steve.

where you actually wrote a loop I simply proposed a generalized solution with provisions for XYposition and Zdepth control and some administering considerations besides frame offset.

As Dad used to say: Great minds run along the same gutters ;)

take care

.k.


Return to posts index
Reply   Like  

Geoff BaileyThanks guys.
by on Apr 13, 2005 at 9:03:36 pm

It's always hard to switch to a new mindset. AE is so limited and I've worked with it for so long, I've found all sorts of bizarre and complicated workarounds to get it to do things it was never supposed to.

I'm not sure I understand everything in Joaquin and Steve's post, but it gives me something to work on. I'll report back if I have more questions.

Cheers.


Return to posts index
Reply   Like  


Joaquin (Kino) GilRe: Thanks guys.
by on Apr 13, 2005 at 9:55:37 pm

[Geoff Bailey] "AE is so limited"

Not for what it does. Only it is not an animation tool.

AE started out as a "CGI Optical Printer" but it did not branch out into a more generalized tool, so the functionalities are similar to the "parent" device, augmented. You can animate and sequence in an optical printer, it used to be done, but there are alternative methods that are more controllable. Even in the optical printer's league there was and is the Oxberry line of animation stands, infinitely better and the de-facto standard at pro drawn animation although they lack the creation of images thorugh automated sequencing of a printer.

Maya, on the other hand is built for animation. Anything goes. Animated sequencing is used everywhere, even for modeling. It has animated paint that grows, MEL, etc. It is very powerful, but you need to see things as an animator in terms of motion so your break-down of the process does not paint you into a corner.

Take care and keep keepin'.

.k.






Return to posts index
Reply   Like  

Geoff BaileyOne last stupid question
by on Apr 14, 2005 at 2:09:00 pm

This has been a really helpful thread in making me rethink how I approach Maya. I just bought MEL programming for animators to help. It's really the programming that is new to me.

One last dumb question: I understand what the script Steve gave me is doing, but where do I put it?


Return to posts index
Reply   Like  

Sean FennellRe: One last stupid question
by on Apr 14, 2005 at 3:43:43 pm

You can put it on a single object and as long as the object names in the line:

string $object = ("nurbsSphere" + $i);

match then it should evaluate. The only problem with steve's expression is it might not actually bind to any attribute since they're kind of implicitely defined. You might want to do something on the first line like this:

nurbsSphere1.visiblity = 1;

....only if the original experssion doesn't evaluate during playback.


Return to posts index
Reply   Like  


Steve SayerRe: One last stupid question
by on Apr 14, 2005 at 3:44:22 pm

Not a stupid question at all; there are (as usual!) about a half-dozen different ways to implement MEL within Maya; I should have specified.

In this case, since you want the code to execute once per frame, to update the position of all the objects for rendering, the code needs to go in an Expression. As a general rule, expressions get evaluated whenever the time changes.

Open up your expression editor, paste the code into the text box, click 'Create,' and you're all set.

Good luck!

-Steve


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]