Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Correct Tangent Values

    Cinema 4D SDK
    python
    2
    5
    684
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Tudor
      last edited by Tudor

      Hello friends,
      I'm trying to draw some splines though a python script.
      I get the shape data from after effects where I extract the vertices and in/out tangents of a bezier shape.
      Then I use this bezier data to recreate the object in cinema 4d.
      So far so good, after some try and error and flipping the y-axis the object appear on the right place but the rounding not match really.
      Something is wrong with the tangent values.
      Does cinema interpret these tangent values from after effects different?

      Thanks for your help
      Tudor

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @Tudor
        last edited by i_mazlov

        Hi Tudor,

        Unfortunatelly, without any piece of code and more details it's very difficult to tell you anything non-speculative. How do you get your data from AE? What data the AE tangent values do actually represent? What is the space these values are defined in?

        Please also note that this topic goes on the edge of our Scope of Support, namely, we don't provide support for 3rd party software and libraries. Please also check the "Asking questions" chapter of our "Support Procedures".

        C4D defines tangent values in the original units (i.e. not percentage!) in the object space (i.e. in relation to the vertex). Please have a look at our geometry_splineobject_s26.py example for the corresponding usecase.

        I would like to note that tangents were already discussed in "Get the Neighboring Keys from a Selected Key?", although applied to animation curves, but the tangents concept is the same.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • T
          Tudor
          last edited by Tudor

          Hallo Mazlov,
          i have an example for this:
          This is the bezier data of a circle with 500px radius what I get from Ae:
          I get this values in Ae through:
          myPath = myLayer.content(i).content(j).path.value;
          vertices = myPath.vertices
          inTangents = myPath.inTangents
          outTangents = myPath.outTangents

          vertices: [[0,-500],[500,0],[0,500],[-500,0]]
          inTangents: [[-276.142364501953,0],[0,-276.142364501953],[276.142364501953,0],[0,276.142364501953]]
          outTangents: [[276.142364501953,0],[0,276.142364501953],[-276.142364501953,0],[0,-276.142364501953]]

          If I construct in cinema4D a spline with this values it looks like this
          Circel C4D.png

          spline = c4d.SplineObject(6, c4d.SPLINETYPE_BEZIER)
          points = [...]
          leftTangents = [...]
          rightTangents = [...]
          spline.SetAllPoints(points)
          spline.SetTangent(i, leftTangents, rightTangents).....
          doc.InsertObject(spline)

          I have correct all y values by -1 but in general all tangents appear to long.
          Somewhere in a forum I found that I just need to multiply them with 0.75 and yes indeed it works, but I'm still confused 😉

          i_mazlovI 1 Reply Last reply Reply Quote 0
          • i_mazlovI
            i_mazlov @Tudor
            last edited by

            Hi Tudor,

            yes, it looks like the tangent values you're getting from the AE comply generic Bezier formula and in particular circle case one of the approximation factors is used. I briefly skimmed through the code and it looks like Bezier spline shares implementation with the Cubic Hermite spline, hence there's this 4/3 factor applied to the hermite spline vectors calculation, which you need to account for when using conventional Bezier tangent values. Something similar to what's explained here on slides 24-25: https://www.cs.colostate.edu/~cs410/yr2019fa/more_progress/pdfs/cs410_F19_Lecture24_curves.pdf

            Cheers,
            Ilia

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • T
              Tudor
              last edited by

              Hallo Mazlov,
              lot of thanks for your explanation. I think I don't will get deeper in the math of generic Bezier and Cubic Hermite spline.
              But this is good to know how Ae and C4D interpret these tangent values.
              Meanwhile I finished my script that push every selected Ae-Shape direct to C4D. Works fine so far.
              Thanks for your help!
              Tudor

              1 Reply Last reply Reply Quote 0
              • First post
                Last post