View Full Version : Linear oscillation
10-14-2011, 07:03 PM
So I have an image sequence that's 120 frames long and I have a shot that 300+ frames long.
I need that 120 frame sequence to bounce between 1 and 120 for as long as I want.
I decided to go the programming route (as I do not know another way)
and what I have now is
but this does not give a desired result cause the sine curve is rounded and what I need is a linear wave.
Can anyone help me? I'm afraid I am not the best programmer
10-14-2011, 09:38 PM
This is actually really easy to do with two key frames and an oscillating cycle. In the attribute editor set the image number on your image plane/file in to 1 at frame 1 and right click in the number box and click Set Key. Then go to frame 120 and set the image number and key it again. Once those keys are set open the graph editor and select the image plane/file in by clicking the select button at the bottom of the attribute editor. Then just select the curve (make sure the tangents are set to linear) and click Curves > Post Infinity > Oscillate. If you want to see your magic curves click View > Infinity in the graph editor.
The good thing about this approach vs. an expression is that it will always have absolute values if you scrub around/jump around in time. Whereas a +/- expression could get off as it only updates on a per frame basis.
10-14-2011, 09:52 PM
I actually ended up doing that, but the reason why I wanted to it with code was so I can set it up so that it can control about a 100 nodes. I have 1800 cards in my scene and around 100 textures randomly assigned to those cards.
I wanted to make the code, then pop that into a for loop and edit the expressions of all my image sequences that would have been put into an array.
I got so far as to make the code then get an array set up, but maya refuses to let me change the expression through Mel (throws up an error saying it can't replace an expression as one is already connected to the same attribute of each of the nodes.) so to not waste any more time (since I am on a tight schedule today) I had to go into each node and edit the expression.
10-14-2011, 09:53 PM
This should do what your asking:
int $direction = abs(frame / 120) % 2;
int $value = abs(frame % 120);
if ($direction == 1)
$value = 120 - $value;
10-15-2011, 12:00 PM
Alternate version (just a matter of coding habits)
float $max = 20;
$result = $max - abs((`fmod $i ($max*2)`/($max*2))*2 - 1)*$max;
print ($i + ": " + $result + "\n");
10-15-2011, 12:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.