Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    SplineHelp GetPosition Deformation

    Cinema 4D SDK
    r20 c++ sdk
    2
    3
    614
    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.
    • J
      JohnThomas
      last edited by Manuel

      I am using the GetPosition function from the SplineHelp class to take a user fed in spline and create a new spline. I use the code below to create the new spline with a set number of points.

      
      AutoAlloc <SplineHelp> helperSpline;
      helperSpline->InitSpline(spline, SPLINEHELPFLAGS::NONE);
      Float offsetIncrease = 1.0 / numberPointsPerSegment;
      maxon::BaseArray< maxon::BaseArray<Vector> > vectorDoubleArray;
      maxon::BaseArray<Vector> vectorSingleArray;
      
      for (Int32 segmentIndex = 0; segmentIndex < helperSpline->GetSegmentCount(); segmentIndex++)
      {
      	for (Int32 pointIndex = 0; pointIndex < numberPointsPerSegment; pointIndex++)
      	{
      		vectorSingleArray.Append(helperSpline->GetPosition(pointIndex * offsetIncrease, segmentIndex, TRUE, TRUE));
      	}
      	vectorDoubleArray.Append(vectorSingleArray);
      	vectorSingleArray.Reset();
      }
      
      

      This code works properly on single segment splines, the problem comes in when a spline is fed in that has multiple segments. From what I can tell the first segment is processed properly, subsequent segments start having issues. As the loop runs on the second segment it start becoming deformed at the end.

      Forum Post 1.png

      I know that feeding in an offset to GetPosition that is greater than 1.0 will not return proper results, I confirmed that the offset I am using does not go outside the bounds of 0->1.0. The offset value that will first trigger the issue seems to vary based on the number of points I am trying to put in the spline. This problem only happens if the number of points that I am trying to create on the new spline passes a certain number (this number seems to vary based on the size of the spline segment).

      I can seemingly correct the issue by increasing the Uniform Intermediate Points parameter on the splines that I am feeding into my plugin, this will effect the speed of the plugin and I want to avoid that if possible.

      Is there an alternative way to deal with this issue without increasing the number of Uniform Intermediate Points?

      Any help would be greatly appreciated.

      John Thomas

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        That comes from the Smooth parameter in the function GetPosition. It's doing an interpolation from the end of the segment to the beginning of the next segment (or the first one).

        If you set the parameter to false you will have the correct position.

        GetPosition(pointIndex * offsetIncrease, segmentIndex, false, true))
        

        I will still open a bug entry and ask the dev. This doesn't look logical to me neither 🙂

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • J
          JohnThomas
          last edited by

          Thanks for the response, that's exactly what I needed.

          John Thomas

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