Getting Spline progress percent, given by point



  • On 16/01/2014 at 20:58, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   13,14,15 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi, I have a spline. It has, let us say, 500 points.
    This gives a step value of 1 / 500 = 0.002.

    So to find the position of a point 1/4 forward on the spline, I do

        Vector pointPos = splineData->GetSplinePoint(125 * step); 
    

    I now have the exact position of this particular point, and I can for example do

        	Matrix mMyObject = myObject->GetMg();
    	mMyObject.off = pointPos;
       	myObject->SetMg(mMyObject);
    

    And voila - myObject is positioned exactly at the point on the spline.
    Now, and here comes the challenge:
    I also have a SweepNurbs, which has the spline as property.

    Now, if I set the SweepNurb's End Growth to 25%, it does not match. The reason is probably that the points are not uniformly aligned along the spline. It does not help to change the spline in any way, from linear to bezier, or alter the uniform, subdivide etc properties. Is there a way to get the percentage by the index of the spline point?

    Look at this, you see that the cone is positioned at spline point 125, which is exactly 25 %. But when I set the end growth of the SweepNurbs to 25%, it is way beyond the cone.


Log in to reply