Home Technical Talk

Maya - Mirror animation curve?

Pola
polycounter lvl 6
Offline / Send Message
Pola polycounter lvl 6
Either, Mel or python. I have a curve I want to mirror along the vertical axis and I'm doing so with this:
scaleKey -iub false -ts -1 -vs 1 -animation keys

Its mirroring it along frame 1 as the vertical axis, I know I can use the -tp flag to offset it correctly but I'm not sure how to make that work. Is there anyway to do this via mel/python?

Replies

  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Well..u could use the graph editor,find the curve and go to the stats box and simply change the keyed value from positive to negative and vice versa or doesn't the maya bonus tool have mirror animation?I am still trying to get the hang of the mirror animation thingy.

    Does it just mirror the animation/or position of the object(cause I noticed it mirrors the position very well but don't see any keys even for driven keys),so do u need to set the keys for the new position or it mirrors the actual keys or creates a new set of mirrored keys?
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    I'm not sure, I tried mirror animation and it didn't work for me. Swapping the float values to be the opposite negative>positive positive>negative reverses my animation, thats like mirroring it along a horizontal axis in the graph editor.
  • Flynny
    Options
    Offline / Send Message
    Flynny polycounter lvl 9
    Im not sure what you want to do? Are you after scaling -1 in the up/down(value) direction?

    scaleKey -iub false -ts 1 -vs -1 -animation keys;
    Seems to be what your after..
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    No left/right direction, I know of the up/down one, that works fine.

    scaleKey -iub false -ts -1 -vs 1 -animation keys

    Does left/right but it moves the curve along the timeline rather than flipping it from the curves center.
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    Turns out I was actually manipulating the wrong curve...oops. So up/down is mirror and left/right is reverse, still interested in how reverse is done properly.
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    The curve editor actually supports doing this without any script in case you're interested:
    * Select all keyframes that you want to invert the value for
    * In the second "Stats" input field type "*=-1" and hit enter
    * values for all selected keyframes should be inversed

    This also works for adding (+=) subtracting (-=) and dividing (/=).
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    *=-1 flips it yes, just like the above code I posted. But the curve is offset, its no longer in the same time range it once was. This was also for a script I was trying to make work doing something a bit more complex.
  • Flynny
    Options
    Offline / Send Message
    Flynny polycounter lvl 9
    Ah, I had something that did sort of what your after, il have a look for the script.
  • Flynny
    Options
    Offline / Send Message
    Flynny polycounter lvl 9
    //Select an animated item, highlight the timeline frames you want to reverse
    //run me


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    global proc reverseKeys()
    {
    string $obSelss[] = `ls -sl `;
    int $selected = size($obSelss);//$channels = `channelBox -q -sma "mainChannelBox"`; //$channelLoop = size($channels);
    string $range = `timeControl -q -rng timeControl1`;
    string $time[];
    $numTokens = `tokenize $range "\":" $time`;
    float $timeStart = $time[0];
    float $timeStart = $timeStart;
    float $timeEnd = $time[1];
    float $timeEnd = $timeEnd -1;
    float $timePiv = (($timeStart + $timeEnd)/2);
    float $FrameCount = ($timeEnd - $timeStart);
    string $range = $timeStart + ":" + $timeEnd;
    scaleKey -time $range -timeScale -1 -timePivot $timePiv;
    }
    reverseKeys;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  • Flynny
    Options
    Offline / Send Message
    Flynny polycounter lvl 9
    The above will be a handy script for people and also you should be able to break it down to a more specific action if you wish ;D
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    Thats very useful, thankyou :)
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    oh...its very simple using the graph editor.In the first stats box enter a negative sign in front of whatever key u want to mirror vertically across the graph,also where ur timeslider scroller is located is very important,if u want to mirror a set of keys vertically ensure its on the key or the location u want it to start from,like if u want it to start from -2,ensure the key is on -2 on the the horizontal numbers(timeslider or driver values).
Sign In or Register to comment.