Page 1 of 4 1234 LastLast
Results 1 to 10 of 31

Thread: Help with ColladaMaya bezier animation

  1. #1
    nazure
    Guest

    Help with ColladaMaya bezier animation

    I am having a tough time trying to get animations exported from Maya to playback the same on my custom viewer.

    It seems I am not handling the bezier math correctly.
    Here is the math I am using, which is from the Collada book( Arnaud, Barnes 2006).

    s = (key-k1)/(k2-k1)
    S= (s^3, s^2, s, 1 )
    M = ( -1 3 -3 1, 3 -6 3 0, -3 0 3 0, 1 4 1 0)
    C = ( V1, V2, T1, T2 )

    Interpolated Value = S x M x C

    My interpretation(very unsure) of the parameters are :
    key - time used to obtain interpolated value (k1 <= key <= k2)
    k1 - first key's start time
    k2 - second key's start time
    V1 - value of first key
    V2 - value of second key
    T1 - V1 + inTangent[V1]
    T2 - V2 - outTangent[V2]

    The matrix used for M appears to be for bsplines? Confused...

    The Feeling Viewer also does not produce identical playback when playing back ColladaMaya files.

    Can someone point me in the right direction?

    Thank you!
    nazure

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Unfortunately I haven't yet added support for Collada animations to my tools, but no one else has replied so maybe I can help. The discussion of the animation curves in the book confuses me. It seems fishy that the basis matrix given for Bezier curves is identital to the basis matrix used for B-Splines, just as you pointed out. Also I'm not sure why the spec defines cubic Bezier curves in terms of two control points and two tangents rather than four control points, which is how it's usually defined.

    Assuming there might be something wrong with the Bezier basis matrix given in the book (which I'm not sure about, but it's worth a shot), let's reformulate the curve segment as four control points and use the Bezier basis matrix given in the Foley/van Dam book.

    M = (-1 3 -3 1, 3 -6 3 0, -3 3 0 0, 1 0 0 0) // from Foley, van Dam, Feiner, and Hughes
    C = (p1, p2, p3, p4)
    p1 = V1
    p2 = p1 + 1/3 T1
    p3 = p4 - 1/3 T2
    p4 = V4

    Everything else is the same as you have it above.

    By the way, another possibility is that the animation data is being exported from Maya incorrectly. You could manually construct some simple Bezier curves to make sure the data being input to your program is correct.

  3. #3
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    Yes, you are correct, there is a typo in the book.
    The matrix for 4 control points, which can be computed from the two points and the two tangents is the one you gave:
    M = (-1 3 -3 1, 3 -6 3 0, -3 3 0 0, 1 0 0 0)

    According to my math, if you substitute with:
    T1 = 3 (P2 - P1)
    T2 = 3 (P4 - P3)

    to get back to the form in the book, you have:

    M = (2 -3 0 1, -2 3 0 0, 1 -2 1 0, 1 -1 0 0)
    C = (P1, P4, T1, T2)

  4. #4
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Why is Collada using tangents even though four control points can express more curves? Isn't this causing loss of information?

    I am looking at 'seymourplane.dae' from the sample_data pack: (only relevant information)
    <float_array id="...-output">0 360 </float_array>
    <float_array id="...-intangents">0 6875.42 </float_array>
    <float_array id="...-outtangents">6875.42 0 </float_array>
    <Name_array id="...-interpolations">BEZIER BEZIER </Name_array>

    The values 6875.42 are confusing me. Should they both be 360 to produce linear interpolation?

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Quote Originally Posted by dsrbecky
    Why is Collada using tangents even though four control points can express more curves? Isn't this causing loss of information?
    Actually they're equivalent in what they're capable of expressing. If you have two points and two tangents you can easily convert to four control points, and vice versa. The formulas were given above.

    Having said that I've always seen Bezier interpolation expressed in terms of four control points, and Hermite as two points and two tangents. I think that's pretty conventional and I'm not sure why they decided to do it differently with Collada.

  6. #6
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Ok, I confess that I have seen Bezier equations for the first time today, but I think I am a reasonable mathematician so...

    Quote Originally Posted by sthomas
    Actually they're equivalent in what they're capable of expressing.
    I see I can covert tangents to four control points, but I do not see how to do that the other way round without loss of information. For example, consider two 'four control points' curves:
    Curve1: P1=[0,0] P2=[1,1] P3=[9,1] P4=[10,0]
    Curve2: P1=[0,0] P2=[10,10] P3=[0,10] P4=[10,0]

    I think that these curves are different. However, they both have same tangent form:
    Tangent: P1=[0,0] T1=10 T2=-10 P4=[10,0]
    (where I am taking the tangent value as (dy/dx)*(time interval) )


    Other idea: Can these curves be expressed in tangent form at all?
    Curve3: P1=[0,0] P2=[0,1] P3=[10,1] P4=[10,0] (Seems valid in Blender)
    Curve4: P1=[0,0] P2=[-5,1] P3=[15,1] P4=[10,0] (Probably invalid in DCCs anyway)

    EDIT: I see one reason to use tangents. If you space the points P1, P2, P3 and P4 equally in the x direction (eg 0, 1/3, 2/3, 1) then the interpolated time is linearly dependent on the parameter 's' and vice versa. Therefore is it easy to get 's' for a given time. If 'four control points' are used, I think that you need to solve cubic equation to get 's' for a given time.
    Anyway, this simplification for developers does not justify the possible loss of information due to the need to convert to the tangent form.

  7. #7
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    The key thing is that the curve is not parameterized as y = f(x). Many perfectly valid curves can't be represented in that way, as you've discovered. One example is a line between (0,0) and (0,1).

    Instead we re-parameterize x and y with respect to an independent variable t. These are called parametric curves and are far more flexible than curves of the form y = f(x). For example a line between any two points p0 and p1 can be represented as p(t) = p0 + t(p1-p0), where t is on the interval [0, 1]. Notice this form handles a line between (0,0) and (0,1) with no problems. In graphics we almost always uses parametric curves and surfaces.

    In terms of derivatives, we compute dp/dt as [dx/dt, dy/dt], i.e. you compute the derivative of each component with respect to t independently. This yields the tangent vector.

    You can read more about parametric curves (including Bezier curves) here.

  8. #8
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    This is an excellent point.
    'Four point Bezier' curve is parametric curve and may not necessarily be expressed as y = f(x)
    'Tangent' curve, however, is a polynomial (cubic) and therefore can be expressed as y = f(x)

    Therefore there exist Bezier curves which can not be expressed in the Collada's tangent form.

    EDIT: In other words,
    'Four control point' can express curves:
    x(t) = a*t^3 + b*t^2 + c*t + d
    y(t) = e*t^3 + f*t^2 + g*t + h
    However, 'tangent' curve can express only curves:
    x(t) = a*t
    y(t) = e*t^3 + f*t^2 + g*t + h
    (or also y(x) = a*x^3 + b*x^2 + c*x + d)
    Right?

  9. #9
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    'Tangent' curve, however, is a polynomial (cubic) and therefore can be expressed as y = f(x)
    I'm not sure about your reasoning there. Both the point-tangent and the 4-point forms are cubic polynomial curves (in terms of t), however this doesn't mean that they can be expressed as y = f(x).

    The Hermite curve is a good example of a curve that's usually expressed in point-tangent form. In general, it can't be expressed as y = f(x). For an example, consider the line we had from (0,0) to (0,1). As we discussed that can't be expressed as y = f(x). But the Hermite curve with p1 = (0,0), t1 = (0,1), p2 = (0,1), t2 = (0,1) is one way of describing that line.

  10. #10
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    One thing to keep in mind is that the point-tangent form is also a parametric curve. The tangents being discussed are parametric tangent vectors (dx/dt, dy/dt), not a dy/dx tangent.

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •