Home Technical Talk

Maya: Animation Curve -> Mathematical formula

polycounter lvl 19
Offline / Send Message
kodde polycounter lvl 19
Hey guys.

Is there anyway I can get the mathematical formula behind an animation curve?

What I'm after is a custom lighting method in a visually and easily controlled environment. I've got a shader so far where I have control of how the light should influence the shading controlled by a curve(animation curve). Much like hooking up a Surface Luminance -> 2D Ramp -> Shader's Diffuse input. But I'm doing this with a curve instead of the ramp. Combine this with IPR rendering that updates on the fly when I'm tweaking the curve and I got a pretty sweet setup.

Now here's my thought. The animation curve ought to be resolution independent, so it's most likely math based right? I want that math" I want to be able to give this to a programmer and have him implement this in his game engine.

Any thoughts on this?

Thanks.

Replies

  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Here's an image to show what I mean. This solution can't handle completely vertical hills on the curve due to this actually being an animation curve and the fact that you can't have 2 keys on top of each other on the exact same keyframe. T_T

    lightcurves.th.jpg

    If anyone has an other easy solution outside of Maya for then I'm all ears.
  • Illusions
    Offline / Send Message
    Illusions polycounter lvl 18
    I don't have a solution for your current problem, but I can tell you that the Remap Value node has curve based editing, although you lose granular control over tangents (they are reduced to None, Linear, Smooth, and Spline). This way you don't have to rely on animation curves for editing.

    If you've already looked into this method and it turned out animation curves were more useful, my mistake.

    Edit: Looking at an animation curve, each keyframe seems to have a few values...its time, its value, its inAngle, and its outAngle. You might be able to query these.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Ah, I will look into the Remap Value solution. Sounds very similar to what a 2D Ramp solution would do.

    Yeah maybe I could get the help of my programmer colleagues to have a look at that animation curve and see what we could make of it. I tried exporting the scene as a Maya Ascii file to see if I could make anything of it. Didn't seem as simple as I had hoped it to be. Perhaps a Collada exporter or something similar that allows you to export animation could be a way?

    Hmm...

    Thank you for input btw.
  • Illusions
    Offline / Send Message
    Illusions polycounter lvl 18
    I may be able to help more. I animated a simple plane, and saved it out in .ma format, and here is some interesting data from the file:

    createNode animCurveTL -n "pPlane1_translateY";
    setAttr ".tan" 3;
    setAttr ".wgt" no;
    setAttr -s 3 ".ktv[0:2]" 1 0 10 13.589232757275301 20 -7.4898579375440484;
    setAttr -s 3 ".kit[1:2]" 9 2;
    setAttr -s 3 ".kot[1:2]" 9 2;

    .ktv I guess stands for Time/Value. At Frame 1, the plane was at 0. At Frame 10, the plane was at 13.589. At Frame 20, it was at -7.489.

    .kit is the inTangent and .kot is the outTangent. I haven't played around with it enough to know what the values mean.

    Edit: It adds a bunch of other values like .kix .kiy .kox and .koy if you use non-standard tangents.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Cool!
    I think you are on to something here.
    I take it the [0:2] part of the ktv must be the declaring the number of keyframes? 0, 1 and 2?
    The numbers in brackets for the kot is a bit trickier. Never really worked with math for curves like this.
  • Illusions
    Offline / Send Message
    Illusions polycounter lvl 18
    Well here's a simpler way I just realized...

    In the Outliner window, in the Display menu, uncheck DAG Objects Only. A bunch of new nodes will appear. The ones that look like the graph editor are animation nodes. Click on one and bring up the Attribute Editor. Check "Expand Spreadsheet". There you go. :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Sweet!
    Thanks for all your help.
Sign In or Register to comment.